I have a webpage containing a ScatterGraph, and I've used one of your previous examples from the discussion board enabling the user to click on any point in the graph and using a cursor, return the X and Y coordinates of the nearest point. An image of my graphing section of the webpage can be found here:
And here is the code behind the PlotAreaClick event:
private void InverseMap(System.Drawing.Rectangle plotAreaBounds, int x, int y, XAxis xAxis, YAxis yAxis, out double xValue, out double yValue)
{
xValue = ((xAxis.Range.Maximum - xAxis.Range.Minimum) *
((x - plotAreaBounds.Left) / (double)(plotAreaBounds.Right - plotAreaBounds.Left))) + xAxis.Range.Minimum;
yValue = ((yAxis.Range.Maximum - yAxis.Range.Minimum) *
((plotAreaBounds.Bottom - y) / (double)(plotAreaBounds.Bottom - plotAreaBounds.Top))) + yAxis.Range.Minimum;
}
protected void ScatterGraph1_PlotAreaClick(object sender, ClickEventArgs e)
{
double xValue, yValue;
XAxis xAxis1;
YAxis yAxis1;
DateTime ClickDate;
ScatterGraph1.Cursors[0].LabelXFormat = new NationalInstruments.UI.FormatString(NationalInstruments.UI.FormatStringMode.DateTime, "M/d/yy h:mm:ss tt");
ScatterGraph1.Cursors[0].LabelYFormat = new NationalInstruments.UI.FormatString(NationalInstruments.UI.FormatStringMode.Numeric, "F1");
ScatterGraph1.Cursors[0].LabelVisible = false;
ScatterGraph1.Cursors[0].Visible = true;
xAxis1 = ScatterGraph1.XAxes[0];
yAxis1 = ScatterGraph1.YAxes[0];
InverseMap(ScatterGraph1.PlotAreaBounds, e.X, e.Y, xAxis1, yAxis1, out xValue, out yValue);
ScatterGraph1.Cursors[0].MoveCursor(xValue, yValue);
ClickDate = (DateTime)DataConverter.Convert(ScatterGraph1.Cursors[0].XPosition, typeof(DateTime));
lblClickDate.Text = ClickDate.ToString("M/d/yyyy");
lblClickTime.Text = ClickDate.ToString("h:mm:ss tt");
lblReading.Text = ScatterGraph1.Cursors[0].YPosition.ToString("0.0");
}
I notice that in Mozilla Firefox, the cursor works correctly and will move to the correct point. However, in Internet Explorer, the cursor doesn't move when the page is refreshed. I know that the MoveCursor method works correctly, because even in IE, the labels lblClickData, lblClickTime, and lblReading all update correctly when the graph is clicked; however, the cursor stays in the same place.
Any suggestions?
Justin