使用rAmCharts包的聚簇堆积柱形图

时间:2019-08-07 17:05:11

标签: javascript r amcharts

我正在尝试通过软件包AmCharts JS library使用rAmCharts的R实现绘制群集堆栈柱形图

library(rAmCharts)
library(dplyr)

Data_DF11 = structure(list(x = structure(1:2, .Label = c("2018 Q3", "2018 Q4"
), class = "factor"), y1 = c(NA, NA), y2 = c(100, 100), y3 = c(NA, 
NA), y4 = c(59.71, 59.71), y5 = c(40.22, 40.21), y6 = c(0.0699999999999932, 
0.0799999999999983), z1 = c(NA, NA), z2 = c(NA, NA), Z3 = c(NA, 
NA), z4 = c(NA, NA), z5 = c(NA, NA), Z6 = c(NA, NA)), class = "data.frame", row.names = c(NA, 
-2L))


amChart_Plot = amSerialChart(categoryField = "x", precision = 2, rotate = FALSE, plotAreaBorderAlpha = 1, plotAreaBorderColor = '#000') %>%
                                              setDataProvider(dataProvider = Data_DF11, keepNA = TRUE) %>%
                                              addGraph(valueField = "y1", fillColors = '#78bcff', fillAlphas = 0.8, bullet = "round", lineThickness = 0, type = 'column', stacked = FALSE,
                                                        fixedColumnWidth = 50, bulletColor = "transparent") %>%
                                              addGraph(valueField = "y2", fillColors = '#1e90ff', fillAlphas = 0.8, bullet = "round", lineThickness = 0, type = 'column', stacked = TRUE,
                                                        fixedColumnWidth = 50, bulletColor = "transparent")  %>%
                                              addGraph(valueField = "y3", fillColors = '#092b4c', fillAlphas = 0.8, bullet = "round", lineThickness = 0, type = 'column', stacked = TRUE,
                                                        fixedColumnWidth = 50, bulletColor = "transparent")  %>%
                                              addGraph(valueField = "y4", fillColors = '#e38dce', fillAlphas = 0.8, bullet = "round", lineThickness = 0, type = 'column', stacked = FALSE,
                                                        fixedColumnWidth = 50, bulletColor = "transparent") %>%
                                              addGraph(valueField = "y5", fillColors = '#d85db9', fillAlphas = 0.8, bullet = "round", lineThickness = 0, type = 'column', stacked = TRUE,
                                                        fixedColumnWidth = 50, bulletColor = "transparent")  %>%
                                              addGraph(valueField = "y6", fillColors = '#6c2e5c', fillAlphas = 0.8, bullet = "round", lineThickness = 0, type = 'column', stacked = TRUE,
                                                        fixedColumnWidth = 50, bulletColor = "transparent")  %>%
                                              setBalloon(cornerRadius = 12, textAlign = "left", maxWidth = 1300) %>%
                                              setChartCursor(cursorAlpha = 0, oneBalloonOnly = TRUE, categoryBalloonEnabled = FALSE)

                            amChart_Plot@valueAxes = list(list(title = "Shareholding Pattern", 
                                                                position = 'bottom', titleBold = FALSE, 
                                                                minMaxMultiplier = 1.05, minimum = 0, stackType = "regular"))

                            amChart_Plot

正如您在此处看到的那样,我得到每个日期的单个堆积柱状图。但是,我希望每个日期有2个堆积的柱形图,并有2个分组(y1, y2, y3)(y4, y5, y6)

如果有人将我引导到正确的方向,这将非常有帮助。

0 个答案:

没有答案
相关问题