Hello,
There is a simple example in attachment that creates a TChart and outputs a value returned by CalcYPosValue(120) method.
This value is always 0, despite what I pass as a parameter.
So, my question is why and what should be done to make it show correct value?
Thanks.
CalcYPosValue returns 0
CalcYPosValue returns 0
- Attachments
-
- TeeChartExample.zip
- (6.74 KiB) Downloaded 675 times
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: CalcYPosValue returns 0
Hello,
This is because the Chart needs to first render before being able to calculate this value. Until the Chart is drawn, the axes do not know where the series points are. You have a couple of options here:
This is because the Chart needs to first render before being able to calculate this value. Until the Chart is drawn, the axes do not know where the series points are. You have a couple of options here:
Code: Select all
public Form1()
{
InitializeComponent();
TChart tchart = new TChart();
tchart.Series.Add(new FastLine());
tchart.Axes.Left.Automatic = false;
tchart.Axes.Left.Minimum = 0;
tchart.Axes.Left.Maximum = 255;
tchart.Aspect.View3D = false;
tchart[0].FillSampleValues();
this.Controls.Add(tchart);
//option 1
/*
tchart.Draw();
int y = tchart.Axes.Left.CalcYPosValue(120);
label1.Text = String.Format("tchart.Chart.Axes.Left.CalcYPosValue(120) = {0}", y);
*/
//option 2
tchart.AfterDraw += tchart_AfterDraw;
}
void tchart_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
int y = (sender as TChart).Axes.Left.CalcYPosValue(120);
label1.Text = String.Format("tchart.Chart.Axes.Left.CalcYPosValue(120) = {0}", y);
}
Best Regards,
Christopher Ireland / 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 |
Re: CalcYPosValue returns 0
Thank you! This works like a charm.
It works without calling Draw() when TChart is placed on UserControl in design mode. However it requires force redrawing in my unit tests.
It works without calling Draw() when TChart is placed on UserControl in design mode. However it requires force redrawing in my unit tests.