1

I use this Library :https://github.com/jjoe64/GraphView-Demos for Draw chart in my application.this library is work but when i want draw new chart or redraw not Work

I see this Link but not work: GraphView and resetData

my code for Draw chart in Activity:

GraphViewData[] newData = new GraphViewData[arrayWeight.size()];
    int i = 0;
    String date_now = "";

    for (Weight w : arrayWeight) {
        i += 1;
        date_now = w.getdate();
        date_now = date_now.substring(8);

        newData[arrayWeight.indexOf(w)] = new GraphViewData(
                Integer.parseInt(date_now), w.getWeight());

    }

    GraphViewSeries exampleSeries = new GraphViewSeries(newData);
    exampleSeries.resetData(newData);
    GraphView graphView = new LineGraphView(this, "weight");
    graphView.redrawAll();
    graphView.setVerticalLabels(new String[] { "100", "50", "1" });
    graphView.setShowLegend(true);
    graphView.setBackgroundColor(Color.GRAY);

    graphView.addSeries(exampleSeries); // data
    LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
    layout.addView(graphView);
Community
  • 1
  • 1
sr.farzad
  • 665
  • 3
  • 8
  • 23

1 Answers1

2

if you want to fill the graph with new data you do not have to create a new graphview object and you do not have to create a new graphviewseries object. Just change the data in your graphviewseries object with resetData. Take a closer look into the GraphView-Demos project, there is a working example.

appsthatmatter
  • 6,347
  • 3
  • 36
  • 40