Grid question

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
INL2
Newbie
Newbie
Posts: 22
Joined: Mon Aug 18, 2008 12:00 am

Grid question

Post by INL2 » Thu Feb 17, 2011 12:12 am

I am using TChart V8.06 to draw a chart that has both a line series and several area series. The stacked area series are just background to show when the line crosses certain thresholds. If I set the area transparency to greater than 0, I can see the grid lines, but if I don't, the grid lines disappear. How can I show the grid lines without setting the transparency?

Also, my left axis is logarithmic, and my area y values are simply log values (10, 100, 1000), but you can see that the red color doesn't quite start at the 100 grid line. How can I fix that?

Image

Thanks

johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

Re: Grid question

Post by johnnix » Thu Feb 17, 2011 6:07 am

Hello,

I also use plots where I need to display areas in the background but I use a different approach. I manual draw these areas using the BeforeDrawSeries (or BefroreDrawAxes) procedure where I calculate my rectangles and paint them accordingly. It needs a few lines of code but produces a nice result.

Regards

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Grid question

Post by Yeray » Fri Feb 18, 2011 10:21 am

Hello,

The custom drawing suggestion from johnnix will always be the most customizable. Here it is another one probably a little bit simpler: You could try with TColorBandTool:

Code: Select all

uses Series, TeeTools;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;
  Chart1.Legend.Visible:=false;

  Chart1.Axes.Left.Logarithmic:=true;
  Chart1.Axes.Left.SetMinMax(1,1000);

  Chart1.AddSeries(TFastLineSeries).FillSampleValues();

  with Chart1.Tools.Add(TColorBandTool) as TColorBandTool do
  begin
    Axis:=Chart1.Axes.Left;
    Transparency:=50;
    Color:=clLime;
    Pen.Visible:=false;
    StartValue:=1;
    EndValue:=10;
  end;

  with Chart1.Tools.Add(TColorBandTool) as TColorBandTool do
  begin
    Axis:=Chart1.Axes.Left;
    Transparency:=50;
    Color:=clred;
    Pen.Visible:=false;
    StartValue:=100;
    EndValue:=1000;
  end;
end;
Also, my left axis is logarithmic, and my area y values are simply log values (10, 100, 1000), but you can see that the red color doesn't quite start at the 100 grid line. How can I fix that?
Have you set the first are to have value 10 and the second one to have value 100. If that's the case, the problem is probably, being stacked areas, the first one goes to 10 and the second one to 110. So you could try setting the second series to have a value 90.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply