Page 1 of 1
Grid question
Posted: Thu Feb 17, 2011 12:12 am
by 10049920
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?
Thanks
Re: Grid question
Posted: Thu Feb 17, 2011 6:07 am
by 10046032
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
Re: Grid question
Posted: Fri Feb 18, 2011 10:21 am
by yeray
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.