Can I dynamatically load data and perform some advanced data setting?
My problem is something likes https://github.com/PhilJay/MPAndroidChart/issues/789
When scaleX in LineChart, I want to load more detailed data , can I listen to the scaleX event and use https://github.com/PhilJay/MPAndroidChart/wiki/Dynamic-&-Realtime-Data to load more data?
And my data is something like
| x | y |
|---|---|
| 2016-01-01 15:00:00 GMT | 25 |
| 2016-01-01 22:00:00 GMT | 58 |
| 2016-01-02 08:00:00 GMT | 36 |
| 2016-01-02 14:00:00 GMT | 12 |
| 2016-01-02 19:00:00 GMT | 29 |
It seems that it don't intervals with the date correctly, intervals are all the same. Can I use https://github.com/PhilJay/MPAndroidChart/wiki/Setting-Data to adjust data to have interval the same as numbers ?
copy from https://github.com/mskec/react-native-mp-android-chart-example/issues/2
Hi @linonetwo,
Unfortunately adding and removing data with these methods is not implemented at this moment. Subscribing to available gesture events is also not implemented.
I can't promise you that I will have time to implement that soon. Feel free to implement it and I will be happy to merge PR.
Regarding data intervals, if I understand correctly you are referring to something like BarChart example where there is gap.
If your data is in hourly intervals, maybe you can add null values between 2 values.
e.g.
| x | y |
|---|---|
| 2016-01-01 15:00:00 GMT | 25 |
| 2016-01-01 16:00:00 GMT | null |
| 2016-01-01 17:00:00 GMT | null |
| ... | |
| 2016-01-01 21:00:00 GMT | null |
| 2016-01-01 22:00:00 GMT | 58 |
Hi @mskec, I'm glad to make a PR for Subscribing to available gesture events and dynamically adding and removing data since my company needs this feature recently.
But for data intervals, I have tried your solution, but too many data will cause horrible lagging. And I need to check if there is a data in a smaller interval: | 2016-01-01 15:00:00 GMT | 25 | | 2016-01-01 16:00:00 GMT | 33 | | 2016-01-01 17:00:00 GMT | 66 | ... | 2016-01-01 20:59:00 GMT | 99 | <- my god smaller interval ! | 2016-01-01 21:00:00 GMT | 99 | | 2016-01-01 22:00:00 GMT | 58 |
Then I have to insert 59 nulls into every hour. So preparing data is an O(n^3) function, which will take 2-3 min for API, lagging.....
Do you have Idea for this problem? Or mpandroid chart have no way to deal with this?
Thats what I thought. It might work for hours, but not for minutes or anything smaller.
I do not know whether https://github.com/PhilJay/MPAndroidChart has a way of dealing with that. You can research a bit and if they can do that maybe we can implement it here also.
I create a fork https://github.com/wuxudong/react-native-mp-android-chart and update mpAndroidChart to V3, now it support xValues as number. you can check demo at https://github.com/wuxudong/react-native-mp-android-chart/blob/master/examples/react-native-mp-android-chart-example/app/TimeSeriesLineChartScreen.js