Page 1 of 1

Colored bands in radar plots

Posted: Thu Jul 08, 2004 11:09 am
by 8573902
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 ?

Posted: Thu Jul 08, 2004 12:24 pm
by Pep
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;

Colored bands

Posted: Fri Jul 09, 2004 8:21 am
by 8573902
Thank you. I will have a look at it.

Tom

Colored bands

Posted: Fri Jul 09, 2004 10:55 am
by 8573902
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.

Posted: Fri Jul 09, 2004 3:33 pm
by Pep
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 ?

colored bands

Posted: Mon Jul 12, 2004 4:05 pm
by 8573902
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 ?

Posted: Tue Jul 13, 2004 6:11 am
by Marjan
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.

Colored bands

Posted: Tue Jul 13, 2004 10:01 am
by 8573902
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.

Posted: Tue Jul 13, 2004 4:16 pm
by Pep
Ok, have a great holidays them 8)