Hello,
I am trying to plot some field data using Teechart. Since the dield data I get is intermittent, the measuring device fills time instances where it doesn't have a measurement with 0. I want to plot only the valid measured values (i.e. leave out the zeros). Currently I go through the following loop to add the points one by one to a fastline series and use the fastline.TreatNull property to not paint these null points
For i = 0 To (numRecords - 1)
m_frmChart.chart.Series(0).Add(time(i), RSSI(i))
If RSSI(i) = 0 Then
m_frmChart.chart.Series(0.SetNull(i)
End If
Next
Can I (and if Yes how) use the DefaultNull property of the series so that all I would have to do is
m_frmchart.chart.series(0).defaultnullvalue=0
m_frmchart.chart.series(0).add(RSSI)
m_frmchart.chart.fastlint1.TreatNulls=DoNotPaint
(Series(0) in this instance is fastline1).
Thanks,
Vivek
DefaultNull Value property in TeeChart
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Vivek,
You have 2 options:
1. Using SetNull:
2. Adding a point being transparent:
3. Calling Add() method without any argument:
You have 2 options:
1. Using SetNull:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.DefaultNullValue = 0;
line1.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
Random y = new Random();
for (int i = 0; i < 100; i++)
{
if (i % 5 == 0)
{
line1.Add(line1.DefaultNullValue);
line1.SetNull(i);
}
else
{
line1.Add(y.Next());
}
}
}
Code: Select all
private void InitializeChart()
{
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.DefaultNullValue = 0;
line1.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
Random y = new Random();
for (int i = 0; i < 100; i++)
{
if (i % 5 == 0)
{
line1.Add(line1.DefaultNullValue, Color.Transparent);
//line1.SetNull(i);
}
else
{
line1.Add(y.Next());
}
}
}
Code: Select all
private void InitializeChart()
{
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.DefaultNullValue = 0;
line1.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
Random y = new Random();
for (int i = 0; i < 100; i++)
{
if (i % 5 == 0)
{
line1.Add();
//line1.SetNull(i);
}
else
{
line1.Add(y.Next());
}
}
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi,
Thanks for the clarification. My understanding of the defaultnullvalue was a little different. The name seems to suggest that one you specify the defaultnullvalue, any point in the series whose value was equal to the defaultnullvalue would be treated as a null point.
The only problem I see with the approaches you had suggested is that I need to loop through the data series and add one point at a time. I would think that this would be slower than specifying a value to be interpreted as a null and just adding the entire series i.e.
Series(0).defaultNullValue=0
Series(0).Add(data) where data() is the data I want to plot.
Do you have anyway by which I can add data to a series in a single shot and specify points with a particular value to be treated as a null?
Thanks,
Vivek
Thanks for the clarification. My understanding of the defaultnullvalue was a little different. The name seems to suggest that one you specify the defaultnullvalue, any point in the series whose value was equal to the defaultnullvalue would be treated as a null point.
The only problem I see with the approaches you had suggested is that I need to loop through the data series and add one point at a time. I would think that this would be slower than specifying a value to be interpreted as a null and just adding the entire series i.e.
Series(0).defaultNullValue=0
Series(0).Add(data) where data() is the data I want to plot.
Do you have anyway by which I can add data to a series in a single shot and specify points with a particular value to be treated as a null?
Thanks,
Vivek
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Vivek,
In that case you should have a colour field in your datatable having Color.Transparent for those points you want to be null so that you can do something like this:
In that case you should have a colour field in your datatable having Color.Transparent for those points you want to be null so that you can do something like this:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
Steema.TeeChart.Styles.FastLine fastLine1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
fastLine1.DefaultNullValue = 0;
fastLine1.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
fastLine1.DataSource = GetData();
fastLine1.YValues.DataMember = "Y";
fastLine1.ColorMember = "Color";
}
private DataTable GetData()
{
DataTable TeeDataTable = new DataTable();
DataRow newRow;
DataColumn yval = new DataColumn("Y", typeof(double));
DataColumn color = new DataColumn("Color", typeof(Color));
TeeDataTable.Columns.Add(yval);
TeeDataTable.Columns.Add(color);
for (int i = 0; i < 100; i++)
{
newRow = TeeDataTable.NewRow();
if (i % 5 == 0)
{
newRow[yval] = 0;
newRow[color] = Color.Transparent;
}
else
{
newRow[yval] = i;
newRow[color] = Color.Empty;
}
TeeDataTable.Rows.Add(newRow);
}
return TeeDataTable;
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Vivek,
I forgot to tell you that I have also added your request to the wish-list to be considered for inclusion in future releases.
I forgot to tell you that I have also added your request to the wish-list to be considered for inclusion in future releases.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |