HI, I have chart view with area and column series:
ComboChart.Frame = new RectangleF (10f, 40f, UIScreen.MainScreen.Bounds.Width, 200f); ComboChart.BackgroundColor = UIColor.Clear; ComboChart.AnimateSeriesWhenAxisRangeChanges = true; ComboChart.ZoomDisplayType = IGChartZoom.IGChartZoomNone; _areaSource = new IGAsyncCategoryDataSourceHelper ("Value", "Label"); _areaData = GenerateData (ViewModel.AreaData); _areaSource.Delegate = new AsyncDataSource (_areaData); _columnSource = new IGAsyncCategoryDataSourceHelper ("Value", "Label"); _columnData = GenerateData (ViewModel.ColumnData); _columnSource.Delegate = new AsyncDataSource (_columnData); _xAxis = new IGCategoryXAxis ("xAxis") { LabelBrush = new IGBrush (_grayColor), MajorStroke = new IGBrush (_grayColor), Stroke = new IGBrush (_grayColor), Gap = 5, Extent = 20, UseSmartAxisPanel = true }; _yAxis = new IGNumericYAxis ("yAxis") { LabelBrush = new IGBrush (_grayColor), MajorStroke = new IGBrush (_grayColor), Stroke = new IGBrush (_grayColor), Minimum = 0, Maximum = 100, Extent = 30 }; float red; float green; float blue; float alpha; UIColor.Orange.GetRGBA (out red, out green, out blue, out alpha); var orangeBrush = new IGGradientBrush (UIColor.Clear); orangeBrush.AddColorStop (0.5, new IGBrush (red, green, blue, 0.75f)); _areaSeries = new IGAreaSeries ("areaSeries") { MarkerType = IGMarkerType.IGMarkerTypeNone, XAxis = _xAxis, YAxis = _yAxis, Thickness = 2, Outline = new IGBrush (UIColor.Red), Brush = orangeBrush, IsTransitionInEnabled = true, TransitionDuration = 500, DataSource = _areaSource }; _columnSeries = new IGColumnSeries ("columnSeries") { MarkerType = IGMarkerType.IGMarkerTypeNone, Thickness = 0, Brush = new IGBrush (_grayColor), XAxis = _xAxis, YAxis = _yAxis, IsTransitionInEnabled = true, TransitionDuration = 500, DataSource = _columnSource }; ComboChart.AddAxis (_xAxis); ComboChart.AddAxis (_yAxis); ComboChart.AddSeries (_areaSeries); ComboChart.AddSeries (_columnSeries); _scrollView.AddSubview (ComboChart);
And when I update data in sources in first way:
_areaData.RemoveAt (0); _columnData.RemoveAt (0); ComboChart.RemoveItem (0, _areaSource); ComboChart.RemoveItem (0, _columnSource); _areaSource.Values = _areaData.ToArray (); _columnSource.Values = _columnData.ToArray ();
axis are updated, but series aren't.
When I update data in second way:
ViewModel.UpdateShowingData (min, max); _areaData = GenerateData (ViewModel.AreaData); _areaSource.Delegate = new AsyncDataSource (_areaData); _areaSeries.DataSource = _areaSource; _columnData = GenerateData (ViewModel.ColumnData); _columnSource.Delegate = new AsyncDataSource (_columnData); _columnSeries.DataSource = _columnSource;
series are hidden in chart, and for updating chart I need make zoom manually.
Refresh method doesn't work.
How I can update chart view. Thank you.
Hi Ivan,
Sorry for a delayed response. Typically, you would use the async datasource for very large data sets, where preloading all the data points initially isn't possible. I'd say it's best to use the async datasource for sets with over one million points. As such, it doesn't support the same update methods as traditional data sources. Using Update/Remove/Insert methods on the chart won't update the series, because in async datasource scenario the entire series shape needs to be recalculated. To update the series you would only need to reassign the series.Datasource to your async datasource instance without having to reassign the delegate.