I've got a form with two charts. One of them displays current function values (say, f(x)) using FastLine series, and the other displays the history of the function (f(x, t), x is in the same range as in the first chart) using ColorGrid series. So the X axis is of the same range in both charts, and Y is different.
When user zooms one of the charts, the other one should adjust display window to contain the area of the chart with the same range of x values. It was easy to implement this synchronization when user zooms the chart.
Code: Select all
private void tChart_UndoneZoom(object sender, System.EventArgs e)
{
TChart other = (sender != tChart1) ? tChart1 : tChart2;
other.UndoneZoom -= new EventHandler(tChart_UndoneZoom);
other.Zoom.Undo();
other.UndoneZoom += new EventHandler(tChart_UndoneZoom);
}
private void tChart_Zoomed(object sender, System.EventArgs e)
{
TChart current = (TChart)sender;
TChart other = (current != tChart1) ? tChart1 : tChart2;
Zoom zoom = current.Zoom;
Rectangle chartRect = other.Chart.ChartRect;
other.Zoomed -= new EventHandler(tChart_Zoomed);
other.Zoom.ZoomRect(new Rectangle(zoom.x0, chartRect.Y, zoom.x1 - zoom.x0, chartRect.Height));
other.Zoomed += new EventHandler(tChart_Zoomed);
}
Thanks in advance,
Alexander