Filling a line series with color

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Activex7
Newbie
Newbie
Posts: 16
Joined: Wed Aug 16, 2006 12:00 am

Filling a line series with color

Post by Activex7 » Thu Oct 17, 2013 8:59 pm

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,

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Filling a line series with color

Post by Narcís » Fri Oct 18, 2013 8:07 am

Hi Activex7,

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
Same applies to TeeChart for .NET though.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Activex7
Newbie
Newbie
Posts: 16
Joined: Wed Aug 16, 2006 12:00 am

Re: Filling a line series with color

Post by Activex7 » Fri Oct 18, 2013 3:58 pm

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) ?
Attachments
curve-style-5.png
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 10087 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Filling a line series with color

Post by Narcís » Mon Oct 21, 2013 12:03 pm

Hi Activex7,
This is a teechart.net question. We have multiple licenses for both activex and .NET
Ok, apologies for my wrong assumption.
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) ?
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.

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
Image Image Image Image Image Image
Instructions - How to post in this forum

Activex7
Newbie
Newbie
Posts: 16
Joined: Wed Aug 16, 2006 12:00 am

Re: Filling a line series with color

Post by Activex7 » Tue Oct 22, 2013 10:51 pm

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

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Filling a line series with color

Post by Sandra » Thu Oct 24, 2013 2:56 pm

Hello Activex7,

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
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply