You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to update the pie chart from the data from a local database whenever I press the button, but whenever I press it the chart is flickering with old and new data. Here's my code.
pie = AnyChart.pie();
AnyChartView anyChartView = binding.anyChartView;
anyChartView.setChart(pie);
binding.getPieChartBtn.setOnClickListener(v -> {
// amountForCategory array is retrieved from database whenever button is clicked
final int delayMillis = 500;
final Handler handler = new Handler();
final Runnable runnable = new Runnable() {
public void run() {
List<DataEntry> data = new ArrayList<>();
if(amountForCategory[0]!=0) data.add(new ValueDataEntry("Food", amountForCategory[0]));
if(amountForCategory[1]!=0) data.add(new ValueDataEntry("Transportation", amountForCategory[1]));
if(amountForCategory[2]!=0) data.add(new ValueDataEntry("Rent", amountForCategory[2]));
if(amountForCategory[3]!=0) data.add(new ValueDataEntry("Medicine", amountForCategory[3]));
if(amountForCategory[4]!=0) data.add(new ValueDataEntry("Other", amountForCategory[4]));
pie.data(data);
handler.postDelayed(this, delayMillis);
}
};
handler.postDelayed(runnable, delayMillis);
});
The text was updated successfully, but these errors were encountered:
I want to update the pie chart from the data from a local database whenever I press the button, but whenever I press it the chart is flickering with old and new data. Here's my code.
The text was updated successfully, but these errors were encountered: