Hi,
I am having a chart in my UI. I am adding a series to the chart and then assign the DataSource to the series. Chart takes lots of time to render the chart.
int[] zi = new int[356]; Infragistics.Silverlight.Chart.Series s3 = new Infragistics.Silverlight.Chart.Series(); s3.ChartType = ChartType.Line; for (int j = 0; j < 356; j++) { zi[j] = j; } igChart3.Series.Add(s3); igChart3.Series[0].DataSource = zi;
Alternatively, if I assign data to the series and then add the series to chart, it works perfectly(much quicker).
int[] zi = new int[356]; Infragistics.Silverlight.Chart.Series s3 = new Infragistics.Silverlight.Chart.Series(); s3.ChartType = ChartType.Line; for (int j = 0; j < 356; j++) { zi[j] = j; } s3.DataSource = zi; igChart1.Series.Add(s3);
Why is this performance difference?
Due to this limitation we are not able to do data binding to the series from XAML code.
Regards,
Madhan
I was able to reproduce the issue and fix the problem. There was an issue with full chart refreshes (such as when you set RefreshEnabled = false and then true or call Refresh() ) where some event listeners were being leaked.
In the interim, its best to avoid causing full chart refreshes with too great a frequency (Calling Refresh() or toggling RefreshEnabled, etc.)
The resolution to this issue should be available with the next service release.
Graham,
Sorry for the late reply. You can reproduce the memory issue using sample code which was provided by your team in this posting.
Thanks for providing more info. I'll see if I can replicate the issue.
I have the same problem of memory leak. to reproduce it, it's easy:
Create a simple chart in xaml:
<Grid x:Name="LayoutRoot" Background="White"> <Border Height="Auto" Width="Auto" VerticalAlignment="Top" BorderThickness="1,1,1,1" BorderBrush="White" Margin="0,10,0,0"> <StackPanel Height="Auto" Width="250" Margin="0,0,0,0"> <Canvas x:Name="ChartCanvas0" Width="334" Height="368" HorizontalAlignment="Center">
<Chart:XamWebChart x:Name="ChartControl0" Height="364" Width="366" BorderThickness="0" Canvas.Left="-24" Canvas.Top="5"> <Chart:XamWebChart.Legend> <Chart:Legend Visibility="Collapsed"/> </Chart:XamWebChart.Legend> </Chart:XamWebChart> </Canvas> </StackPanel> </Border> </Grid>
In the "code - behing", create a timer who update the seriescollection each 5s:
private void RefreshData(){ IsRefreshable = false; Curves = GetData(); IsRefreshable = true;}
//it's just an example
private SeriesCollection GetData() { SeriesCollection sColl = new SeriesCollection();
for (int i = 0; i < 7; i++) { Series s = new Series(); s.ChartType = ChartType.ScatterLine; ObservableCollection<DataPoint> lData = new ObservableCollection<DataPoint>(); for (int j = 0; j < 200; j++) { DataPoint d = new DataPoint(); d.ChartParameters.Add(new ChartParameter { Type = ChartParameterType.ValueY, Value = i
}); d.ChartParameters.Add(new ChartParameter { Type = ChartParameterType.ValueX, Value = j
}); lData.Add(d); } s.DataPoints = lData; sColl.Add(s); } return sColl; }
If you check your perfmon or taskmgr, you can see that the memory of the process iexplorer increase for each time you are updating the series of the chart. After some times, an "Outofmemory exception" is throwed by the application.
if you changing the code by just only updated the datapoint or chartparameter, it's the same result.
or, if you binding the seriescollection(MVVM), same result.
The garbageCollector never cleans the old objects.
Have you got an answer for this problem?
Thank you for your quick answer.
Some additional performance hints for the chart:
-Graham