TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
-
amsus2021
- Newbie

- Posts: 3
- Joined: Tue Nov 02, 2021 12:00 am
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):
Thanks for help !
-
Yeray
- Site Admin

- Posts: 9645
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
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 (19.25 KiB) Viewed 13892 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;
-
amsus2021
- Newbie

- Posts: 3
- Joined: Tue Nov 02, 2021 12:00 am
Post
by amsus2021 » Fri Jun 02, 2023 3:43 pm
Thank you very mush ! I will try !
-
amsus2021
- Newbie

- Posts: 3
- Joined: Tue Nov 02, 2021 12:00 am
Post
by amsus2021 » Fri Jun 02, 2023 4:30 pm
Its working perfect ! Thank you very much !