1

I am using TimeChartView of AChartEngine 0.7.0 to draw chart.

on x-axis there is date and for y-axis there is value for specific date. i am parsing these values from xml so someday I get value of complete last 5 day but someday only of 3 days so when i get value of 3 days, chart shows x-values shifted compared to y-values. also sometimes there is repetition of date due to fix number of x-labels which i have solved.

I think i have similar problem to this SO Quest and mostly to this as I want to set X-intervals by using dates.

MyChart

Here Originally from XML,I am having values of date 28.09,27.09,26.09 but it displays as above.

Community
  • 1
  • 1
Hanry
  • 5,481
  • 2
  • 40
  • 53

1 Answers1

0

When the number of (x,y) values are changed suppose from 5 to 3 or vice versa you should first remove the values that repaint the chart

public XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
dataset.getSeriesAt(0).clear(); // use this to clear your data set
dataset.getSeriesAt(0).add(x, y) // use this to add the new x,y values
Farhana Haque
  • 1,371
  • 14
  • 23
  • but i am defining series first and then assigning : for (int k = 0; k < seriesLength; k++) { series.add(xV[k].getTime(), yV[k]); } dataset.addSeries(series); – Hanry Sep 30 '11 at 06:42
  • Here you add a new series every time when there is a change in data. But the old series are remain into the dataset. If you make update in series then you should either follow the approach which I provide to you or at first remove the series for dataset then add new series as you do – Farhana Haque Sep 30 '11 at 06:48
  • Give me the answer of one question. Suppose you have run your app for the first time and draw chart for 3 values. Is that time chart show correct graph. If the answer is yes then you follow my approach and it will be perfect. – Farhana Haque Sep 30 '11 at 09:04