i have a chart that i add values to it using datagridview. its xValues are persian date and i add them as string to AXIS-X but when i want to get those values on mouse_move event it returns an incorrect values. here is my code: bool ismiddlebuttonclick = false;
private void chart1_MouseMove(object sender, MouseEventArgs e)
{
if (ismiddlebuttonclick)
{
label_VE.Visible = true;
label_HO.Visible = true;
label_VAL.Visible = true;
label_HO.Location = new Point(76, e.Y);
label_VE.Location = new Point(e.X, 21);
if (e.X <= 83 || e.Y >= 435 || e.Y <= 27 || e.X >= 852)
{
label_VE.Visible = false;
label_HO.Visible = false;
label_VAL.Visible = false;
}
else
{
label_VE.Visible = true;
label_HO.Visible = true;
label_VAL.Visible = true;
}
try
{
double yValue = chart1.ChartAreas[0].AxisY.PixelPositionToValue(e.Y);
double xPixel = chart1.ChartAreas[0].AxisX.ValueToPixelPosition(chart1.ChartAreas[0].AxisX.PixelPositionToValue(e.X));
double xValue = chart1.ChartAreas[0].AxisX.PixelPositionToValue(xPixel);
label_VAL.Text = string.Concat(Math.Round(yValue, 1).ToString(), " , ", xValue.ToString());
label_VAL.Location = new Point(863, e.Y - 5);
}
catch (Exception ex)
{
MessageBox.Show("خطا در نشانگر" + ex.Message, "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
else
{
label_VE.Visible = false;
label_HO.Visible = false;
label_VAL.Visible = false;
return;
}
}
i have tried to convert persian date to date time but my chart got deformation in that case i can see the correct xvalues on label_val.