0

I'm using android graph view from here it works fine , but when the Y value of data are the same it doesn't show any thing more like the whole View visibility is GONE. I can handle this by appending a fake value to the data point but it doesn't look fine.does anybody have an idea. Thanks a lot! this part of my code

/...
DataPoint[] dataPoints = new DataPoint[length];
// populate my dataPoints
LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(
                            dataPoints);
graph.removeAllSeries();
graph.addSeries(series);
// make other stuff
/...
soha1410
  • 555
  • 5
  • 14

2 Answers2

3

You don't need to append a fake value.

In this case like what you have mentioned (same value for Y) actually it works correctly, the line will be created but it coincides on the X-axis actually as the Y-axis is starting from the Y value you have set, not zero. Changing the line colour by adding following lines to your code, you will be able to see the drawn line.

graph.setBackgroundColor(getResources().getColor(android.R.color.holo_blue_bright));
series.setColor(Color.GREEN);
graph.getViewport().setScalable(true);
graph.getViewport().setScrollable(true);
Jasmine
  • 222
  • 2
  • 12
  • thanks for your answer , i can not check it right now , but it seems reasonable. so i set it to accepted answer. – soha1410 Feb 22 '16 at 13:49
0

I'm using GraphView as well, and seem to be having the same problem. That the graph doesn't have the right data when I come back to the same fragment. I don't know if you are using fragment or not, but if you do then you need to pop that fragment that contains the graph. So when you came back to the fragment, you will create new fragment instead of taking the fragment from the stack. This works for me. Don't know how accurate is this, cause I'm new to Android dev, but it works for me. Hope this helps.

QuartZ
  • 154
  • 3
  • 12