I'm trying to draw a simple chart for use with real-time data updates. The
chart is intended to have a fixed 10x10 grid as the graticule. The axis
labels should be just the start (minimum) and stop (maximum) values,
preferrably with units (e.g., us for microseconds).
I've had considerable trouble with this....
For the grid:
I've set min and max, then set increment to (max - min)/10.
That works ok, except that if min/max are not nice round numbers then the
grid gets shifted around. My solution to this has been to set up the top
and right axes with a fixed grid (min = 0, max = 10, incr = 1), and configure
the left and bottom axes to not draw the grid.
Does that make any sense?
For the labels:
I've tried everything I could think of, including the callouts for "next
label" I've seen in the "documentation". The best I've been able to do is
to get the 'max' label to show up correctly. I've never been able to get
the 'min' label to draw. I finally just gave up and turned labels off
entirely. Now, instead, I use an annotation for the min "label" and another
for the max "label". I set the axis title to " " to make sure that room is
left for me to add the annotation.
How was I supposed to get this to reliably work with using the label
functionality?
P.S.- For annotations, I really wanted to write code like:
annotation.Left = chart.ClientRectangle.Width - annotation.Width - pad;
However, there doesn't seem to be a functional 'Width' property. I found a
Wideth property on an embedded Shape, but it is always zero. Any ideas?
How to draw simple chart - 10x10 grid, min/max axis labels
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
Hi,
I think I'd probably run with something similar to this:
I think I'd probably run with something similar to this:
Code: Select all
private Steema.TeeChart.Styles.Line line1;
private Steema.TeeChart.Styles.Line dummy;
private void InitializeChart()
{
tChart1.GetAxisLabel += new Steema.TeeChart.GetAxisLabelEventHandler(tChart1_GetAxisLabel);
tChart1.Aspect.View3D = false;
line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.FillSampleValues();
DoTenGrid();
}
private void DoTenGrid()
{
dummy = new Steema.TeeChart.Styles.Line(tChart1.Chart);
dummy.HorizAxis = Steema.TeeChart.Styles.HorizontalAxis.Top;
dummy.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Right;
tChart1.Axes.Top.Visible = true;
tChart1.Axes.Right.Visible = true;
tChart1.Axes.Top.Ticks.Visible = false;
tChart1.Axes.Right.Ticks.Visible = false;
tChart1.Axes.Top.MinorTicks.Visible = false;
tChart1.Axes.Right.MinorTicks.Visible = false;
tChart1.Axes.Right.SetMinMax(0,10);
tChart1.Axes.Top.SetMinMax(0,10);
tChart1.Axes.Left.Grid.Visible = false;
tChart1.Axes.Bottom.Grid.Visible = false;
tChart1.Axes.Bottom.MinorTicks.Visible = false;
tChart1.Axes.Left.MinorTicks.Visible = false;
Bitmap redraw = tChart1.Bitmap;
double max = tChart1.Axes.Bottom.Maximum;
double min = tChart1.Axes.Bottom.Minimum;
tChart1.Axes.Bottom.Labels.Items.Add(min, min.ToString());
tChart1.Axes.Bottom.Labels.Items.Add(max, max.ToString());
max = tChart1.Axes.Left.Maximum;
min = tChart1.Axes.Left.Minimum;
tChart1.Axes.Left.Labels.Items.Add(min, min.ToString());
tChart1.Axes.Left.Labels.Items.Add(max, max.ToString());
}
private void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
{
if(sender.Equals(tChart1.Axes.Right) || sender.Equals(tChart1.Axes.Top))
{
e.LabelText = " ";
}
}
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/