AnyChart / AnyChart-Android

AnyChart Android Chart is an amazing data visualization library for easily creating interactive charts in Android apps. It runs on API 19+ (Android 4.4) and features dozens of built-in chart types.
2.29k stars 367 forks source link

The changes are not applied in the app ?? the data is different but the resultant pie chart is the same. Please Help! #99

Open Pranavg387 opened 5 years ago

Pranavg387 commented 5 years ago

`package com.example.piechart;

import android.os.Bundle; import android.support.v7.app.AppCompatActivity;

import com.anychart.AnyChart; import com.anychart.AnyChartView; import com.anychart.chart.common.dataentry.DataEntry; import com.anychart.chart.common.listener.Event; import com.anychart.chart.common.listener.ListenersInterface; import com.anychart.charts.Pie; import com.anychart.enums.Align; import com.anychart.enums.LegendLayout;

import java.util.ArrayList; import java.util.List;

public class MainActivity extends AppCompatActivity {

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);

AnyChartView anyChartView = findViewById(R.id.any_chart_view);

Pie pie = AnyChart.pie();

pie.setOnClickListener(new ListenersInterface.OnClickListener(new String[]{"x", "value"}) {
    @Override
    public void onClick(Event event) {

    }
});

List<DataEntry> data = new ArrayList<>();

data.add(new ValueDataEntry("Apples", 6)); data.add(new ValueDataEntry("Pears", 7)); data.add(new ValueDataEntry("Bananas", 7)); data.add(new ValueDataEntry("Grapes", 1)); data.add(new ValueDataEntry("Oranges", 1));

{pie.data(data);

pie.title("Fruits imported in 2019 (in kg)");

pie.labels().position("outside");

pie.legend().title().enabled(true);
pie.legend().title()
        .text("Retail channels")
        .padding(0d, 0d, 10d, 0d);

pie.legend()
        .position("center-bottom")
        .itemsLayout(LegendLayout.HORIZONTAL)
        .align(Align.CENTER);
System.out.print("here");}

anyChartView.setChart(pie);

} }`

Shestac92 commented 5 years ago

@Pranavg387 Unfortunately, in your snippet, I can't find Pie chart updating code. This issue comment describes how to update the Pie chart with new data without recreating it. This should solve your issue.