I have a large dataset(around 50000 points) which has be visualized in a line chart.开发者_如何学运维The size of Canvas may vary according to the size of dataset. Massive amount of points makes the drawing too slow.It also results in cluttering and overlapping of points due to plotting of several points close to each other.So visual representation of data will be unsatisfactory. How can I display subset of available points which will increase the performance? Can anybody suggest me with a suitable algorithm which will help to extract the subset of actual number of points?
everything i can think of would be a compromise...:
to keep it simple let's say you have a List with 50k entries to vizualize, but you only want to draw 1k pts for performance reasons...
some different approaches would be...:
take every n'th pt so you get 1k vals:
List<double> src = ... //50k entries
List<double> viz = new List<double>();
for(int i=0;i<1000;i++)
viz.Add(src[(int)(i * (src.Length / 1000d))];
another approach would get the avg. to the pts...:
List<double> src = ... //50k entries
List<double> viz = new List<double>();
for(int i=0;i<1000;i++) {
int from = (int)(i * (src.Length / 1000d));
int to = (int)((i+1) * (src.Length / 1000d));
double avg = 0;
for(int j=from;j<to;j++)
avg += src[j];
viz.Add(avg/(to-from));
}
code untested - just some thoughts...
精彩评论