0

I am using Vaadin framework with Spring boot and I need to display a PIE Chart with its contents. The thing is everything is working fine and when I click the legends labels the animation works fine.

Pre-click: enter image description here

When I click the labels: enter image description here

Note that when I clicked the labels the pie changed, which is what I want.

But when I click all the labels: enter image description here

The pie chart turns into this blue I don't even know what this is.

I was wondering if anyone knows how would I access the labels in the legends to check if they are selected via Java and if none of them is selected I wouldn't let the user deselect the last one.

Thank you for your help

Find the chart code here:

 private Component getCompaniesChart() {
        Chart chart = new Chart(ChartType.PIE);
        Configuration conf = chart.getConfiguration();
        DataSeries dataSeries = new DataSeries();
        service.findAllDepartments()
                .forEach(Department -> dataSeries.add(new DataSeriesItem(Department.getName(), Department.getEmployeeCount())));

        Options3d options3d = new Options3d();
        options3d.setEnabled(true);
        options3d.setAlpha(70);
        options3d.setBeta(0);
        conf.getChart().setOptions3d(options3d);

        PlotOptionsPie plotOptions = new PlotOptionsPie();
        plotOptions.setDepth(100);
        plotOptions.setAllowPointSelect(true);
        plotOptions.setShowInLegend(true);
        plotOptions.setShadow(true);
        plotOptions.setSize("200%");

        conf.getLegend().setLabelFormat("{name} ({y})");
        conf.getLegend().setItemMarginTop(100);


        conf.setPlotOptions(plotOptions);
        conf.setSeries(dataSeries);
        conf.getChart().setStyledMode(true);

        return chart;
    }
Enis
  • 109
  • 9
  • I do not know if it is a bug or feature, but Highcharts itself seem to work that way, see e.g. demo here: http://jsfiddle.net/FKKz9/129/ – Tatu Lund Jan 23 '23 at 07:59
  • Hi @TatuLund, thanks for the comment first. Yes, that is true but in my case, the circle just turns blue instead of only a white outline which is the case in the Highcharts itself. And also, my circle seems to be cropped at the top if you can notice, not sure why. I've been trying to modify the CSS but nothing worked. – Enis Jan 26 '23 at 08:13
  • Btw @TatuLund is there any way I can remove the whole circle if none of the legends options is selected? I tried a lot of stuff but none of them worked for me. Thank you in advance! – Enis Jan 26 '23 at 08:14

0 Answers0