Page 1 of 1

TPieSeries: Fill patterns in legend and markers

Posted: Thu Jun 18, 2009 1:01 pm
by 10052955
Hello,

I am working on a TPieSeries chart.
If I set

Code: Select all

mySeries.usePatterns := true
then symbols in the chart's legend adopt the patterns according to the slice they refer to.
But unfortunately the markers do not behave the same. The symbols in the markers keep the normal coloring as before triggering the patterns by the usePatterns property.

Could someone please give me a hint on how I can make the symbols in the markers take on the patterns?

Thanks!

Re: TPieSeries: Fill patterns in legend and markers

Posted: Thu Jun 18, 2009 3:21 pm
by yeray
Hi Windwalker,

Yes, you could use OnGetSeriesMarkText to define the brush for each mark like in the following example.

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.FillSampleValues(8);
  Series1.UsePatterns := true;
end;

procedure TForm1.Series1GetMarkText(Sender: TChartSeries;
  ValueIndex: Integer; var MarkText: String);
begin
  Series1.Marks.Brush.Color := clNone;
  Series1.Marks.Brush.Style := TBrushStyle((ValueIndex mod 6)+2);
  Series1.Marks.Color := Series1.ValueColor[ValueIndex];
end;
Note that TBrushStyle has 8 elements but the two first aren't used when UsePatterns is true. That's the reason of the "mod 6" and the "+2"

Code: Select all

TBrushStyle = (bsSolid, bsClear, bsHorizontal, bsVertical,
    bsFDiagonal, bsBDiagonal, bsCross, bsDiagCross);

Re: TPieSeries: Fill patterns in legend and markers

Posted: Fri Jun 19, 2009 12:22 pm
by 10052955
Yeray, thanks a lot!