Hi,
I have a question about filling a line series with color. I would like to fill a line series in one direction with color.
An example would be I have a line series "Test" with about 10 points, I take the avg of the 10 points and draw another line using the avg value. Now i want all the values lying above the avg to be colored on the series Test.
I tried to do this using the series band tool, the first series is the actual series called Test and the second series will the line drawn using the avg value. The issue here is there is no way I can specify on fill those values which are great than the avg. This fills values both greater than and lesser than mean.
To be brief, I would like to color the peaks and leave the troughs uncolored. Is there a way to do this ?
Thanks,
Filling a line series with color
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Filling a line series with color
Hi Activex7,
Given your nick and that your previous questions are in the TeeChart ActiveX forum, I'll answer this with an ActiveX example:
Same applies to TeeChart for .NET though.
Given your nick and that your previous questions are in the TeeChart ActiveX forum, I'll answer this with an ActiveX example:
Code: Select all
Private Sub Form_Load()
TChart1.Aspect.View3D = False
TChart1.AddSeries scLine
TChart1.Series(0).FillSampleValues 50
TChart1.AddSeries scLine
TChart1.Series(1).SetFunction tfAverage
TChart1.Series(1).DataSource = TChart1.Series(0)
TChart1.Environment.InternalRepaint
Dim Avg As Double
Avg = TChart1.Series(1).YValues.Value(0)
For i = 0 To TChart1.Series(0).Count - 1
If TChart1.Series(0).YValues.Value(i) > Avg Then
TChart1.Series(0).PointColor(i) = vbRed
End If
Next
End Sub
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 |
Re: Filling a line series with color
Hi Narcis,
This is a teechart.net question. We have multiple licenses for both activex and .NET
Just tried what you sent and instead of
TChart1.Series(0).PointColor(i) = vbRed
I am using
Tchart1.Series[0].Colors=color.blue;
This does not work as I want to fill in the curve, not change the line color of the curve.
I attached a example, as image. In this image both the high and lows are filled with color. Assuming the line passing through the middle is avg. Can I just fill in the peaks (highs) ?
This is a teechart.net question. We have multiple licenses for both activex and .NET
Just tried what you sent and instead of
TChart1.Series(0).PointColor(i) = vbRed
I am using
Tchart1.Series[0].Colors=color.blue;
This does not work as I want to fill in the curve, not change the line color of the curve.
I attached a example, as image. In this image both the high and lows are filled with color. Assuming the line passing through the middle is avg. Can I just fill in the peaks (highs) ?
- Attachments
-
- This is example from the web. Here both Peaks and troughs are filled. I Just want peaks filled.
- curve-style-5.png (61.68 KiB) Viewed 10126 times
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Filling a line series with color
Hi Activex7,
Ok, apologies for my wrong assumption.This is a teechart.net question. We have multiple licenses for both activex and .NET
I did a similar example here. This is a Delphi example. In .NET you can do something like the code below using CrossPoints function and HighLow series.This does not work as I want to fill in the curve, not change the line color of the curve.
I attached a example, as image. In this image both the high and lows are filled with color. Assuming the line passing through the middle is avg. Can I just fill in the peaks (highs) ?
Code: Select all
tChart1.Aspect.View3D = false;
tChart1.Legend.CheckBoxes = true;
Line line1 = new Line(tChart1.Chart);
Line line2 = new Line(tChart1.Chart);
Steema.TeeChart.Functions.Average avg1 = new Steema.TeeChart.Functions.Average();
line2.Function = avg1;
line2.DataSource = line1;
line1.FillSampleValues();
tChart1.Draw();
double avg = line2.YValues[0];
Points points1 = new Points(tChart1.Chart);
Steema.TeeChart.Functions.CrossPoints crossPoints1 = new Steema.TeeChart.Functions.CrossPoints();
points1.DataSource = new object[] { line1, line2 };
points1.Function = crossPoints1;
HighLow highLow1 = new HighLow(tChart1.Chart);
highLow1.HighBrush.Visible = true;
int j = 0;
for (int i = 0; i < line1.Count; i++)
{
double y = line1.YValues[i];
if (y > avg)
{
double x = line1.XValues[i];
highLow1.Add(x, y, avg);
}
else
{
double x = points1.XValues[j];
highLow1.Add(x, avg, avg);
j++;
}
}
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 |
Re: Filling a line series with color
Hi Narcis,
Thanks for the suggestion. However I have another issue, does this work if the curve is along the y axis ? I tried the highlow and it only seems to work for a curve along the x-axis.
The code does not seem to work if the value axis is the x-axis ? Can you please let me know ?
Thanks
Thanks for the suggestion. However I have another issue, does this work if the curve is along the y axis ? I tried the highlow and it only seems to work for a curve along the x-axis.
The code does not seem to work if the value axis is the x-axis ? Can you please let me know ?
Thanks
Re: Filling a line series with color
Hello Activex7,
Could you try to use a horizLine to achieve as you want? If it doesn't help please let me know.
Thanks,
Could you try to use a horizLine to achieve as you want? If it doesn't help please let me know.
Thanks,
Best Regards,
Sandra Pazos / 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 |