Menu

Drilldown and using categories

2017-10-20
2018-03-28
  • Phil McLachlan

    Phil McLachlan - 2017-10-20

    Hi, I have developed a column chart using GWT HighCharts, and I set the x-axis categories with a call to chart.getXAxis().setCategories(false, categories), where categories is a string array. This produces the correct categories for my data. Now, I have added the ability to drilldown from one series to another. This also works. The problem is I have to set the categories differently for the drilldown data. What is the best way to do this? I tried setSeriesPlotOptions(new SeriesPlotOptions().setSeriesClickEventHandler to set the categories, if the clicked on point will cause a drilldown. While this works for the drilldown, I don't know how to set the categories back, when drilling up to the original series. Are there events for drilldown and drillup in GWT HighCharts? If not, what is the work-around to set the categories when drill down and up? Thanks for any help.

    Phil

     
  • Phil McLachlan

    Phil McLachlan - 2017-10-20

    Also, what do I do to show multiple series on drilldown?

     
  • Shawn Quinn

    Shawn Quinn - 2018-03-28

    I don't have a use case chart handy that attempts to use the drilldown functionality with categories to try your particular use case, but thought I'd share that you can also just implement the drilldown logic on your own by responding to the "series click events" and then providing a button or some other way to reset back to the original series. E.g. here's a rough example of how to setup a drilldown with categories when the user clicks on any point in a series, and then returning to the original series when the user clicks anywhere on the chart:

    Chart chart;
    Series series;
    XAxis xAxis;
    
    private void createDrillDownChart() {
        chart = new Chart()
            .setClickEventHandler(new ChartClickEventHandler() {
                @Override
                public boolean onClick(ChartClickEvent chartClickEvent) {
                    xAxis.setCategories(false, originalCategories);
                    series.setPoints(originalPoints, false);
                    chart.redraw();
                    return false;
                }
            })
            .setSeriesPlotOptions(new SeriesPlotOptions()
                .setSeriesClickEventHandler(new SeriesClickEventHandler() {
                    @Override
                    public boolean onClick(SeriesClickEvent seriesClickEvent) {
                        final String category = seriesClickEvent.getNearestPointName();
                        xAxis.setCategories(false, getDrilldownCategories(category));
                        series.setPoints(getDrilldownPoints(category), false);
                        chart.redraw();
                        return false;
                    }
                })
            );
    
        xAxis = chart.getXAxis();
        series = chart.createSeries();
        chart.addSeries(series);
    }
    
     

Log in to post a comment.