Hi Jeremy,
You can use the following approach to synchronize the Y axes when one of them zooms in:
1. Implement an event handler of the scale ruler changed event of the y axis that you zoom, which looks like:
void Scale_RulerRangeChanged(object sender, EventArgs e)
{
_NevronChart.Document.Calculate();
_NevronChart.Document.RecalcLayout(_NevronChart.View.Context);
NChart chart = _NevronChart.Charts[0];
NRange1DD contentRange = chart.Axis(StandardAxis.PrimaryY).ViewRange;
NRange1DD viewRange = chart.Axis(StandardAxis.PrimaryY).Scale.RulerRange;
// compute factors
double beginFactor = contentRange.GetValueFactor(viewRange.Begin);
double endFactor = contentRange.GetValueFactor(viewRange.End);
// then for all other y axes make sure their view range factor equals to begin/end factor
if (beginFactor == 0.0 && endFactor == 1.0)
{
// disable zoom
foreach (NAxis axis in chart.Axes)
{
if (axis.AxisId != (int)StandardAxis.PrimaryY && axis.AxisOrientation == AxisOrientation.Vertical)
{
axis.PagingView.Enabled = false;
}
}
}
else
{
// disable zoom
foreach (NAxis axis in chart.Axes)
{
if (axis.AxisId != (int)StandardAxis.PrimaryY && axis.AxisOrientation == AxisOrientation.Vertical)
{
axis.PagingView.Enabled = true;
// compute the new range based on factor
NRange1DD axisContentRange = axis.ViewRange;
double rangeLength = axisContentRange.End - axisContentRange.Begin;
double begin = axisContentRange.Begin + beginFactor * rangeLength;
double end = axisContentRange.Begin + endFactor * rangeLength;
axis.PagingView.ZoomIn(new NRange1DD(begin, end), 0.0001);
}
}
}
_NevronChart.Refresh();
}
Here the idea is to take the current zoom range in factor form - for example if the axis content range is 0, 100 and the axis is zoomed to 20, 40 - then the code computes two factors - 0.2, 0.4 which are then used to compute a zoom range for all the other Y axes:
// compute the new range based on factor
NRange1DD axisContentRange = axis.ViewRange;
double rangeLength = axisContentRange.End - axisContentRange.Begin;
double begin = axisContentRange.Begin + beginFactor * rangeLength;
double end = axisContentRange.Begin + endFactor * rangeLength;
2. Then attach that event handler to the ruler range changed event of the primary y axis:
chart.Axis(StandardAxis.PrimaryY).Scale.RulerRangeChanged += new EventHandler(Scale_RulerRangeChanged);
Hope this helps...
Best Regards,
Nevron Support Team