Page 1 of 1
Howto calculate point index(es) using definite Xvalue
Posted: Fri Apr 24, 2009 11:31 am
by 9641771
I'm looking for function that returns point index(es) having definite Xvalue.
I mean something like
Code: Select all
int[] Indexes TeeChart.Series.CalcIndexForXValue(double XValue)
Is there such a function or I will have to use
foreach instead?
BTW I'm using line series if it's matter.
Posted: Fri Apr 24, 2009 11:40 am
by narcis
Posted: Fri Apr 24, 2009 4:42 pm
by 9641771
It is not exactly what I wanted because
IndexOf returns only the first point index. If I have for example
and than use
it returns
0.
But I of course expect to get
0 and
1.
So what is the solution?
Posted: Mon Apr 27, 2009 8:40 am
by narcis
Hi bairog,
In that case you can use FindAll, for example:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.Add(0, 2);
line1.Add(1, 3);
line1.Add(1, 4);
line1.Add(2, 5);
double[] results = Array.FindAll(line1.XValues.Value, IsOne);
}
private static bool IsOne(double d)
{
return d == 1;
}
Or for getting the indices you need to do that:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.Add(0, 2);
line1.Add(1, 3);
line1.Add(1, 4);
line1.Add(2, 5);
System.Collections.ArrayList results = new System.Collections.ArrayList();
for (int i = 0; i < line1.Count; i++)
{
if (line1.XValues[i] == 1.0)
{
results.Add(i);
}
}
}