Reputation: 137
I have to automatisate the analyse of a dataset on RStudio.
My problem is that I don't know how many series are going to be in the dataset. So I'm wondering is it possible to do a for loop INSIDE the Highcharts ?
I don't know if it doesn't work because I've done something wrong or because it's not possible.
output$hc2 <- renderHighchart ({
Hchc <- highchart(hcaes(x = Spring ,y = Ponctuation)) %>%
hc_title(text = "Cumulation of the result of a Team per spring",
margin = 20, align = "left",
style = list(color = "#FE8000", useHTML = TRUE)) %>%
hc_xAxis(categories = tableA$Spring, title = list(text = "Number of spring",color = "#FE8000")) %>%
hc_yAxis(title = list(text = "Cumulation of the result", color = "#FE8000"))%>%
for (i in length(mylist)){
hc_add_series(name = name[i], data = mylistcumu[[i]]$CumuPonct) }
print(Hchc)})
Upvotes: 2
Views: 383
Reputation: 137
I found !
output$hc2 <- renderHighchart ({
Hchc <- highchart(hcaes(x = Spring ,y = Ponctuation)) %>%
hc_title(text = "Cumulation of the result of a Team per spring",
margin = 20, align = "left",
style = list(color = "#FE8000", useHTML = TRUE)) %>%
hc_xAxis(categories = tableA$Spring, title = list(text = "Number of spring",color = "#FE8000")) %>%
hc_yAxis(title = list(text = "Cumulation of the result", color = "#FE8000"))
for (i in 1:length(mylist)){
Hchc <- Hchc %>%
hc_add_series(name = name[i], data = mylistcumu[[i]]$CumuPonct) }
Hchc})
Upvotes: 3