Is it possible to zoom in to a specific series line graph?
Or how can I calculate the outside dimensions of a particular series so I can use the tChart.Zoom.ZoomRect() method?
Thanks,
Kevin
Zoom in to specific series (line graph)
Hi Kevin,
I think that the easiest way to do this would be using custom axes. Note that custom axes don't zoom by default. So, a possibility, would be to assign your "non zooming series" to custom axes and the other series will be the only one zoomed.
Here there is an example, that uses a numericUpDown control to choose the series to zoom:
Of course, here you should hide some axes labels or draw left axis labels more to the left, and the bottom axis labels more to the bottom. Or something similar to avoid labels superposition.
I think that the easiest way to do this would be using custom axes. Note that custom axes don't zoom by default. So, a possibility, would be to assign your "non zooming series" to custom axes and the other series will be the only one zoomed.
Here there is an example, that uses a numericUpDown control to choose the series to zoom:
Code: Select all
Steema.TeeChart.Axis CustomVert, CustomHoriz;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
chartController1.Chart = tChart1;
for (int i = 0; i < 4; i++)
{
new Line(tChart1.Chart);
tChart1[i].FillSampleValues(100);
}
numericUpDown1.Maximum = 3;
CustomVert = new Steema.TeeChart.Axis(false, false, tChart1.Chart);
CustomHoriz = new Steema.TeeChart.Axis(true, false, tChart1.Chart);
tChart1.Axes.Custom.Add(CustomVert);
tChart1.Axes.Custom.Add(CustomHoriz);
tChart1.Panel.MarginLeft = 7;
tChart1.Panel.MarginBottom = 10;
tChart1.Zoomed += new EventHandler(tChart1_Zoomed);
}
void tChart1_Zoomed(object sender, EventArgs e)
{
for (int i = 0; i < tChart1.Series.Count; i++)
{
if (i == numericUpDown1.Value)
{
tChart1[i].CustomVertAxis = tChart1.Axes.Left;
tChart1[i].CustomHorizAxis = tChart1.Axes.Bottom;
}
else
{
tChart1[i].CustomVertAxis = CustomVert;
tChart1[i].CustomHorizAxis = CustomHoriz;
}
}
}
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Hi Yeray, thanks for the prompt reply. I ended up going with my second option because I was reading the "Articles" on this website (http://www.teechart.net/reference/articles/index.php)
There was info about zooming and scrolling so I went wtih it and came up with this:
There was info about zooming and scrolling so I went wtih it and came up with this:
Code: Select all
// basically I determine the number of series that exist
int valueForTopLayerSeries = tChart.Series.Count - 1;
double minX = tChart.Series[valueForTopLayer].MinXValue();
double maxX = tChart.Series[valueForTopLayer].MaxXValue();
double minY = tChart.Series[valueForTopLayer].MinYValue();
double maxY = tChart.Series[valueForTopLayer].MaxYValue() * 1.1; // add 10% so the top mark doesn't get cut off
int x = tChart.Series[valueForTopLayer].CalcXPosValue(minX);
int y = tChart.Series[valueForTopLayer].CalcYPosValue(maxY);
int width = tChart.Series[valueForTopLayer].CalcXPosValue(maxX) - x;
int height = tChart.Series[valueForTopLayer].CalcYPosValue(minY) - y;
Rectangle rect = new Rectangle(x, y, width, height);
tChart.Zoom.ZoomRect(rect);