Hello,
I have a TpolarSeries and i am looking a way to fill each zone with a different color like the picture below
Is it possible?
Thanks for help
@Yeray: I've edited you post to make the picture visible
TpolarSeries and fillzone
Hi Calou,
Here is an example:
PS: This may help when we'll implement the rose series (TV52013339)
Here is an example:
Code: Select all
uses TeCanvas, Math;
var Colors: array of TColor;
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
for i:=0 to 8 do
begin
if i > 0 then Series1.AddPolar(i*30, Series1.YValue[Series1.Count-1]);
Series1.AddPolar(i*30, 0);
if i < 8 then Series1.AddPolar(i*30, random*30);
end;
Series1.Pointer.Visible := false;
SetLength(Colors,Series1.Count div 3);
for i:=0 to length(Colors) do
begin
Colors[i] := RGB(Random(255), Random(255), Random(255));
end;
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var i: Integer;
tmpPoints: TPointArray;
begin
SetLength(tmpPoints,3);
for i:=0 to Series1.Count-1 div 3 do
begin
tmpPoints[0].X := Series1.CalcXPos(i*3);
tmpPoints[0].Y := Series1.CalcYPos(i*3);
tmpPoints[1].X := Series1.CalcXPos(i*3+1);
tmpPoints[1].Y := Series1.CalcYPos(i*3+1);
tmpPoints[2].X := Series1.CalcXPos(i*3+2);
tmpPoints[2].Y := Series1.CalcYPos(i*3+2);
Chart1.Canvas.Brush.Color := Colors[i];
Chart1.Canvas.Polygon(tmpPoints);
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Hi Calou,
The possibility to have a fully customizable legend is already in the wish list (TV52010510). So I'm afraid that in the meanwhile the only solution you have is custom drawing to the canvas.
The possibility to have a fully customizable legend is already in the wish list (TV52010510). So I'm afraid that in the meanwhile the only solution you have is custom drawing to the canvas.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Hello,
Ok for the legend
I have this code and i am surprised because the zone are not colored
What could be wrong?
Thanks for help
Regards
Ok for the legend
I have this code and i am surprised because the zone are not colored
Code: Select all
procedure TfrmRoseVent.DrawAllPetales(num_chart:integer;prjt:string);
var
prctg_max,prctg,ind: Integer;
begin
...
//parcours des enregs
while not frmMain.IbcQryRd.Eof do
begin
//dessine le contour d'une pétale
DrawPetale(num_chart,frmMain.IbcQryRd.FieldByName('ANGLE').AsInteger,frmMain.SpnEdtAngle.Value,prctg);
ColorPetale(num_chart,ind,frmMain.IbcQryRd.FieldByName('VIT_MOY').AsFloat);
frmMain.IbcQryRd.Next;
Inc(ind,3);
end;//fin du while parcours des enregs
end;
//dessine une petale de la rose
procedure TfrmRoseVent.DrawPetale(num_chart,angle_deb, pas_angle: integer; prctg: double);
begin
//Déssine le contour
TabSeriesRoseVent[num_chart].AddPolar(angle_deb,prctg);
TabSeriesRoseVent[num_chart].AddPolar(angle_deb+pas_angle,prctg);
TabSeriesRoseVent[num_chart].AddPolar(angle_deb+pas_angle,0);
end;
//colorie toutes les pétales
procedure TfrmRoseVent.ColorPetale(num_chart,ind_serie:integer ;vit_moy:double);
var
tmp_pts: TPointArray;
begin
SetLength(tmp_pts,3);
//colorie
tmp_pts[0].X:=TabSeriesRoseVent[num_chart].CalcXPos(ind_serie);
tmp_pts[0].Y:=TabSeriesRoseVent[num_chart].CalcYPos(ind_serie);
tmp_pts[1].X:=TabSeriesRoseVent[num_chart].CalcXPos(ind_serie+1);
tmp_pts[1].Y:=TabSeriesRoseVent[num_chart].CalcYPos(ind_serie+1);
tmp_pts[2].X:=TabSeriesRoseVent[num_chart].CalcXPos(ind_serie+2);
tmp_pts[2].Y:=TabSeriesRoseVent[num_chart].CalcYPos(ind_serie+2);
TabChrtRoseVent[num_chart].Canvas.Brush.Color := clYellow;
TabChrtRoseVent[num_chart].Canvas.Polygon(tmp_pts);
end;
Thanks for help
Regards
Hi Calou,
Yes, the problem is that drawing directly to the canvas needs to be done into an event that is called every time the chart is painted. For example at OnAfterDraw event.
So, you should call your ColorPetale method at OnAfterDraw for example.
Yes, the problem is that drawing directly to the canvas needs to be done into an event that is called every time the chart is painted. For example at OnAfterDraw event.
So, you should call your ColorPetale method at OnAfterDraw for example.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |