Page 1 of 1

GetTeeBrush and TGanttSeries

Posted: Thu Nov 15, 2012 10:55 am
by 16462341
Hi,

Two questions:

1) I would like to put a brush on a TGanttSeries - the code below doesn't allow me to do that? How do I assing the Brush to the TGanttseries??

2) Is it possible to assing different types of Brush to different Points in the same GanttSeries? How do I do that?

Code: Select all

procedure TForm10.FormCreate(Sender: TObject);
var
ABitmap : TBitmap;
s : shortstring;
begin

ABitmap := TBitmap.Create;
GetTeeBrush(3,ABitmap);

with Chart1.AddSeries(TGanttSeries.Create(self)) as TGanttSeries do
  begin
    ParentChart := Chart1;
    ColorEachPoint := true;
    pointer.Brush.Image.Assign(ABitmap);
    Title := 'PO Planned';
    ShowInLegend := true;
    XValues.Order:=loNone;
    Marks.visible := true;
    Marks.Transparent := true;
    Xvalues.DateTime := true;
    with Chart1[Chart1.SeriesCount-1] as TGanttSeries do
      begin
        Pointer.VertSize:=10;
        s := 'hej';
        AddGantt(now,now+1,-1,s);
      end;
  end;

end;


Re: GetTeeBrush and TGanttSeries

Posted: Fri Nov 16, 2012 3:33 pm
by yeray
Hello Hans,

It seems that the patterns based on images work fine with the TLineSeries, but the don't with the TPointSeries nor with the TGanttSeries. I've added it to the defect list to be revised for next releases (TV52016419).

However, the regular patterns seem to work fine. And you could change the pattern depending on the ValueIndex, at the OnGetPointerStyle event:

Code: Select all

  private
    { Private declarations }
    Function SeriesGetPointerStyle(Sender:TChartSeries; ValueIndex:Integer):TSeriesPointerStyle;
//...
procedure TForm1.FormCreate(Sender: TObject);
begin
  with Chart1.AddSeries(TGanttSeries) as TGanttSeries do
  begin
    Pointer.VertSize:=10;
    FillSampleValues(10);
    OnGetPointerStyle:=SeriesGetPointerStyle;
  end;
end;

Function TForm1.SeriesGetPointerStyle(Sender:TChartSeries; ValueIndex:Integer):TSeriesPointerStyle;
begin
  Chart1.Canvas.Brush.Style:=TBrushStyle(2+(ValueIndex mod 6));
  result:=psRectangle;
end;