DownSampling vs Series.Active flag
Posted: Tue Oct 21, 2008 9:15 am
i'm trying to use DownSampling with Ponits Series contains over 86k points.
i draw points on chart - it take a lot of time, just freeze app.
To reduce generation time i try to use DownSamplingMethod.Avarage in this
way:
Line.Function = DownSampling;
the problem is when i set
points.active = false;
nothing is drawn on chart! (screen 2)
if Active is True chart drawing time is biiiig (for over 86k points) but
Line with DownSampling works very good, as i expected! (screen 1)
i need to set something?
i write my code based on Yours sample:
"NetTutorialsContentsTutorial7-WorkingwithFunctions custom"
Im using TeeChart.WPF from
TeeChart.NET version 3
Release Notes 23rd September 2008
TeeChart.NET version 3
Build 3.5.3188.18562
installation
Screen 1
Screen 2
Code: Select all
private void GenerateSeries()
{
Line oryginalPoints = new Line();
FastLine reduceLine = new FastLine();
double[] speedData = new double[60 * 60 * 24]; // sec per day
DateTime[] times = new DateTime[60 * 60 * 24];
/*
* preparing sample data
* car speed in each second (24h period)
* gives over 86 000 points
* this amount slows TeeChart extemlly
*/
DateTime x = DateTime.Now.Date;
Random rand = new Random((int)DateTime.Now.Second);
double prev = 0;
for (int i = 0; i < 60 * 60 * 24; i++)
{
times[i] = x + TimeSpan.FromSeconds(i);
speedData[i] = prev + rand.Next(-10, 10);
if (speedData[i] < 0) speedData[i] *= -1;
if (speedData[i] > 120)
{
double tmp = 120 - (speedData[i] - 120);
speedData[i] = tmp;
}
prev = speedData[i];
}
oryginalPoints.Color = Colors.Red;
oryginalPoints.Title = "oryginal";
reduceLine.Color = Colors.Green;
reduceLine.Title = "reduce";
tChart.Series.Add(oryginalPoints);
tChart.Series.Add(reduceLine);
DownSampling sampling = new DownSampling(tChart.Chart);
/*
*
* change to True to see something on chart
* False generates empty chart
*
*/
oryginalPoints.Active = true;
oryginalPoints.Add(times, speedData);
oryginalPoints.XValues.DateTime = true;
sampling.Method = DownSamplingMethod.Average;
sampling.DisplayedPointCount = 1000;
sampling.PeriodStyle = PeriodStyles.Range;
sampling.Period = 5;
reduceLine.DataSource = oryginalPoints;
reduceLine.XValues.DateTime = true;
reduceLine.Function = sampling;
reduceLine.CheckDataSource();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
GenerateSeries();
}
To reduce generation time i try to use DownSamplingMethod.Avarage in this
way:
Line.Function = DownSampling;
the problem is when i set
points.active = false;
nothing is drawn on chart! (screen 2)
if Active is True chart drawing time is biiiig (for over 86k points) but
Line with DownSampling works very good, as i expected! (screen 1)
i need to set something?
i write my code based on Yours sample:
"NetTutorialsContentsTutorial7-WorkingwithFunctions custom"
Im using TeeChart.WPF from
TeeChart.NET version 3
Release Notes 23rd September 2008
TeeChart.NET version 3
Build 3.5.3188.18562
installation
Screen 1
Screen 2