Hi, using the Android Infragistics toolkit, DataChartView. I have a RangeAreaSeries and a LineSeries that are displaying okay, except that as I add elements to the backing model I'm getting a strange horizontal mirroring of the chart. See this pic -- left side is the actual data and the right side is a mirror of the data reversed (minus the timestampy labels).
https://dl.dropboxusercontent.com/u/56947838/temp.png
I don't have much documentation to go on, but what I'm doing is as I add data to the model, I notify each series of the updated element using this call:
mSeries.notifyInsertItem(i, mValues.get(i));
where 'i' is the last index of the added data. For example, if I started with two elements of data and added a 3rd, the effective call would be:
mSeries.notifyInsertItem(2, mValues.get(2));
and mValues.get(2) returns my last row.
Am I notifying the chart/series correctly about the updated data? I'm adding data relatively quickly so I don't want to recalculate the entire chart. If I invalidate everything then the chart displays properly, albeit slowly as the data set increases.
Thanks.
Thanks, that does fix the issue.
Hi Ben,
I spoke with the chart developer about this and it seems that while notifyInsertItem is the correct method, we are not calling it on the correct object. We shouldn't be calling notifyInsertItem on the series itself, it should be called on the DataChartView object instead. In your code, remove the series notifyInsertItem and replace it with:
mChartView.notifyInsertItem(mData, newIndex, mData.get(newIndex));
The idea behind this is that you only need to notify the chart when a new item is updated. From there the chart will figure out what series are actually using this data source and update them accordingly.
Thanks for the sample. With it I was able to reproduce the issue you described. The key to reproducing this is to notifyInsertItem on both series at the same time. I wasn't doing this before. It seems that if you call notifyInsertItem on both of series then it mirrors the data. If, however, I only notify one of the series, it updates both series properly. It's pretty weird. I logged a development issue for this with a development ID of 190724. I also created a private support case for you. The case # is CAS-152690-P4T2H2.
For now you can comment out one of notifyInsertItem so only one series is doing it. This will give you the desired behavior.
Okay, I have this one reproduced separate from our app. The app just keeps adding two new data points every 500ms, one of them rising the other falling. What we should end up with is a a large triangle with the added values on the right side, but what we see is a diamond shape where the added values are in the middle of the chart, the mirroring on the right side some sort of artifact.
Here's a .webm video that shows the app as its running:
https://dl.dropboxusercontent.com/u/56947838/InfraMirror.webm
And here's the full Android Studio project file:
https://dl.dropboxusercontent.com/u/56947838/InfraMirror.zip
I tried it on both my Nexus 5 and a Genymotion emulator of a Nexus 7 2013.
If I take this same model and rebuild the chart from scratch instead of using the notify() methods, it works fine.
Yep, those notify methods should be working to update the chart when new data is added. I'll wait for a reproducing sample since I'm not able to reproduce it on my end.