Page 1 of 1
How to get the value of the right axis?
Posted: Thu Jan 21, 2021 6:32 am
by 15690245
The value of the bottom and left axis of the cursor position can be obtained through the cursortool component.How can I get the value of the right axis of the cursor position.
Re: How to get the value of the right axis?
Posted: Thu Jan 21, 2021 10:04 am
by Christopher
Hello,
please find following a short code snippet which hopefully shows you how this can be done:
Code: Select all
private void InitializeTChart(TChart chart)
{
void CursorTool_Change(object sender, CursorChangeEventArgs e)
{
chart.Header.Text = $"YValue {e.YValue}";
chart.Header.Text += $" Right axis {chart.Axes.Right.CalcPosPoint(e.y)}";
}
var line1 = new Line(chart.Chart);
var line2 = new Line(chart.Chart);
line1.VertAxis = VerticalAxis.Left;
line2.VertAxis = VerticalAxis.Right;
var rnd = new Random();
for (int i = 0; i < 20; i++)
{
var val = rnd.Next(0, 100);
line1.Add(val);
line2.Add(val * 100);
}
var cursorTool = new CursorTool(chart.Chart);
cursorTool.FollowMouse = true;
cursorTool.Change += CursorTool_Change;
}