How to set pattern for specific donut slice ?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
amsus2021
Newbie
Newbie
Posts: 3
Joined: Tue Nov 02, 2021 12:00 am

How to set pattern for specific donut slice ?

Post by amsus2021 » Fri May 19, 2023 11:01 am

Hi,

I want to set pattern for specific slice in Donut chart. Is its possible ?

I found UsePatterns property but if set they draw all slices with pattern. But I need specific ones.

So, how to select pattern type, foreground and background colors for specific slise ? Maybe using some event ?

Result should looks like this (made by hand):

Image

Thanks for help !

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: How to set pattern for specific donut slice ?

Post by Yeray » Mon May 29, 2023 12:41 pm

Hello,

You can do something similar to the explained here:
TeeChartVCLTest_2023-05-29_14-42-51.png
TeeChartVCLTest_2023-05-29_14-42-51.png (19.25 KiB) Viewed 12872 times

Code: Select all

type TDonutSeriesAccess=class(TDonutSeries);

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.AddSeries(TDonutSeries).FillSampleValues(5);

  Chart1.OnAfterDraw:=PatternInDonutSliceAfterDraw;
end;

procedure TForm1.PatternInDonutSliceAfterDraw(Sender: TObject);
var donut: TDonutSeriesAccess;
begin
  if (Chart1.SeriesCount>0) and (Chart1[0] is TDonutSeries) then
  begin
    donut:=TDonutSeriesAccess(Chart1[0]);
    if pie.Count>1 then
    begin
      Chart1.Canvas.Brush.Color:=donut.GetValueColor(1);
      Chart1.Canvas.Brush.Style:=bsFDiagonal;
      donut.DrawPie(1);
    end;
  end;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

amsus2021
Newbie
Newbie
Posts: 3
Joined: Tue Nov 02, 2021 12:00 am

Re: How to set pattern for specific donut slice ?

Post by amsus2021 » Fri Jun 02, 2023 3:43 pm

Thank you very mush ! I will try !

amsus2021
Newbie
Newbie
Posts: 3
Joined: Tue Nov 02, 2021 12:00 am

Re: How to set pattern for specific donut slice ?

Post by amsus2021 » Fri Jun 02, 2023 4:30 pm

Its working perfect ! Thank you very much !

Post Reply