Hello Sandra, Thank you for your example, It works great.
I have the problem that each Y custom axis has different scale, and I can not use the Minimum and Maximum value of a specific axis as you do in your example...
Code: Select all
...
axis.SetMinMax(ch1.Axes.Bottom.Minimum, ch1.Axes.Bottom.Maximum);
...
Another problem is that I use a button to add or remove series from the chart (and maybe add or remove axes), here is when I have problems to keep the zoom because when I call CheckZoom() in button_Click() I always get "0" in y1 and y0, However, if I call CheckZoom() in chart_AfterDraw() I get the correct values for y1 and y0, but the y-axes don't rescale.
This is part of my CheckZoom():
Code: Select all
...
for (int c = 0; c < this.CurvesWebChart.Chart.Axes.Custom.Count; c++)
{
Axis axis = this.CurvesWebChart.Chart.Axes.Custom[c];
double y1 = 0;
double y0 = 0;
if (applyNewZoom)//user makes zoom
{//this works great...
y1 = axis.CalcPosPoint(this.CurvesWebChart.Chart.Zoom.y1);
y0 = axis.CalcPosPoint(this.CurvesWebChart.Chart.Zoom.y0);
//save last zoomY1 and zoomY0
this.lastZoomY1 = this.CurvesWebChart.Chart.Zoom.y1;
this.lastZoomY0 = this.CurvesWebChart.Chart.Zoom.y0;
}
else//user pressed button to add/remove series, keep zoom using lastZoomY1 and lastZoomY0 because this.CurvesWebChart.Chart.Zoom.y1 and this.CurvesWebChart.Chart.Zoom.y0 are "0" at this momment
{//here I get correct values only when CheckZoom() is called from chart_AfterDraw(), but axes don't rescale on chart...
y1 = axis.CalcPosPoint(this.lastZoomY1);
y0 = axis.CalcPosPoint(this.lastZoomY0);
}
axis.SetMinMax(y1, y0);
}
...
Am I doing something wrong?
How can I keep the zoom in this case?
Thank you.