用高位图表将Solidgugu和列混合

时间:2018-09-23 10:46:16

标签: highcharts

我有两个数据框

1)t1(Var1(数字),Var2(字符串),频率(数字))

2)首选媒体(首选媒体(数字)

我有这个分离的图形,但是我想在同一图形中打印两个系列

1)柱形图,好的

column1 <- highchart() %>%
 hc_add_series(t1$Freq, type = "column") %>%
 hc_xAxis(categories = t1$Var1) %>%
 hc_plotOptions(series = list(showInLegend = FALSE,dataLabels = list(enabled = TRUE, color = t1$Var1)))

2)固体压力表(确定)

gauge1 <- highchart(width = 800, height = 600) %>%
 hc_chart(type = "solidgauge",backgroundColor = "#F0F0F0",marginTop = 50) %>%
 hc_title(text = "Preferencia",style = list(fontSize = "24px")) %>%
 hc_tooltip(borderWidth = 0, backgroundColor = 'none',shadow = FALSE,style = list(fontSize = '16px')) %>%
 hc_pane(startAngle = -90,endAngle = 90) %>%
 hc_yAxis(min = 0,max = 11,lineWidth = 0,tickPositions = list(0,1,2,3,4,5,6,7,8,9,10,11)) %>%
 hc_plotOptions(solidgauge = list(borderWidth = '34px',dataLabels = list(enabled = TRUE, style = list(borderWidth = 3,backgroundColor = 'none',shadow = FALSE, fontSize = '16px',color="#888800")),linecap = 'round',stickyTracking = FALSE)) %>%
 hc_add_series(name = "Preferencia",borderColor = "#000000",data = list(list(color = "#888800"),radius = "100%",innerRadius = "100%",y =  round(pref.media[[1,1]],2)))

3)混合图表(不好,有错误)

highchart() %>%
 hc_add_series(t1, "column", hcaes(x = Var1, y = Freq), name = "Preferencia") %>%
 hc_add_series(pref.media, "solidgauge", hcaes(name = "Gauge", y = round(pref.media[[1,1]],2)), name = "Indicador") %>%
 hc_plotOptions(
      series = list(showInLegend = FALSE,pointFormat = "{point.y}%"),
      column = list(colorByPoint = TRUE),
      solidgauge = list(borderWidth = '34px',dataLabels = list(enabled = TRUE),linecap = 'round',stickyTracking = FALSE)) %>% 
 hc_pane(startAngle = -90,endAngle = 90) %>%
 hc_yAxis(title = list(text = "Porcentaje de preferencia"),labels = list(format = "{value}%"), max = 100) %>% 
 hc_xAxis(categories = t1$Var1) %>%
 hc_title(text = "Título") %>%
 hc_subtitle(text = "Subtítulo") 

我不明白将两个系列混合的顺序。我在http://jkunst.com/highcharter/highcharts.html

中以J.Kunst的示例进行了尝试

谢谢

0 个答案:

没有答案