Page 1 of 1

Zero Values Not being Displayed

Posted: Wed Aug 15, 2007 1:57 pm
by 9642161
I am plotting a timeseries against a set of values which are either zero or one. The chart displays points at 1 values but no point is being displayed for each of the 0 values.


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace SampleTrend
{
public partial class Form1 : Form
{

double?[] timestamps = new double?[25];
double?[] values = new double?[25];


public Form1()
{
InitializeComponent();

InitializeChart();
}


private void InitializeChart()
{
//chart.Axes.Bottom.IsDateTime = true;
uxChart.Header.Text = "";
uxChart.Header.Font.Bold = true;
uxChart.Header.Font.Color = Color.BlueViolet;


//Steema.TeeChart.Themes.Theme.ApplyChartTheme(Steema.TeeChart.Themes.Theme.ModernPalette, chart, -1);
uxChart.Aspect.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
uxChart.Aspect.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
uxChart.Aspect.View3D = false;

uxChart.Legend.LegendStyle = Steema.TeeChart.LegendStyles.Series;

uxChart.Panel.Gradient.Visible = false;
uxChart.Panel.Gradient.EndColor = Color.LightYellow;
}


private void button1_Click(object sender, EventArgs e)
{
PopulateData();

PopulateChart();
}

private void PopulateChart()
{
Steema.TeeChart.Styles.FastLine lineSeries;
Steema.TeeChart.Styles.Points dataPoints;

dataPoints = uxChart.Series.Add(new Steema.TeeChart.Styles.Points()) as Steema.TeeChart.Styles.Points;
lineSeries = uxChart.Series.Add(new Steema.TeeChart.Styles.FastLine()) as Steema.TeeChart.Styles.FastLine;

lineSeries.LinePen.Width = 2;

dataPoints.Add(timestamps, values);

dataPoints.DefaultNullValue = double.NegativeInfinity;
dataPoints.XValues.DateTime = true;

lineSeries.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
lineSeries.XValues.DateTime = true;
lineSeries.DataSource = dataPoints;

}


private void PopulateData()
{
timestamps[0] = 39309.47034;
timestamps[1] = 39309.47381;
timestamps[2] = 39309.47728;
timestamps[3] = 39309.48075;
timestamps[4] = 39309.48422;
timestamps[5] = 39309.4877;
timestamps[6] = 39309.49117;
timestamps[7] = 39309.49464;
timestamps[8] = 39309.49811;
timestamps[9] = 39309.50159;
timestamps[10] = 39309.50506;
timestamps[11] = 39309.50853;
timestamps[12] = 39309.512;
timestamps[13] = 39309.51547;
timestamps[14] = 39309.51895;
timestamps[15] = 39309.52242;
timestamps[16] = 39309.52589;
timestamps[17] = 39309.52936;
timestamps[18] = 39309.53284;
timestamps[19] = 39309.53631;
timestamps[20] = 39309.53978;
timestamps[21] = 39309.54325;
timestamps[22] = 39309.54672;
timestamps[23] = 39309.5502;
timestamps[24] = 39309.55367;

values[0] = 1;
values[1] = 1;
values[2] = 1;
values[3] = 1;
values[4] = 1;
values[5] = 1;
values[6] = 1;
values[7] = 1;
values[8] = 0;
values[9] = 0;
values[10] = 0;
values[11] = 0;
values[12] = 1;
values[13] = 1;
values[14] = 0;
values[15] = 0;
values[16] = 0;
values[17] = 1;
values[18] = 1;
values[19] = 1;
values[20] = 1;
values[21] = 1;
values[22] = 0;
values[23] = 0;
values[24] = 1;



}
}
}

Posted: Wed Aug 15, 2007 2:17 pm
by 9642161
looks like the zero values are being associated as nulls. Why if using a nullable array to add data is zero being assigned as a null value?

Posted: Thu Aug 16, 2007 2:38 pm
by narcis
Hi histry,

This is because you need to set DefaultNullValue before populating series, for example:

Code: Select all

		private void PopulateChart()
		{
			Steema.TeeChart.Styles.FastLine lineSeries;
			Steema.TeeChart.Styles.Points dataPoints;

			dataPoints = uxChart.Series.Add(new Steema.TeeChart.Styles.Points()) as Steema.TeeChart.Styles.Points;
			lineSeries = uxChart.Series.Add(new Steema.TeeChart.Styles.FastLine()) as Steema.TeeChart.Styles.FastLine;

			lineSeries.LinePen.Width = 2;

			dataPoints.DefaultNullValue = double.NegativeInfinity;
			dataPoints.Add(timestamps, values);
			
			dataPoints.XValues.DateTime = true;

			lineSeries.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
			lineSeries.XValues.DateTime = true;
			lineSeries.DataSource = dataPoints; 
		}

Posted: Thu Aug 16, 2007 3:27 pm
by 9642161
Narcis

Thanks, I moved that line up to before adding the values and it corrected the issue.