Hello again,
I would like to be able to work out the average between 2 points, indicated on a line graph using (maybe) two x-axis colorbands.
Could you recommend the best way to do this?
thanks.
Average between 2 points
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi andyb,
Have you tried using an average function? You'll find further information at Tutorial 7 - Working with Functions. You'll find TeeChart tutorials at its program group.
Have you tried using an average function? You'll find further information at Tutorial 7 - Working with Functions. You'll find TeeChart tutorials at its program group.
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 |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi andyb,
Then you can try doing something like this:
Then you can try doing something like this:
Code: Select all
private double OldStart,OldEnd;
private void Form1_Load(object sender, EventArgs e)
{
line1.FillSampleValues();
colorBand1.Start = 5;
colorBand1.End = line1.Count -5;
OldStart=colorBand1.Start;
OldStart=colorBand1.End;
CalculateAverageRange(colorBand1.Start, colorBand1.End);
}
private void CalculateAverageRange(double start, double end)
{
Steema.TeeChart.Styles.Line source = new Steema.TeeChart.Styles.Line();
for (int i=0; i <line1.Count; ++i)
{
if ((line1.XValues[i] >= start) && (line1.XValues[i] <= end))
source.Add(line1.XValues[i],line1.YValues[i]);
}
if (tChart1.Series.Count == 1)
{
Steema.TeeChart.Styles.Line line2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
}
Steema.TeeChart.Functions.Average average1 = new Steema.TeeChart.Functions.Average();
tChart1[tChart1.Series.Count - 1].Function = average1;
tChart1[tChart1.Series.Count - 1].DataSource = source;
//tChart1[tChart1.Series.Count - 1].Function.Period = 2;
tChart1[tChart1.Series.Count - 1].CheckDataSource();
}
private void tChart1_MouseMove(object sender, MouseEventArgs e)
{
if ((colorBand1.Start!=OldStart) || (colorBand1.End!=OldEnd))
{
CalculateAverageRange(colorBand1.Start, colorBand1.End);
OldStart=colorBand1.Start;
OldEnd=colorBand1.End;
}
}
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 |