AAChartKit-Swift icon indicating copy to clipboard operation
AAChartKit-Swift copied to clipboard

Refreshing Data / Updating Line Chart Dynamically

Open johnallen24 opened this issue 7 years ago • 4 comments

I want to be able add a new data point every second to an existing AAChartView of type line chart. I am not sure how to do this. I know there is the aa_onlyRefreshTheChartDataWithChartModelSeries() function. The function takes the parameter chartModelSeries:Array<Any> but I am not sure exactly what a chartModelSeries is? Currently I am putting an updated array with the new data value appended at the end for this parameter. However, I get

☠️☠️💀☠️☠️WARNING!!!!! THERE ARE SOME ERROR INFOMATION_______Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo={WKJavaScriptExceptionLineNumber=102, WKJavaScriptExceptionMessage=TypeError: undefined is not an object (evaluating 'chartSeries.setData'), WKJavaScriptExceptionColumnNumber=28, WKJavaScriptExceptionSourceURL=file:///Users/......AAChartView.html, NSLocalizedDescription=A JavaScript exception occurred}

Any help would be greatly appreciated.

johnallen24 avatar May 04 '18 19:05 johnallen24

Never mind I figured it out. For the parameter, I had to create a new AAChartElement with the data property set to the updated array and then insert that AAChartElement into an empty array.

However, I can not seem to get the chart to scroll by itself. I have set scrollEnabled to true but it does not scroll. Also, is there a way to animate the new values being added. The line connecting to the new data point just seems to suddenly appear, instead of drawing smoothly.

Thanks

johnallen24 avatar May 04 '18 20:05 johnallen24

Maybe you need this https://www.highcharts.com/ios/demo/dynamic-update

AAChartModel avatar May 05 '18 13:05 AAChartModel

Is that possible to create with AAChartKit?

johnallen24 avatar May 05 '18 16:05 johnallen24

NO,It is come from Highcharts offical wrapper Highcharts-iOS,you can get it from here https://github.com/highcharts/highcharts-ios

AAChartModel avatar May 05 '18 16:05 AAChartModel