We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Poor scrolling performance for high datapoint count.

Hello, after customizing sfChart to increase performance as much as possible, there is an issue remaining. When zooming in very close on a chart with many datapoints, the scrolling is sluggish. This should not be the case, because only the area within the visible range needs to be redrawn. However, it seems that behind the scenes, sfChart still converts every datapoint into pixels for the entire range, which unnecessarily decreases performance.

The culprit is this line:

GetType(FastStepLineBitmapSegment).GetMethod("CalculatePoints", BindingFlags.InvokeMethod Or BindingFlags.Instance Or BindingFlags.NonPublic).Invoke(Me, New Object() {chartTransformer})

Attached is a sample. Run the sample while ensuring the the Immediate window is open in Visual Studio. When the chart becomes visible, the output measurement shows that the method in question takes about 1700 ms. Next, click the Zoom 1 day button. Now the measure measurement is about 1450 ms. Next, scroll the chart by dragging the chart with the mouse button. The scrolling is very sluggish. The measurements are around 1450 ms per update.

Is there a way to speed this up, by for example having the method only perform pixel conversions for the visible range rather than the entire range?
Thank you.

Attachment: sfChartLargeDataPerformance_515194f7.rar

3 Replies

MK Muneesh Kumar G Syncfusion Team September 5, 2019 02:23 AM

Hi Tom, 
Greetings from Syncfusion.  
We have analysed your query and we would like to inform you that in CalculatePoints method every data point getting added with calculation to pixel rendering collection. So that it takes so much time in small level data count also.  
We can able to reduce this cycle with visible range. It improves the zoomed state panning performance in your sample. But in load it takes more time compared with old time.  
Instead of calling CalculatePoints method in reflection, we have tried to implement the calculation in sample level itself.  
Public Overrides Sub Update(transformer As IChartTransformer) 
            Debug.WriteLine("CalculatePoints method completed in {0} milliseconds.", sw.ElapsedMilliseconds) 
        End If 
    End Sub 
    Private Sub CalculatePoints(ByVal cartesianTransformer As ChartTransform.ChartCartesianTransformer) 
        Dim xAxis As ChartAxis = cartesianTransformer.XAxis 
        Dim cnt As Integer = xChartVals.Count - 1 
        Dim start As Integer = 0, endV As Integer = 0 
        start = Math.Floor(xAxis.VisibleRange.Start) 
        endV = Math.Ceiling(xAxis.VisibleRange.End) 
        If start < 0 Then 
            start = 0 
        End If 
        If endV > yChartVals.Count - 1 Then 
            endV = yChartVals.Count - 1 
        End If 
        For i As Integer = start To [endV] 
            GetType(FastStepLineBitmapSegment).GetMethod("AddDataPoint", BindingFlags.InvokeMethod Or BindingFlags.Instance Or BindingFlags.NonPublic). 
                Invoke(Me, New Object() {cartesianTransformer, i}) 
    End Sub 
Please check and let us know if you have any other queries.  
Muneesh Kumar G 

TO Tom September 5, 2019 09:27 AM

This is brilliant! Actually, being able to add points individually you can also add them in intervals, greatly speeding up when the visible range is the entire range.
Thank you.

MK Muneesh Kumar G Syncfusion Team September 6, 2019 12:10 AM

Hi Tom,  
Thanks for the update. 
We are glad to know that the given solution works. Please let us know if you need any further assistance. 
Muneesh Kumar G. 

Live Chat Icon For mobile
Up arrow icon