Page 1 of 1

TeeChart.Net Zoom

Posted: Thu Sep 15, 2005 10:17 am
by 8123141
I'm experiencing problems using the tchart zoom feature.

In my chart, annotations describe the contents of the curves. The right border of an annotation is always 15 pixels to the left of a seperator line.

When i use the zoom feature, the annotations remain where they are, although I update the annotations in the "zoom"-event:

this.tChart.Zoomed += new System.EventHandler(this.tChart_Zoomed);

private void tChart_Zoomed(object sender, System.EventArgs e)
{
foreach (object o in tChart.Tools)
{
if (o.GetType() == typeof(Steema.TeeChart.Tools.Annotation))
{
((Steema.TeeChart.Tools.Annotation)o).Invalidate();
((Steema.TeeChart.Tools.Annotation)o).Shape.Invalidate();
((Steema.TeeChart.Tools.Annotation)o).Shape.Visible = false;
}
}

CalcLabelsPositions();

foreach (object o in tChart.Tools)
{
if (o.GetType() == typeof(Steema.TeeChart.Tools.Annotation))
{
//((Steema.TeeChart.Tools.Annotation)o).Invalidate();
//((Steema.TeeChart.Tools.Annotation)o).Shape.Invalidate();
((Steema.TeeChart.Tools.Annotation)o).Shape.Visible = true;
}
}

this.tChart.Invalidate(true);
this.tChart.Refresh();
}


private void CalcLabelsPositions()
{
try
{
Graphics g = this.CreateGraphics();
foreach (VisSeries ser in chartDesc.VisSeriesList.Values)
{
if (ser.MaterialLabels.Count == 0) continue;
foreach (SerLabel serLab in ser.MaterialLabels.Values)
{
int val = tChart.Axes.Bottom.CalcXPosValue(serLab.XPos) - 15
- Convert.ToInt32(Math.Round(
g.MeasureString(serLab.Label.Text, serLab.Label.Shape.Font.DrawingFont).Width, 0));

serLab.Label.Shape.Left = val > 0 ? val : 0;
}
}
g.Dispose();
}
catch(Exception ex)
{
AC.chart2DTracer.E(ex.StackTrace, ex.Message);
}
}

Have you got any idea?

Posted: Fri Sep 16, 2005 11:27 am
by narcis
Hi dotnetjunkee,

You need to position the annotations relative to other TeeChart objects (e.g. axis, series point etc.). The code below works fine when zooming.

Code: Select all

		private Steema.TeeChart.Styles.Line line1;
		private Steema.TeeChart.Tools.Annotation annotation1;

		private void InitializeChart() 
		{
			line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			annotation1 = new Steema.TeeChart.Tools.Annotation(tChart1.Chart);
			line1.FillSampleValues();
			annotation1.Text = "HI"; 
		}
		private void tChart1_BeforeDrawSeries(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			int left, top;
			left = line1.CalcXPos(3);
			top = line1.CalcYPos(3);
			annotation1.Left = left;
			annotation1.Top = top;
		}