Page 1 of 1

Drawing A Line Changes Axes Labels and Grid Lines

Posted: Tue Sep 15, 2009 1:34 pm
by 13048151
TeeChart Build: 3.5.3498.27367 (x86)

Our software allows users to click on a chart and draw a line when they move mouse cursor.
When user releases mouse button, a new line is added to a chart.
Sometimes, this causes horizontal axes labels to change and the distance between grid lines on a chart changes as well.

Code that creates line:

private void CreateNewLine(MouseEventArgs e)
{
newLine = new Steema.TeeChart.Styles.Line();
newLine.Visible = true;
newLine.Chart = tChart1.Chart;
newLine.OutLine.Width = 1;
newLine.OutLine.Style = DashStyle.Dot;
newLine.OutLine.Transparency = 70;
newLine.OutLine.Color = Color.Black;
newLine.Title = "Title";
newLine.LinePen.Width = 3;
newLine.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Right;
newLine.Cursor = Cursors.SizeAll;
newLine.Color = Color.Goldenrod;
newLine.Marks.Clip = true;

newLine.Add((int)Math.Round(tChart1.Chart.Axes.Bottom.CalcPosPoint(e.X), 0), tChart1.Chart.Axes.Right.CalcPosPoint(e.Y));
newLine.Add((int)Math.Round(tChart1.Chart.Axes.Bottom.CalcPosPoint(e.X), 0), tChart1.Chart.Axes.Right.CalcPosPoint(e.Y));

newLine.Click += new MouseEventHandler(line_Click);
newLine.BeforeDrawValues += beforeDrawValuesHandler;
newLine.AfterDrawValues += afterDrawValuesHandler;
tChart1.Series.Add(newLine);

}

When users moves mouser cursor and then releases mouse button, the following code changes the line on a chart:

private void MoveEndPoint(Steema.TeeChart.Styles.Line trendLine, MouseEventArgs e)
{
int x = e.X;
int y = e.Y;

newLine.XValues[1] = tChart1.Chart.Axes.Bottom.CalcPosPoint(x);

if (horizontal)
{
newLine.YValues[1] = newLine.YValues[0];
}
else
{
newLine.YValues[1] = tChart1.Chart.Axes.Right.CalcPosPoint(y);
}
}

Any ideas why changing custom line X and Y values would result in automatic axis label changing as well as distance between grid lines would be appreciated.

Re: Drawing A Line Changes Axes Labels and Grid Lines

Posted: Tue Sep 15, 2009 2:59 pm
by narcis
Hi Alex,
Any ideas why changing custom line X and Y values would result in automatic axis label changing as well as distance between grid lines would be appreciated.
This is probably because adding new series to the chart changes data points intervals and/or axes minimum or maximum values and therefore axes are recalculated automatically. If you don't want this to occur you can manually set all those properties as described in tutorial 4. Tutorials can be found at TeeChart's program group.

If the problem persists please attach a simple example project we can run "as-is" to reproduce the problem here.

Thanks in advance.

Re: Drawing A Line Changes Axes Labels and Grid Lines

Posted: Tue Sep 15, 2009 3:16 pm
by 13048151
Thank you very much for your prompt reply.

The fact that the code must be inserting new data point makes a lot of sense.
I'll investigate this further.

Thank you again,
Alex