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?
TeeChart.Net Zoom
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
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.
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;
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |