Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Series in Drilldown #470

Closed
gulhamster opened this issue Sep 12, 2018 · 2 comments
Closed

Multiple Series in Drilldown #470

gulhamster opened this issue Sep 12, 2018 · 2 comments

Comments

@gulhamster
Copy link

Hi,

I am trying to create a drilldown from a single to multiple series but cannot find a way of doing so.

The code below only creates a single series, even though i link on the same id.

I've tried incorporating a java script function (see below) without any luck.

Thanks

    df <- data_frame(
      name = c("Animals", "Fruits", "Cars"),
      y = c(5, 2, 4),
      drilldown = tolower(name)
    )

    df

    hc <- highchart() %>%
      hc_chart(type = "column") %>%
      hc_title(text = "Basic drilldown") %>%
      hc_xAxis(type = "category") %>%
      hc_legend(enabled = FALSE) %>%
      hc_plotOptions(
        series = list(
          boderWidth = 0,
          dataLabels = list(enabled = TRUE)
        )
      ) %>%
      hc_add_series(
        data = df,
        name = "Things",
        colorByPoint = TRUE
      )


    dfan <- data_frame(
      name = c("Cats", "Dogs", "Cows", "Sheep", "Pigs"),
      value = c(4, 3, 1, 2, 1)
    )

    dfcar <- data_frame(
      name = c("Toyota", "Opel", "Volkswagen"),
      value = c(4, 2, 2)
    )

dfcar2 <- data_frame(
      name = c("Toyota", "Opel", "Volkswagen"),
      value = c(6, 7, 2)
)
    )

    hc <- hc %>%
      hc_drilldown(
        allowPointDrilldown = TRUE,
        series = list(
          list(
            id = "animals",
            data = list_parse2(dfan)
          ),
          list(
            id = "cars",
type = "line",
            data = list_parse2(dfcar )
          ),
          list(
            id = "cars",
            type = "line",
            data = list_parse2(dfcar2)
          )
        )
      )

    hc

Java script function:

fn = 'function(e) {
console.log(e.seriesOptions);
if(data.series){
for(var i = 0; i < data.series.length; i ++ ){
this.addSeries({
name: data.series[i].name,
data: data.series[i].data,
type: data.series[i].type,
});
}
} else {
this.addSeries({
name: name,
data: data,
type: type,
});
}
}
}

Incorporated here in the code:

    hc <- highchart() %>%
      hc_chart(type = "column",
       events = list(
         drilldown = JS(fn)) 
@stale
Copy link

stale bot commented Aug 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Feel free to reopen it if you find it necessary.

@stale stale bot added the wontfix label Aug 21, 2020
@stale
Copy link

stale bot commented Aug 21, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Feel free to reopen it if you find it necessary.

@stale stale bot closed this as completed Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant