-1

I am currently trying to update my pie chart with new data whether that be new or deleted. The data i am passing into the chart is all correct but the chart will not refresh and apply any changes that have been made. Any help will be appreciated :) Thank you.

               Pie pie;
               List<DataEntry> dataEntriesPie;
                   for(int i = 0; i < earnings.size(); i++) {
                        if (earnings.get(i) == 1) {
                            values[0] += 1;
                        } else if (earnings.get(i) == 2) {
                            values[1] += 1;
                        } else if (earnings.get(i) == 3) {
                            values[2] += 1;
                        } else if (earnings.get(i) == 4) {
                            values[3] += 1;
                        } else if (earnings.get(i) == 5) {
                            values[4] += 1;
                        }
                    }

                    pie = AnyChart.pie();
                    dataEntriesPie = new ArrayList<>();

                    pie.legend()
                            .position("center-bottom")
                            .itemsLayout(LegendLayout.HORIZONTAL)
                            .align(Align.CENTER)
                            .fontSize(10);

                    dataEntriesPie.add(new ValueDataEntry(months[0], values[0]));
                    dataEntriesPie.add(new ValueDataEntry(months[1], values[1]));
                    dataEntriesPie.add(new ValueDataEntry(months[2], values[2]));
                    dataEntriesPie.add(new ValueDataEntry(months[3], values[3]));
                    dataEntriesPie.add(new ValueDataEntry(months[4], values[4]));

                    pie.data(dataEntriesPie);
                    anyChartView.setChart(pie);
efe
  • 11
  • 3

1 Answers1

0

This snippet describes how to update the existing Pie chart.

AnyChart Support
  • 3,770
  • 1
  • 10
  • 16