используя C # с диаграммой .NET.
Я пытаюсь изобразить несколько осциллограмм и хочу перемещать указатель мыши по области диаграммы, чтобы моя всплывающая подсказка отображала значение Y для каждой серии в диаграмме в этом месте значения X.
| at xValue 12 | |
| _ = 3 | |
| * = 2 | * * |
| ________|______________________________*_____ |
| / | * |
| __________*/*********|***************************** |
| * | |
| * | |
|______________________|_____________________________________|
Вроде как эта диаграмма выше. Ниже представлена версия моего кода:
void chart1_MouseMove(object sender, MouseEventArgs e)
{
var pos = e.Location;
_point.X = e.Location.X;
_point.Y = e.Location.Y;
try
{
if ((chart1.ChartAreas[0].AxisX.PixelPositionToValue(e.X) >= 0) && (chart1.ChartAreas[0].AxisX.PixelPositionToValue(e.X) <= max))
{
//Crossair
chart1.ChartAreas[0].CursorX.SetCursorPixelPosition(_point, true);
//Tooltips
double xValue = chart1.ChartAreas[0].AxisX.PixelPositionToValue(e.X);
double yValue = chart1.ChartAreas[0].AxisY.PixelPositionToValue(e.Y);
string all_Data_Values = "";
foreach (var series in chart1.Series)
{
all_Data_Values = all_Data_Values + Environment.NewLine + series.Name + ": " + yValue;
}
tooltip.Show("At " + Math.Truncate(xValue * 1000) / 1000 + all_Data_Values, this.chart1, pos.X - 40, pos.Y - 20);
}
}
catch (Exception exception)
{
//
}
}
Это то, что у меня есть, и сейчас он отображает только значение Y для местоположения моего курсора мыши. Я пробовал другие коды, пытаясь каким-то образом отобразить значения x в chart1.Series [], но это тоже не сработало.
max
? - person Matthew Watson   schedule 22.03.2013