问题描述
我不确定是否可以在高级图表中完成此操作,但是,我有一个场景,其中绘制了7个系列,默认情况下,我只需要显示3个,但是其余4个应该显示为灰色,但是用户可以单击并根据需要选择.
I am not sure whether this could be done in highcharter, however, I have a scenario where I have 7 series plotted of which by default I need to display only 3, however remaining 4 should be greyed out but be present, user can click and select if needed.
那么,我们该怎么做呢?欢迎提出所有建议.我做了一些研究,但是我没有得到任何线索.
So, how can we do that? All suggestions are welcome. I did some research, however i was not able to get any leads.
谢谢!
hc <- highchart(type = "stock") %>%
hc_title(text = paste0("<span style=\"color:#000000\">", prod_line, ", ", sku , " at ", cust_group , "</span>")) %>%
hc_subtitle(text = paste0("<span style=\"color:#000000\">", prod_mktg_name, "</span>")) %>%
hc_yAxis_multiples(yaxis) %>%
hc_add_series(yAxis = 0, name = "Retail Price", candle_data, type = "candlestick", color = "white") %>%
hc_add_series(yAxis = 0, name = "COGS($)" , data = my_xts_data$COGS_dollar, color = "blue") %>%
hc_add_series(yAxis = 0, name = "MSRP", data = my_xts_data$MSRP, color = "black") %>%
hc_add_series(yAxis = 0, name = "Sell In Price", data = my_xts_data$SI_price, color = "orange") %>%
hc_add_series(yAxis = 1, name = "Sell In Units", data = my_xts_data$SI_units, color = "orange", type = "column") %>%
hc_add_series(yAxis = 1, name = "Channel Inv Units", data = my_xts_data$CI_units, color = "gray", type = "column") %>%
hc_add_series(yAxis = 1, name = "Sell Thru Units", data = my_xts_data$ST_units, color = "black", type = "column") %>%
hc_legend(enabled = TRUE) %>%
hc_exporting(enabled = TRUE) %>%
hc_tooltip(shared = TRUE)
hc
推荐答案
您可以将参数"visible = FALSE"添加到hc_add_series函数中
You can add the argument 'visible = FALSE' to the hc_add_series functions
https://api.highcharts.com/highcharts/plotOptions.series.visible
Highcharter示例下方
Highcharter example modified from http://jkunst.com/highcharter/highstock.html below
library("quantmod")
usdjpy <- getSymbols("USD/JPY", src = "oanda", auto.assign = FALSE)
eurkpw <- getSymbols("EUR/KPW", src = "oanda", auto.assign = FALSE)
hc <- highchart(type = "stock") %>%
hc_title(text = "Charting some Symbols") %>%
hc_subtitle(text = "Data extracted using quantmod package") %>%
hc_add_series(usdjpy, id = "usdjpy") %>%
hc_add_series(eurkpw, id = "eurkpw", visible = FALSE) %>%
hc_legend(enabled = TRUE)
这篇关于R-Highcharter-展出的精选图例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!