Handling large datasets in charts quickely
I have a collection of 50000 points List<DataPoint> DataPoints;Each item in this collection contains (X,Y) co ordinates.These points have to be drawn using line and path in my line chart.Canvas size may vary.Drawing the entire collection will increase the load time.Hence I need to filter the points in such a way that I can get a sub collection of lesser number of points and this list will not affect shape of the chart to larger extent and also renders quickly.Suppose there are points like (1,2)(2,4)(3,6) which passes through same line.I can exclude(2,4).This method can be used as a first order filter.Can anyone please suggest or help me out how I can filter it further.Like excluding points which are very close to each other?
Re: Handling large datasets in charts quickely
Not 100% sure what you're after, but you could combine your 2 ideas (filtering out colinear points and points close to each other) and filter out points very nearly colinear (along the same line). e.g.
(1,2)(2,3.99)(3,6)
Re: Handling large datasets in charts quickely
See if this helps:
vb.net Code:
Private Function GetReleventPoints(ByVal allPoints As List(Of Point)) As List(Of Point)
Const MinXDeviation As Integer = 1
Const MinYDeviation As Integer = 1
Dim selectedPoints As New List(Of Point)
Dim lastPt As Point = allPoints.First
selectedPoints.Add(lastPt)
For Each pt In allPoints
If Math.Abs(lastPt.X - pt.X) > MinXDeviation OrElse Math.Abs(lastPt.Y - pt.Y) > MinYDeviation Then
selectedPoints.Add(pt)
lastPt = pt
End If
Next
If lastPt <> allPoints.Last Then selectedPoints.Add(allPoints.Last)
Return selectedPoints
End Function