Page 1 of 1

### 1D chart

Posted: Thu Oct 30, 2008 7:25 pm
Do you have a recommendation on how to chart data that is 1 dimension?

Option #1 I would like to create a number line. The data would look something like a number line with a dark line drawn from the min to the max value of the data.

Option #2 As another way to chart something like this would be to have on regular chart that shows a large region that is solid from the min and max values of the data on one axis and on the other axis there is no tick marks or min/max values indicated.

For example if I have a set of data I want to plot that can be any value between 2 and 5. I might want the chart to show a min/max of 0 - 10 on the bottom axis.

So in case #1, I would like to see a number line, and there would be darker line from 2 - 5.

In case #2, maybe assign the data to the bottom axis and the chart shows the bottom axis min/max goes from 0 - 10. A solid line that has a width of 3 units wide (5 -2) creates a bar that goes from the bottom axis to the top of the chart

Posted: Fri Oct 31, 2008 10:10 am
Hello,

You may add one set of data to a Chart. That would give you, as default, a set of Y plotted values. When added to the Chart TeeChart will automatically assign an X index value to plot for each Y value. That would look like a conventional XY Series when plotted with equally spaced points along the X-Axis. To generate the behaviour you require set the Bottom Axis Labels Visible to False:
Eg.

Code: Select all

``````double[] yValues = new double[] { 2,5,7,4 };
tChart1.Axes.Bottom.Labels.Visible = false;``````
if you don't want any x-displacement for your points add all the points at the same x location.
Eg.

Code: Select all

``````double[] yValues = new double[] { 2,5,7,4 };
double[] xValues = new double[] { 0, 0, 0, 0 };
To colour the Lines in the way you choose add them with the add method Color overload. If you wish to plot an additional line to join Max and Min use the Chart OnAfterDraw event and step through the Series points selecting the point equal to Series Max or Min.

Eg.

Code: Select all

``````private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
int maxIdx = -1;
int minIdx = -1;
bool maxAssigned = false;
bool minAssigned = false;

if ((tChart1.Series.Count > 0) && (tChart1.Series[0].Count > 0))
{
for (int i = 0; i < tChart1.Series[0].Count; i++)
{
//take first max min pair
if ((tChart1.Series[0].YValues[i] == tChart1.Series[0].MaxYValue()) && (!maxAssigned))
{
maxIdx = i;
maxAssigned = true;
}
if ((tChart1.Series[0].YValues[i] == tChart1.Series[0].MinYValue()) && (!minAssigned))
{
minIdx = i;
minAssigned = true;
}
if (maxAssigned && minAssigned)
{
//can ... colour point lines. *Note will affect line 'up-to' point
tChart1.Series[0].Colors[maxIdx] = Color.Red;
tChart1.Series[0].Colors[minIdx] = Color.Yellow;
break;
}
}

// and/or ... plot a joining line
g.Pen.Color = Color.Black;
g.Line(tChart1.Series[0].CalcXPos(minIdx), tChart1.Series[0].CalcYPos(minIdx),
tChart1.Series[0].CalcXPos(maxIdx), tChart1.Series[0].CalcYPos(maxIdx));
}``````
If you have more than one point equal to max or min you'll need to decide which points you wish to join. Using the above techniques you can set Line colours as you require, either at Point add time

Regards,
Marc Meumann