Drawing A Line Changes Axes Labels and Grid Lines
Posted: 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.
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.