Colored bands in radar plots

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Tom
Newbie
Newbie
Posts: 9
Joined: Fri Nov 15, 2002 12:00 am
Location: Bergen

Colored bands in radar plots

Post by Tom » Thu Jul 08, 2004 11:09 am

I am using TChart 6.01 with Delphi 7 and I am very satisfied with that combination.

One of the plots I am generating is a radar plot with two series in it. What I would like to include is three colored zones with for instance a light red in background of the middle (center) part, a band of light yellow outside that and a corresponding green band from the yellow to the border of the radar plot itself.

I have seen an attribute called DrawZone for the polar plots (in the demo program) but not anything like that for radar plots. Nor do I, by the way find anything like that in the "edit chart" part neither for radar or polar plots.

Is this possible, and how do I program it ?

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Jul 08, 2004 12:24 pm

Hi Tom,

this can be done also with the Radar Series getting the same effect. You must use the same code as in the Demo :

Code: Select all

procedure TForm1.DrawPolarZones;
begin
  if Series1.CircleXCenter<>0 then
  begin
    // Hide pen
    Chart1.Canvas.Pen.Style:=psClear;
    // Draw three zones (green, yellow and red)
    Chart1.Canvas.Brush.Color:=clGreen;
    Series1.DrawZone(0,100,Chart1.Width3D);
    Chart1.Canvas.Brush.Color:=clYellow;
    Series1.DrawZone(100,300,Chart1.Width3D);
    Chart1.Canvas.Brush.Color:=clRed;
    Series1.DrawZone(300,700,Chart1.Width3D);
    // Prepare Pen
    with Chart1.Canvas.Pen do
    begin
      Color:=clWhite;
      Width:=2;
      Style:=psSolid;
    end;
    // Draw "ring" at 300
    Series1.DrawRing(300,Chart1.Width3D);
  end;
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
    Chart1.Canvas.Brush.Color:=clGreen;
    Series1.DrawZone(0,100,Chart1.Width3D);
    Chart1.Canvas.Brush.Color:=clYellow;
    Series1.DrawZone(100,300,Chart1.Width3D);
    Chart1.Canvas.Brush.Color:=clRed;
    Series1.DrawZone(300,700,Chart1.Width3D);
end;

procedure TForm1.Series1BeforeDrawValues(Sender: TObject);
begin
  if CheckBox1.Checked then DrawPolarZones;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.Clear;
  Series1.FillSampleValues(10);
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  Chart1.Invalidate;
end;

Tom
Newbie
Newbie
Posts: 9
Joined: Fri Nov 15, 2002 12:00 am
Location: Bergen

Colored bands

Post by Tom » Fri Jul 09, 2004 8:21 am

Thank you. I will have a look at it.

Tom

Tom
Newbie
Newbie
Posts: 9
Joined: Fri Nov 15, 2002 12:00 am
Location: Bergen

Colored bands

Post by Tom » Fri Jul 09, 2004 10:55 am

I am unexperienced, but ... The code seems to work in a fashion, But:

- I would like to have the colored band on the background with the plot on top, so I assume that the event Series1BeforeDrawValues is the correct one. However, I cannot locate that one. Logically, the procedures seems to generate the bands twice where the first one seems to do nothing.

- I need to be able to do this in a non-gui context, so ideally the whole thing should be generated by code, not relying on events.

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Jul 09, 2004 3:33 pm

Hi Tom,

I've posted one example into the steema.public.attachments newsgroup which shows how to create the Chart, the Series and necessary events at runtime, using TRadarSeries and the DrawZone. Could you please test it ?

Tom
Newbie
Newbie
Posts: 9
Joined: Fri Nov 15, 2002 12:00 am
Location: Bergen

colored bands

Post by Tom » Mon Jul 12, 2004 4:05 pm

Pardon me for not responding before, I had to tak my family outside the reach of the Internet for the weekend.

In any case, thank you very much, this one is quite a lot closer to what I ideally would like. The ideal would be to have the colors follow the corresponding bands in the radar plot, i.e. as polygons rather than ellipses. Is that possible at all ?

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Tue Jul 13, 2004 6:11 am

Hi.

Yes, I think it can also be done. You only have to replace the Series.DrawZone with canvas Polygon method. Of cource, you'll have do calculate polygon points, but with some coding it can be done successfully.
Marjan Slatinek,
http://www.steema.com

Tom
Newbie
Newbie
Posts: 9
Joined: Fri Nov 15, 2002 12:00 am
Location: Bergen

Colored bands

Post by Tom » Tue Jul 13, 2004 10:01 am

Thank you. I'll try to do some headscratching and see what I can find. It is vacation time now, so I may be silent for the next few weeks.

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Jul 13, 2004 4:16 pm

Ok, have a great holidays them 8)

Post Reply