Page 1 of 1

Patterns to fill pie areas

Posted: Mon Mar 02, 2009 3:54 pm
by 9340497
How can we DEFINE and select the patterns to fill pie areas using TeeChart Pro 7.0. The printer we use forces monochromatic images and we need to define 13 different styles to fill (shading patterns and cross-hatch patterns).
We need an answer as soon as possible because our customer wants to print tomorrow.

Posted: Mon Mar 02, 2009 4:21 pm
by narcis
Hi SIRIUS,

I'm afraid it's not possible to define different brush style/pattern for each pie slice in a pie series.

Posted: Mon Mar 02, 2009 4:48 pm
by narcis
Hi SIRIUS,

Sorry but a colleague pointed me out that it is possible to set a different pattern for each slice as shown in the code below. However, it's not possible to set different patterns and colors at the same time.

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.FillSampleValues();
  Series1.ColorEachPoint:=false;
end;

function TForm1.Series1BeforeAdd(Sender: TChartSeries): Boolean;
begin
  if Series1.Count>0 then
    if Series1.Count=1 then
    begin
       Series1.UsePatterns := true;
       Chart1.Canvas.Brush.Color := clblue;
       Chart1.Canvas.Brush.Style := bsDiagCross;
    end;
end;

Posted: Mon Mar 02, 2009 9:20 pm
by 9340497
Thanks Narcis for your quick answer.
We need to compose the pie as showed in the figure below keeping the sequence 1,2 3 4 etc. with the showed styles. It is possible ?
Image

Posted: Tue Mar 03, 2009 11:06 am
by narcis
Hi Sirius,

You can set slices with different patterns using code below but you can't specify which pattern will be used.

Code: Select all

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

Posted: Tue Mar 03, 2009 1:52 pm
by 9340497
We have verified that after six patterns your sw repeats the same styles. We need to show a pie with 13 different styles in a monochromatic way (no color) and with styles mentioned below:
- Solid color white
- Cross
- Cross small
- Diagonal
- Gray (20%)
- Back diagonal
- Gray (40%)
- Gray (10%)
- Gray (60%)
- Gray (80%)
- Cross diagonal
- Diagonal small
- Solid black

Is that possible or even more to increase up to 20 different styles for a pie with 20 slices ?

Posted: Tue Mar 03, 2009 3:50 pm
by narcis
Hi Sirius,

The only option would be being a TeeChart source code customer and modify where brushes are assigned. The problem is that graphics.pas there are less brush styles defined than what you request:

Code: Select all

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

Posted: Wed Mar 04, 2009 4:32 pm
by 9340497

Posted: Thu Mar 05, 2009 6:13 pm
by 9340497
We need an asnwer to our inquiry dated yesterday as sson as possíble because our customer is waiting for the soltion to build a pie with 13 different patterns according to the sample sent to you on March 2th.
The hard code we have tried did not work !!

Posted: Mon Mar 09, 2009 1:40 pm
by yeray
Hi Sirius,

Excuse us for the delay. We've been doing some tests and finally noticed that this solution works fine in 2D pies but not for 3D. So we'll try to solve it for further releases.

Posted: Wed Mar 11, 2009 11:44 am
by narcis
Hi Sirius,

As an update, we have added support for using brush images in 3D too so in next v8 maintenance release code below will work fine.

Code: Select all

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, TeEngine, Series, ExtCtrls, TeeProcs, Chart, TeeComma;

type
  TForm1 = class(TForm)
    Chart1: TChart;
    Series1: TPieSeries;
    TeeCommander1: TTeeCommander;
    procedure FormCreate(Sender: TObject);
    procedure Chart1AfterDraw(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

type
  TPieSeriesAccess=class(TPieSeries);
var
  Form1: TForm1;

implementation

{$R *.dfm}

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

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var b : TBitmap;
begin
  Chart1.Canvas.Brush.Color := clRed;
  Chart1.Canvas.Brush.Style := bsFDiagonal;
  TPieSeriesAccess(Series1).DrawPie(2);
  b := TBitmap.Create();
  b.LoadFromFile('C:\temp\Copy.bmp');
  Chart1.Canvas.Brush.Bitmap := b;
  TPieSeriesAccess(Series1).DrawPie(8);
  Chart1.Canvas.Brush.Color := clyellow;
  Chart1.Canvas.Brush.Style := bsSolid;
  TPieSeriesAccess(Series1).DrawPie(5);
end;

end.

Define the pie size (diameter)

Posted: Wed Mar 25, 2009 9:26 pm
by 9340497
Thanks for the answer about the previous question.
We need to build pies with the same diameter even if the labels used for the areas and the areas sizes are differents. How can do it ? See the following figures Image and
Image

Posted: Thu Mar 26, 2009 9:56 am
by yeray
Hi Sirius,

Are your different pies in different charts or in the same?
Having multiple pies in the same chart, all them should have the same radius.

Anyway, have you tried these properties?

Code: Select all

Series1.CustomXRadius := 50;
Series1.CustomYRadius := 50;
Series1.Circled := true;
Finally, you may be interested in looking at the demo at All features/Chart styles/Standard/Pie/Multiple Pies

Posted: Thu Mar 26, 2009 11:38 am
by 9340497
I apologize for the mistake attaching the figures.
The figure of the pies generated using your sw is the following one:
Image
where we can see that in oder to place the labels, the pie size is reduced. The customer wants that all pies have the same radio in an independet way of the label sizes.
We will try with your explanation.
Thanks a lot.