Reputation: 1
I created a cross hair or chart and I and its working, now I want to change the position of y-axis form left to right (I fixed it form chart properties-> series(collection)->y-axis type change primary to secondary )then its show only x-axis line, i want also y-asix, how can I fix it, my code is below..
//for X axis line
chart1.ChartAreas[0].CursorX.LineWidth = 1;
chart1.ChartAreas[0].CursorX.LineDashStyle = ChartDashStyle.Solid;
chart1.ChartAreas[0].CursorX.LineColor = Color.Red;
//chart1.ChartAreas[0].CursorX.SelectionColor = Color.Yellow;
//for Y axis line
chart1.ChartAreas[0].CursorY.LineWidth = 1;
chart1.ChartAreas[0].CursorY.LineDashStyle = ChartDashStyle.Solid;
chart1.ChartAreas[0].CursorY.LineColor = Color.DarkSlateBlue;
chart1.ChartAreas[0].CursorX.Interval = 0;
chart1.ChartAreas[0].CursorY.Interval = 0;
chart1.ChartAreas[0].CursorX.SetCursorPixelPosition(mousePoint, true);
chart1.ChartAreas[0].CursorY.SetCursorPixelPosition(mousePoint, true);
label2.Text = "pixel of X=" + chart1.ChartAreas[0].AxisX.PixelPositionToValue(e.X).ToString();
label3.Text = "pixel of X2=" + chart1.ChartAreas[0].AxisY2.PixelPositionToValue(e.Y).ToString();
Upvotes: 0
Views: 772
Reputation: 13188
Use AxisY2
instead:
label2.Text = "Pixel of X Position = " + chart1.ChartAreas[0].AxisX.PixelPositionToValue(e.X).ToString("0.00");
label3.Text = "Pixel of Y Position = " + chart1.ChartAreas[0].AxisY2.PixelPositionToValue(e.Y).ToString("0.00");
Upvotes: 1