A line chart with error bars seems to be missing from the multitude of chart types available.
I want to show trends over time, and compare groups (three series), but I would like to inform the viewer of the underlying variation, which I can calculate.
Essentially, I want to Add (X, Y, Error, ... ) like a CustomErrorBar, but I want a line graph, not a bar graph.
Any way around this in the mean time?
Line chart with error bars
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi vas,
Ok, I've added your request to the wish-list to be considered for inclusion in future releases.
In the meantime you can hide the bars and custom draw the line like this:
Ok, I've added your request to the wish-list to be considered for inclusion in future releases.
In the meantime you can hide the bars and custom draw the line like this:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.Clear;
Series1.FillSampleValues();
Series1.BarPen.Visible:=false;
Series1.BarBrush.Style:=bsClear;
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var i ,x, y, tmp: Integer;
begin
tmp:=Series1.BarWidth div 2;
x:=Series1.CalcXPos(0) + tmp;
y:=Series1.CalcYPos(0);
Chart1.Canvas.Pen.Color:=clRed;
Chart1.Canvas.Pen.Width:=2;
Chart1.Canvas.MoveTo(x, y);
for i:=1 to Series1.Count-1 do
begin
x:=Series1.CalcXPos(i) + tmp;
y:=Series1.CalcYPos(i);
Chart1.Canvas.LineTo(x, y);
Chart1.Canvas.MoveTo(x, y);
end;
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 |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi vas,
For completeness, for 3D series you can do this:
For completeness, for 3D series you can do this:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.Clear;
Series1.FillSampleValues();
Series1.BarPen.Visible:=false;
Series1.BarBrush.Style:=bsClear;
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var i ,x, y, tmp: Integer;
begin
tmp:=Series1.BarWidth div 2;
x:=Series1.CalcXPos(0) + tmp;
y:=Series1.CalcYPos(0);
Chart1.Canvas.Pen.Color:=clRed;
Chart1.Canvas.Pen.Width:=2;
Chart1.Canvas.MoveTo3D(x, y, Series1.MiddleZ);
for i:=1 to Series1.Count-1 do
begin
x:=Series1.CalcXPos(i) + tmp;
y:=Series1.CalcYPos(i);
Chart1.Canvas.LineTo3D(x, y, Series1.MiddleZ);
Chart1.Canvas.MoveTo3D(x, y, Series1.MiddleZ);
end;
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 |
Clipping?
Almost - this works, except when the screen is scrolled, the lines are displayed outside of the ChartRect.
Oddly, the error bars are not, nor are any other TeeChart series components.
But this is a minor issue for me, but it probably needs to addressed when the new ErrorLine Series is released.
Thanks again.
Oddly, the error bars are not, nor are any other TeeChart series components.
But this is a minor issue for me, but it probably needs to addressed when the new ErrorLine Series is released.
Thanks again.