Down Sampling version 3.0
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
Keith,
No, it shouldn't be necessary as the downsampling function does an internal redraw of the chart when CheckDataSource is called.
BTW, the example class I sent zooms and unzooms as expected with the DateTime values going forward.
No, it shouldn't be necessary as the downsampling function does an internal redraw of the chart when CheckDataSource is called.
BTW, the example class I sent zooms and unzooms as expected with the DateTime values going forward.
Thank you!
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/
Christopher
With this sample I cannot get it to Unzoom, any idea what is missing as I have the times changed to ascending
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Steema.TeeChart;
namespace DownSample
{
public partial class Form1 : Form
{
private Steema.TeeChart.Styles.Points points;
private Steema.TeeChart.Styles.Line fastLine;
private Steema.TeeChart.Functions.DownSampling downSampling;
private Steema.TeeChart.Functions.DownSampling downSampling1;
private Nullable<double>[] xValues, yValues;
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void CreateArrays()
{
int length = 20000;
xValues = new Nullable<double>[length];
yValues = new Nullable<double>[length];
Random rnd = new Random();
for (int i = 0; i < length; i++)
{
DateTime dt = DateTime.Now - new TimeSpan(0, 0,( length -i ), 0);
xValues = dt.ToOADate();
if (i % 20 == 0)
{
yValues = null;
}
else
{
yValues = rnd.Next(100);
}
}
}
private void InitializeChart()
{
CreateArrays();
tChart1.Aspect.View3D = false;
tChart1.Zoom.Direction = ZoomDirections.Horizontal;
tChart1.Series.Add(new Steema.TeeChart.Styles.Points());
tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
downSampling = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
downSampling1 = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
points = tChart1[0] as Steema.TeeChart.Styles.Points;
points.Add(xValues, yValues);
points.XValues.DateTime = true;
points.Active = false;
downSampling.DisplayedPointCount = 1000;
downSampling.Method = Steema.TeeChart.Functions.DownSamplingMethod.MinMaxFirstLastNull;
fastLine = tChart1[1] as Steema.TeeChart.Styles.Line;
fastLine.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
fastLine.XValues.DateTime = true;
fastLine.DataSource = points;
fastLine.Function = downSampling;
fastLine.Pointer.Visible = false;
CreateArrays();
downSampling1.DisplayedPointCount = 1000;
downSampling1.Method = Steema.TeeChart.Functions.DownSamplingMethod.MinMaxFirstLastNull;
tChart1.Series.Add(new Steema.TeeChart.Styles.Points());
tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
points = tChart1[2] as Steema.TeeChart.Styles.Points;
points.Add(xValues, yValues);
points.XValues.DateTime = true;
points.Active = false;
fastLine = tChart1[3] as Steema.TeeChart.Styles.Line;
fastLine.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
fastLine.XValues.DateTime = true;
fastLine.DataSource = points;
fastLine.Function = downSampling1;
}
private void tChart1_Zoomed(object sender, EventArgs e)
{
tChart1[1].CheckDataSource(); //series 1 is the function series
tChart1[3].CheckDataSource();
}
private void tChart1_UndoneZoom(object sender, EventArgs e)
{
//tChart1.Axes.Bottom.SetMinMax(0, tChart1[0].Count); //series 0 is the original series, although you could use any value to set the maximum
tChart1[1].CheckDataSource();
tChart1[3].CheckDataSource();
}
private void udPointCount_ValueChanged(object sender, EventArgs e)
{
((Steema.TeeChart.Functions.DownSampling)tChart1[1].Function).DisplayedPointCount = (int)udPointCount.Value;
((Steema.TeeChart.Functions.DownSampling)tChart1[3].Function).DisplayedPointCount = (int)udPointCount.Value;
//downSampling.DisplayedPointCount = (int)udPointCount.Value;
//downSampling1.DisplayedPointCount = (int)udPointCount.Value;
//tChart1.Axes.Bottom.SetMinMax(0, tChart1[0].Count);
tChart1[1].CheckDataSource();
tChart1[3].CheckDataSource();
}
}
}
With this sample I cannot get it to Unzoom, any idea what is missing as I have the times changed to ascending
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Steema.TeeChart;
namespace DownSample
{
public partial class Form1 : Form
{
private Steema.TeeChart.Styles.Points points;
private Steema.TeeChart.Styles.Line fastLine;
private Steema.TeeChart.Functions.DownSampling downSampling;
private Steema.TeeChart.Functions.DownSampling downSampling1;
private Nullable<double>[] xValues, yValues;
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void CreateArrays()
{
int length = 20000;
xValues = new Nullable<double>[length];
yValues = new Nullable<double>[length];
Random rnd = new Random();
for (int i = 0; i < length; i++)
{
DateTime dt = DateTime.Now - new TimeSpan(0, 0,( length -i ), 0);
xValues = dt.ToOADate();
if (i % 20 == 0)
{
yValues = null;
}
else
{
yValues = rnd.Next(100);
}
}
}
private void InitializeChart()
{
CreateArrays();
tChart1.Aspect.View3D = false;
tChart1.Zoom.Direction = ZoomDirections.Horizontal;
tChart1.Series.Add(new Steema.TeeChart.Styles.Points());
tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
downSampling = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
downSampling1 = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
points = tChart1[0] as Steema.TeeChart.Styles.Points;
points.Add(xValues, yValues);
points.XValues.DateTime = true;
points.Active = false;
downSampling.DisplayedPointCount = 1000;
downSampling.Method = Steema.TeeChart.Functions.DownSamplingMethod.MinMaxFirstLastNull;
fastLine = tChart1[1] as Steema.TeeChart.Styles.Line;
fastLine.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
fastLine.XValues.DateTime = true;
fastLine.DataSource = points;
fastLine.Function = downSampling;
fastLine.Pointer.Visible = false;
CreateArrays();
downSampling1.DisplayedPointCount = 1000;
downSampling1.Method = Steema.TeeChart.Functions.DownSamplingMethod.MinMaxFirstLastNull;
tChart1.Series.Add(new Steema.TeeChart.Styles.Points());
tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
points = tChart1[2] as Steema.TeeChart.Styles.Points;
points.Add(xValues, yValues);
points.XValues.DateTime = true;
points.Active = false;
fastLine = tChart1[3] as Steema.TeeChart.Styles.Line;
fastLine.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
fastLine.XValues.DateTime = true;
fastLine.DataSource = points;
fastLine.Function = downSampling1;
}
private void tChart1_Zoomed(object sender, EventArgs e)
{
tChart1[1].CheckDataSource(); //series 1 is the function series
tChart1[3].CheckDataSource();
}
private void tChart1_UndoneZoom(object sender, EventArgs e)
{
//tChart1.Axes.Bottom.SetMinMax(0, tChart1[0].Count); //series 0 is the original series, although you could use any value to set the maximum
tChart1[1].CheckDataSource();
tChart1[3].CheckDataSource();
}
private void udPointCount_ValueChanged(object sender, EventArgs e)
{
((Steema.TeeChart.Functions.DownSampling)tChart1[1].Function).DisplayedPointCount = (int)udPointCount.Value;
((Steema.TeeChart.Functions.DownSampling)tChart1[3].Function).DisplayedPointCount = (int)udPointCount.Value;
//downSampling.DisplayedPointCount = (int)udPointCount.Value;
//downSampling1.DisplayedPointCount = (int)udPointCount.Value;
//tChart1.Axes.Bottom.SetMinMax(0, tChart1[0].Count);
tChart1[1].CheckDataSource();
tChart1[3].CheckDataSource();
}
}
}
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
Hello Keith,
I imagine that the problem is again related to the following line:
Try changing this line to this:
I imagine that the problem is again related to the following line:
Code: Select all
DateTime dt = DateTime.Now - new TimeSpan(0, 0,( length -i ), 0);
Code: Select all
DateTime dt = DateTime.Now + new TimeSpan(0, 0,( length -i ), 0);
Thank you!
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/
Christopher
I made some modifications to the program to try and describe what I am finding when I have a small sample size. I used the line instead of fastline as I wanted to see the line points.
Issues:
1) If I do not display the points series only display the line series and its points when I check the downsample checkbox the line and its points are not displayed as well the count for the series is zero. I am seing this behavior in our project.
2) If I turn the visible of points series on and display the line and its points, I set the sample size to 10 there are points that are not being displayed and hence gaps in the line. There were no null points.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Steema.TeeChart;
namespace DownSample
{
public partial class Form1 : Form
{
private Steema.TeeChart.Styles.Points points;
private Steema.TeeChart.Styles.Line fastLine;
private Steema.TeeChart.Functions.DownSampling downSampling;
private Steema.TeeChart.Functions.DownSampling downSampling1;
private Nullable<double>[] xValues, yValues;
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void CreateArrays()
{
int length = 100;
xValues = new Nullable<double>[length];
yValues = new Nullable<double>[length];
Random rnd = new Random();
for (int i = 0; i < length; i++)
{
DateTime dt = DateTime.Now - new TimeSpan(0, 0,( length -i ), 0);
xValues = dt.ToOADate();
yValues = 100 * Math.Sin(i * 10 * (Math.PI/180)) + 100;
//if (i % 20 == 0)
//{
// yValues = null;
//}
//else
//{
// yValues = rnd.Next(100);
//}
}
}
private void InitializeChart()
{
CreateArrays();
tChart1.Aspect.View3D = false;
tChart1.Zoom.Direction = ZoomDirections.Horizontal;
tChart1.Series.Add(new Steema.TeeChart.Styles.Points());
tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
downSampling = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
downSampling1 = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
points = tChart1[0] as Steema.TeeChart.Styles.Points;
points.Add(xValues, yValues);
points.XValues.DateTime = true;
points.Active = true;
downSampling.DisplayedPointCount = 10;
downSampling.Method = Steema.TeeChart.Functions.DownSamplingMethod.MinMaxFirstLastNull;
fastLine = tChart1[1] as Steema.TeeChart.Styles.Line;
fastLine.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
fastLine.XValues.DateTime = true;
fastLine.LinePen.Width = 2;
fastLine.DataSource = points;
fastLine.Pointer.Visible = true;
numOfPoints.Text = points.Count.ToString();
lineCount.Text = tChart1[1].Count.ToString();
this.tChart1.Axes.Left.Automatic = false;
this.tChart1.Axes.Left.Maximum = 300;
this.tChart1.Axes.Left.Minimum = -50;
//CreateArrays();
//downSampling1.DisplayedPointCount = 10;
//downSampling1.Method = Steema.TeeChart.Functions.DownSamplingMethod.MinMaxFirstLastNull;
//tChart1.Series.Add(new Steema.TeeChart.Styles.Points());
//tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
//points = tChart1[2] as Steema.TeeChart.Styles.Points;
//points.Add(xValues, yValues);
//points.XValues.DateTime = true;
//points.Active = true;
//fastLine = tChart1[3] as Steema.TeeChart.Styles.Line;
//fastLine.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
//fastLine.XValues.DateTime = true;
//fastLine.DataSource = points;
//fastLine.Function = downSampling1;
}
private void tChart1_Zoomed(object sender, EventArgs e)
{
tChart1[1].CheckDataSource(); //series 1 is the function series
//tChart1[3].CheckDataSource();
}
private void tChart1_UndoneZoom(object sender, EventArgs e)
{
//tChart1.Axes.Bottom.SetMinMax(0, tChart1[0].Count); //series 0 is the original series, although you could use any value to set the maximum
tChart1.Axes.Bottom.SetMinMax(tChart1[0].XValues.Minimum, tChart1[0].XValues.Maximum); //series 0 is the original series, although you could use any value to set the maximum
tChart1[1].CheckDataSource();
//tChart1[3].CheckDataSource();
}
private void udPointCount_ValueChanged(object sender, EventArgs e)
{
if((Steema.TeeChart.Functions.DownSampling)tChart1[1].Function != null)
{
((Steema.TeeChart.Functions.DownSampling)tChart1[1].Function).DisplayedPointCount = (int)udPointCount.Value;
//((Steema.TeeChart.Functions.DownSampling)tChart1[3].Function).DisplayedPointCount = (int)udPointCount.Value;
//downSampling.DisplayedPointCount = (int)udPointCount.Value;
//downSampling1.DisplayedPointCount = (int)udPointCount.Value;
//tChart1.Axes.Bottom.SetMinMax(0, tChart1[0].Count);
tChart1[1].CheckDataSource();
//tChart1[3].CheckDataSource();
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
tChart1[1].Function = downSampling;
downSampling.DisplayedPointCount = (int)udPointCount.Value;
tChart1[1].CheckDataSource();
}
else
{
tChart1[1].Function = null;
tChart1[1].CheckDataSource();
}
lineCount.Text = tChart1[1].Count.ToString();
}
}
}
I made some modifications to the program to try and describe what I am finding when I have a small sample size. I used the line instead of fastline as I wanted to see the line points.
Issues:
1) If I do not display the points series only display the line series and its points when I check the downsample checkbox the line and its points are not displayed as well the count for the series is zero. I am seing this behavior in our project.
2) If I turn the visible of points series on and display the line and its points, I set the sample size to 10 there are points that are not being displayed and hence gaps in the line. There were no null points.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Steema.TeeChart;
namespace DownSample
{
public partial class Form1 : Form
{
private Steema.TeeChart.Styles.Points points;
private Steema.TeeChart.Styles.Line fastLine;
private Steema.TeeChart.Functions.DownSampling downSampling;
private Steema.TeeChart.Functions.DownSampling downSampling1;
private Nullable<double>[] xValues, yValues;
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void CreateArrays()
{
int length = 100;
xValues = new Nullable<double>[length];
yValues = new Nullable<double>[length];
Random rnd = new Random();
for (int i = 0; i < length; i++)
{
DateTime dt = DateTime.Now - new TimeSpan(0, 0,( length -i ), 0);
xValues = dt.ToOADate();
yValues = 100 * Math.Sin(i * 10 * (Math.PI/180)) + 100;
//if (i % 20 == 0)
//{
// yValues = null;
//}
//else
//{
// yValues = rnd.Next(100);
//}
}
}
private void InitializeChart()
{
CreateArrays();
tChart1.Aspect.View3D = false;
tChart1.Zoom.Direction = ZoomDirections.Horizontal;
tChart1.Series.Add(new Steema.TeeChart.Styles.Points());
tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
downSampling = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
downSampling1 = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
points = tChart1[0] as Steema.TeeChart.Styles.Points;
points.Add(xValues, yValues);
points.XValues.DateTime = true;
points.Active = true;
downSampling.DisplayedPointCount = 10;
downSampling.Method = Steema.TeeChart.Functions.DownSamplingMethod.MinMaxFirstLastNull;
fastLine = tChart1[1] as Steema.TeeChart.Styles.Line;
fastLine.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
fastLine.XValues.DateTime = true;
fastLine.LinePen.Width = 2;
fastLine.DataSource = points;
fastLine.Pointer.Visible = true;
numOfPoints.Text = points.Count.ToString();
lineCount.Text = tChart1[1].Count.ToString();
this.tChart1.Axes.Left.Automatic = false;
this.tChart1.Axes.Left.Maximum = 300;
this.tChart1.Axes.Left.Minimum = -50;
//CreateArrays();
//downSampling1.DisplayedPointCount = 10;
//downSampling1.Method = Steema.TeeChart.Functions.DownSamplingMethod.MinMaxFirstLastNull;
//tChart1.Series.Add(new Steema.TeeChart.Styles.Points());
//tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
//points = tChart1[2] as Steema.TeeChart.Styles.Points;
//points.Add(xValues, yValues);
//points.XValues.DateTime = true;
//points.Active = true;
//fastLine = tChart1[3] as Steema.TeeChart.Styles.Line;
//fastLine.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
//fastLine.XValues.DateTime = true;
//fastLine.DataSource = points;
//fastLine.Function = downSampling1;
}
private void tChart1_Zoomed(object sender, EventArgs e)
{
tChart1[1].CheckDataSource(); //series 1 is the function series
//tChart1[3].CheckDataSource();
}
private void tChart1_UndoneZoom(object sender, EventArgs e)
{
//tChart1.Axes.Bottom.SetMinMax(0, tChart1[0].Count); //series 0 is the original series, although you could use any value to set the maximum
tChart1.Axes.Bottom.SetMinMax(tChart1[0].XValues.Minimum, tChart1[0].XValues.Maximum); //series 0 is the original series, although you could use any value to set the maximum
tChart1[1].CheckDataSource();
//tChart1[3].CheckDataSource();
}
private void udPointCount_ValueChanged(object sender, EventArgs e)
{
if((Steema.TeeChart.Functions.DownSampling)tChart1[1].Function != null)
{
((Steema.TeeChart.Functions.DownSampling)tChart1[1].Function).DisplayedPointCount = (int)udPointCount.Value;
//((Steema.TeeChart.Functions.DownSampling)tChart1[3].Function).DisplayedPointCount = (int)udPointCount.Value;
//downSampling.DisplayedPointCount = (int)udPointCount.Value;
//downSampling1.DisplayedPointCount = (int)udPointCount.Value;
//tChart1.Axes.Bottom.SetMinMax(0, tChart1[0].Count);
tChart1[1].CheckDataSource();
//tChart1[3].CheckDataSource();
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
tChart1[1].Function = downSampling;
downSampling.DisplayedPointCount = (int)udPointCount.Value;
tChart1[1].CheckDataSource();
}
else
{
tChart1[1].Function = null;
tChart1[1].CheckDataSource();
}
lineCount.Text = tChart1[1].Count.ToString();
}
}
}
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
Keith,
Back to basics. Running the following code:
Gives me the following chart:
The debug variables look like this:
That is, the chart is plotting the first (0, 40), the min (1, 20), the max (3, 70) and the last (3, 70) in ascending xvalue order. This is, in theory, correct. I believe it is this, feature, which is causing the effects you are seeing. How would you like the algorithm to work in such cases? Exactly, what are the cases in which you'd like to see an alternative behaviour?
Back to basics. Running the following code:
Code: Select all
public partial class Form1 : Form
{
private Steema.TeeChart.Styles.Points points;
private Steema.TeeChart.Styles.Line fastLine;
private Steema.TeeChart.Functions.DownSampling downSampling;
private Nullable<double>[] xValues, yValues;
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void CreateArrays()
{
int length = 4;
xValues = new Nullable<double>[length];
yValues = new Nullable<double>[length];
Random rnd = new Random();
for (int i = 0; i < length; i++)
{
xValues[i] = i;
//yValues[i] = Utils.Round(rnd.NextDouble() * 100);
}
yValues[0] = 40;
yValues[1] = 20;
yValues[2] = 50;
yValues[3] = 70;
}
private void AddValues()
{
CreateArrays();
points.Clear();
fastLine.Clear();
points.Add(xValues, yValues);
fastLine.CheckDataSource();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Zoom.Direction = ZoomDirections.Horizontal;
tChart1.Series.Add(new Steema.TeeChart.Styles.Points());
tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
downSampling = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
points = tChart1[0] as Steema.TeeChart.Styles.Points;
downSampling.DisplayedPointCount = 4;
downSampling.Method = Steema.TeeChart.Functions.DownSamplingMethod.MinMaxFirstLastNull;
fastLine = tChart1[1] as Steema.TeeChart.Styles.Line;
fastLine.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
fastLine.LinePen.Width = 2;
fastLine.DataSource = points;
fastLine.Function = downSampling;
fastLine.Pointer.Visible = true;
fastLine.Active = true;
AddValues();
}
private void tChart1_Zoomed(object sender, EventArgs e)
{
tChart1[1].CheckDataSource(); //series 1 is the function series
}
private void tChart1_UndoneZoom(object sender, EventArgs e)
{
tChart1.Axes.Bottom.SetMinMax(tChart1[0].XValues.Minimum, tChart1[0].XValues.Maximum); //series 0 is the original series, although you could use any value to set the maximum
tChart1[1].CheckDataSource();
}
private void button1_Click(object sender, EventArgs e)
{
AddValues();
}
}
The debug variables look like this:
Code: Select all
*******************************
tmpsum 180
tmpmax 70
tmpmin 20
tmpfirst 40
tmpXfirst 0
tmpXmax 3
tmpXmin 1
tmplast 70
tmpXlast 3
*******************************
Thank you!
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/
Christopher
This is what I would have expected to see. If there were null points then the first null point would be displayed if not then would only display the first,last min and max
Why in the sample I sent when I have points.active = false and I set the number of downsample points to 10 the series count is showing zero. If I set the points.active to true I see the count as 11 but only 9 points displayed.
[/img]
This is what I would have expected to see. If there were null points then the first null point would be displayed if not then would only display the first,last min and max
Why in the sample I sent when I have points.active = false and I set the number of downsample points to 10 the series count is showing zero. If I set the points.active to true I see the count as 11 but only 9 points displayed.
[/img]
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
Keith,
Ok, that's because the original series has values which are not null but which coincide with the Series.DefaultNullValue and so are treated as such. You can try changing this value, thus:
Ok, that's because the original series has values which are not null but which coincide with the Series.DefaultNullValue and so are treated as such. You can try changing this value, thus:
Code: Select all
public partial class Form1 : Form
{
private Steema.TeeChart.Styles.Points points;
private Steema.TeeChart.Styles.Line fastLine;
private Steema.TeeChart.Functions.DownSampling downSampling;
private Steema.TeeChart.Functions.DownSampling downSampling1;
private Nullable<double>[] xValues, yValues;
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void CreateArrays()
{
int length = 100;
xValues = new Nullable<double>[length];
yValues = new Nullable<double>[length];
Random rnd = new Random();
for (int i = 0; i < length; i++)
{
DateTime dt = DateTime.Now - new TimeSpan(0, 0, (length - i), 0);
xValues[i] = dt.ToOADate();
yValues[i] = 100 * Math.Sin(i * 10 * (Math.PI / 180)) + 100;
}
}
private void InitializeChart()
{
CreateArrays();
tChart1.Aspect.View3D = false;
tChart1.Zoom.Direction = ZoomDirections.Horizontal;
tChart1.Series.Add(new Steema.TeeChart.Styles.Points());
tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
downSampling = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
downSampling1 = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
points = tChart1[0] as Steema.TeeChart.Styles.Points;
points.DefaultNullValue = double.NegativeInfinity;
points.Add(xValues, yValues);
points.XValues.DateTime = true;
points.Active = false;
downSampling.DisplayedPointCount = 10;
udPointCount.Value = downSampling.DisplayedPointCount;
downSampling.Method = Steema.TeeChart.Functions.DownSamplingMethod.MinMaxFirstLastNull;
fastLine = tChart1[1] as Steema.TeeChart.Styles.Line;
fastLine.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
fastLine.XValues.DateTime = true;
fastLine.LinePen.Width = 2;
fastLine.DataSource = points;
fastLine.Pointer.Visible = true;
numOfPoints.Text = points.Count.ToString();
lineCount.Text = tChart1[1].Count.ToString();
this.tChart1.Axes.Left.Automatic = false;
this.tChart1.Axes.Left.Maximum = 300;
this.tChart1.Axes.Left.Minimum = -50;
checkBox1_CheckedChanged(checkBox1, EventArgs.Empty);
}
private void tChart1_Zoomed(object sender, EventArgs e)
{
tChart1[1].CheckDataSource(); //series 1 is the function series
}
private void tChart1_UndoneZoom(object sender, EventArgs e)
{
tChart1.Axes.Bottom.SetMinMax(tChart1[0].XValues.Minimum, tChart1[0].XValues.Maximum); //series 0 is the original series, although you could use any value to set the maximum
tChart1[1].CheckDataSource();
}
private void udPointCount_ValueChanged(object sender, EventArgs e)
{
if ((Steema.TeeChart.Functions.DownSampling)tChart1[1].Function != null)
{
((Steema.TeeChart.Functions.DownSampling)tChart1[1].Function).DisplayedPointCount = (int)udPointCount.Value;
tChart1[1].CheckDataSource();
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
downSampling.DisplayedPointCount = (int)udPointCount.Value;
tChart1[1].Function = downSampling;
}
else
{
tChart1[1].Function = null;
}
tChart1[1].CheckDataSource();
lineCount.Text = tChart1[1].Count.ToString();
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
points.Active = !points.Active;
}
}
Thank you!
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
Keith,
Running the following code:
Gives me the following image:
Clicking on checkBox2 (Points.Active) gives me:
That is, I can't seem to reproduce this issue using the above code and the lastest (unpublished) source for TeeChart v3.
Running the following code:
Code: Select all
public partial class Form1 : Form
{
private Steema.TeeChart.Styles.Points points;
private Steema.TeeChart.Styles.Line fastLine;
private Steema.TeeChart.Functions.DownSampling downSampling;
private Steema.TeeChart.Functions.DownSampling downSampling1;
private Nullable<double>[] xValues, yValues;
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void CreateArrays()
{
int length = 100;
xValues = new Nullable<double>[length];
yValues = new Nullable<double>[length];
Random rnd = new Random();
for (int i = 0; i < length; i++)
{
DateTime dt = DateTime.Now - new TimeSpan(0, 0, (length - i), 0);
xValues[i] = dt.ToOADate();
yValues[i] = 100 * Math.Sin(i * 10 * (Math.PI / 180)) + 100;
}
}
private void InitializeChart()
{
CreateArrays();
checkBox1.Checked = true;
tChart1.Aspect.View3D = false;
tChart1.Zoom.Direction = ZoomDirections.Horizontal;
tChart1.Series.Add(new Steema.TeeChart.Styles.Points());
tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
downSampling = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
downSampling1 = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
points = tChart1[0] as Steema.TeeChart.Styles.Points;
points.DefaultNullValue = double.NegativeInfinity;
points.Add(xValues, yValues);
points.XValues.DateTime = true;
points.Active = true;
downSampling.DisplayedPointCount = 10;
udPointCount.Value = downSampling.DisplayedPointCount;
downSampling.Method = Steema.TeeChart.Functions.DownSamplingMethod.MinMaxFirstLastNull;
fastLine = tChart1[1] as Steema.TeeChart.Styles.Line;
fastLine.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
fastLine.XValues.DateTime = true;
fastLine.LinePen.Width = 2;
fastLine.DataSource = points;
fastLine.Pointer.Visible = true;
numOfPoints.Text = points.Count.ToString();
lineCount.Text = tChart1[1].Count.ToString();
this.tChart1.Axes.Left.Automatic = false;
this.tChart1.Axes.Left.Maximum = 300;
this.tChart1.Axes.Left.Minimum = -50;
checkBox1_CheckedChanged(checkBox1, EventArgs.Empty);
}
private void tChart1_Zoomed(object sender, EventArgs e)
{
tChart1[1].CheckDataSource(); //series 1 is the function series
}
private void tChart1_UndoneZoom(object sender, EventArgs e)
{
tChart1.Axes.Bottom.SetMinMax(tChart1[0].XValues.Minimum, tChart1[0].XValues.Maximum); //series 0 is the original series, although you could use any value to set the maximum
tChart1[1].CheckDataSource();
}
private void udPointCount_ValueChanged(object sender, EventArgs e)
{
if ((Steema.TeeChart.Functions.DownSampling)tChart1[1].Function != null)
{
((Steema.TeeChart.Functions.DownSampling)tChart1[1].Function).DisplayedPointCount = (int)udPointCount.Value;
tChart1[1].CheckDataSource();
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
downSampling.DisplayedPointCount = (int)udPointCount.Value;
tChart1[1].Function = downSampling;
}
else
{
tChart1[1].Function = null;
}
tChart1[1].CheckDataSource();
lineCount.Text = tChart1[1].Count.ToString();
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
points.Active = !points.Active;
}
}
Clicking on checkBox2 (Points.Active) gives me:
That is, I can't seem to reproduce this issue using the above code and the lastest (unpublished) source for TeeChart v3.
Thank you!
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
Keith,
This is because the FirstMinMaxLast function is sensitive to the first and last visible values of the source series, which it has to be in order to recalculate itself correctly when the chart is zoomed. With the source series set to inactive, these two values are also set to zero and the algorithm returns an empty set. You can, as before, set the bottom axis min and max values manually to work around this, e.g.
This is because the FirstMinMaxLast function is sensitive to the first and last visible values of the source series, which it has to be in order to recalculate itself correctly when the chart is zoomed. With the source series set to inactive, these two values are also set to zero and the algorithm returns an empty set. You can, as before, set the bottom axis min and max values manually to work around this, e.g.
Code: Select all
public partial class Form1 : Form
{
private Steema.TeeChart.Styles.Points points;
private Steema.TeeChart.Styles.Line fastLine;
private Steema.TeeChart.Functions.DownSampling downSampling;
private Steema.TeeChart.Functions.DownSampling downSampling1;
private Nullable<double>[] xValues, yValues;
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void CreateArrays()
{
int length = 100;
xValues = new Nullable<double>[length];
yValues = new Nullable<double>[length];
Random rnd = new Random();
for (int i = 0; i < length; i++)
{
DateTime dt = DateTime.Now - new TimeSpan(0, 0, (length - i), 0);
xValues[i] = dt.ToOADate();
yValues[i] = 100 * Math.Sin(i * 10 * (Math.PI / 180)) + 100;
}
}
private void InitializeChart()
{
CreateArrays();
checkBox1.Checked = true;
tChart1.Aspect.View3D = false;
tChart1.Zoom.Direction = ZoomDirections.Horizontal;
tChart1.Series.Add(new Steema.TeeChart.Styles.Points());
tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
downSampling = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
downSampling1 = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
points = tChart1[0] as Steema.TeeChart.Styles.Points;
points.DefaultNullValue = double.NegativeInfinity;
points.Add(xValues, yValues);
points.XValues.DateTime = true;
points.Active = false;
downSampling.DisplayedPointCount = 10;
udPointCount.Value = downSampling.DisplayedPointCount;
downSampling.Method = Steema.TeeChart.Functions.DownSamplingMethod.MinMaxFirstLastNull;
fastLine = tChart1[1] as Steema.TeeChart.Styles.Line;
fastLine.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
fastLine.XValues.DateTime = true;
fastLine.LinePen.Width = 2;
fastLine.DataSource = points;
fastLine.Pointer.Visible = true;
numOfPoints.Text = points.Count.ToString();
lineCount.Text = tChart1[1].Count.ToString();
this.tChart1.Axes.Left.Automatic = false;
this.tChart1.Axes.Left.Maximum = 300;
this.tChart1.Axes.Left.Minimum = -50;
checkBox2.Checked = points.Active;
checkBox1.Checked = false;
}
private void tChart1_Zoomed(object sender, EventArgs e)
{
tChart1[1].CheckDataSource(); //series 1 is the function series
}
private void tChart1_UndoneZoom(object sender, EventArgs e)
{
tChart1.Axes.Bottom.SetMinMax(tChart1[0].XValues.Minimum, tChart1[0].XValues.Maximum); //series 0 is the original series, although you could use any value to set the maximum
tChart1[1].CheckDataSource();
}
private void udPointCount_ValueChanged(object sender, EventArgs e)
{
if ((Steema.TeeChart.Functions.DownSampling)tChart1[1].Function != null)
{
((Steema.TeeChart.Functions.DownSampling)tChart1[1].Function).DisplayedPointCount = (int)udPointCount.Value;
tChart1[1].CheckDataSource();
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
downSampling.DisplayedPointCount = (int)udPointCount.Value;
tChart1[1].Function = downSampling;
}
else
{
tChart1[1].Function = null;
}
tChart1.Axes.Bottom.SetMinMax(tChart1[0].XValues.Minimum, tChart1[0].XValues.Maximum);
tChart1[1].CheckDataSource();
lineCount.Text = tChart1[1].Count.ToString();
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
points.Active = checkBox2.Checked;
}
}
Thank you!
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/