Drawing A Line Changes Axes Labels and Grid Lines

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Alex
Newbie
Newbie
Posts: 2
Joined: Wed Jan 30, 2008 12:00 am

Drawing A Line Changes Axes Labels and Grid Lines

Post by Alex » Tue Sep 15, 2009 1:34 pm

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.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Drawing A Line Changes Axes Labels and Grid Lines

Post by Narcís » Tue Sep 15, 2009 2:59 pm

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Alex
Newbie
Newbie
Posts: 2
Joined: Wed Jan 30, 2008 12:00 am

Re: Drawing A Line Changes Axes Labels and Grid Lines

Post by Alex » Tue Sep 15, 2009 3:16 pm

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

Post Reply