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?
series points
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Chris,
Hope this helps!
Yes, you can use NearestPoint tool like this: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?
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];
}
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: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?
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();
}
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 |