Page 1 of 1
series points
Posted: Tue Mar 10, 2009 11:53 am
by 14045263
Is there any way of getting the number of points between the Min and Max X of the screen (not the Min and Max of the series), but when the series isn't visible?
Regards,
Chris.
PS: on a similar note, I think FirstDisplayedIndex() and LastDisplayedIndex() are returning the Min and Max point of the full series rather than just what is displayed on the screen?
Posted: Tue Mar 10, 2009 3:19 pm
by narcis
Hi Chris,
Is there any way of getting the number of points between the Min and Max X of the screen (not the Min and Max of the series), but when the series isn't visible?
Yes, you can use NearestPoint tool like this:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Tools.NearestPoint nearestPoint1;
private void InitializeChart()
{
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.FillSampleValues();
nearestPoint1 = new Steema.TeeChart.Tools.NearestPoint(tChart1.Chart);
nearestPoint1.Series = bar1;
nearestPoint1.Active = false;
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
tChart1.Zoomed += new EventHandler(tChart1_Zoomed);
tChart1.UndoneZoom += new EventHandler(tChart1_UndoneZoom);
tChart1.Scroll += new EventHandler(tChart1_Scroll);
tChart1.Draw();
}
void tChart1_Scroll(object sender, EventArgs e)
{
tChart1.Draw();
}
void tChart1_UndoneZoom(object sender, EventArgs e)
{
tChart1.Draw();
}
void tChart1_Zoomed(object sender, EventArgs e)
{
tChart1.Draw();
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
int min = nearestPoint1.GetNearestPoint(new Point(tChart1.Axes.Bottom.IStartPos, tChart1.Axes.Left.IEndPos));
int max = nearestPoint1.GetNearestPoint(new Point(tChart1.Axes.Bottom.IEndPos, tChart1.Axes.Left.IEndPos));
tChart1.Header.Text = "Min: " + tChart1[0].XValues[min] + " - Max: " + tChart1[0].XValues[max];
}
PS: on a similar note, I think FirstDisplayedIndex() and LastDisplayedIndex() are returning the Min and Max point of the full series rather than just what is displayed on the screen?
No, it returns the indexes of first and last displayed points in a series: You can see how it works implementing AfterDraw event in the example above like this:
Code: Select all
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
int min = nearestPoint1.GetNearestPoint(new Point(tChart1.Axes.Bottom.IStartPos, tChart1.Axes.Left.IEndPos));
int max = nearestPoint1.GetNearestPoint(new Point(tChart1.Axes.Bottom.IEndPos, tChart1.Axes.Left.IEndPos));
//tChart1.Header.Text = "Min: " + tChart1[0].XValues[min] + " - Max: " + tChart1[0].XValues[max];
tChart1.Header.Text = "First index: " + tChart1[0].FirstDisplayedIndex() +
" - Last index: " + tChart1[0].LastDisplayedIndex();
}
Hope this helps!