highcharts - 在带有 highcharter 的图中混合solidguage 和 column
问题描述
我有这两个数据框
1)t1(Var1(数字),Var2(字符串),Freq(数字))
2)pref.media(pref.media(数字)
我有这个分开的图表,但我想在同一个图表中打印两个系列
1)柱形图,ok
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) 实心量规图 (ok)
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 的示例进行了尝试
谢谢
解决方案
推荐阅读
- apache-spark - 为什么 Spark 工作节点上完成的任务比主节点少得多?
- node.js - 带有 fs、缓冲区和流的 TypeORM 错误
- haskell - 镜头访问地图键
- python - Python GraphQL API 调用组合
- c# - 在 Visual Studio c# 中生成 (ListView) 的网格
- python - Pandas 列 - 如何将列表的字符串表示更改为字符串列表?
- javascript - 如果 styleName 存在,则签入反应组件
- mysql - 非主键上的MySQL重复输入错误
- ruby-on-rails - Stripe Checkout Beta:避免为每次付款创建新客户
- python - 是否可以在棉花糖中定义具有互斥字段的嵌套模式?