Gantt Series Bar Height and Spacing

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
oneofsomany
Newbie
Newbie
Posts: 5
Joined: Tue Oct 14, 2014 12:00 am

Gantt Series Bar Height and Spacing

Post by oneofsomany » Tue Oct 14, 2014 3:38 pm

I have a gantt chart with 1 series. this series uses 2 y positions (0 and 1) to create 2 bars. I want the bars to always be directly underneath each other with no spacing and I want the 2 bars to fill the chart and scale appropriately when the chart is resized. how do I accomplish this?

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

Re: Gantt Series Bar Height and Spacing

Post by Yeray » Wed Oct 15, 2014 9:54 am

Hello,

You could calculate the distance in pixels between both values in the left axis, divide it by 2 and set this as the Pointer.Size for the Gantt. Of course this has to be done for each resize.
Ie:

Code: Select all

uses GanttCh;

var Series1: TGanttSeries;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.Align:=alClient;

  Series1:=Chart1.AddSeries(TGanttSeries) as TGanttSeries;
  Series1.FillSampleValues(2);

  Chart1.Axes.Left.SetMinMax(-2, 3);
  FitGantt;
end;

procedure TForm1.FitGantt;
begin
  Chart1.Draw;

  Series1.Pointer.Size:=Chart1.Axes.Left.CalcSizeValue(1) div 2;
end;

procedure TForm1.Chart1Resize(Sender: TObject);
begin
  FitGantt;
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

oneofsomany
Newbie
Newbie
Posts: 5
Joined: Tue Oct 14, 2014 12:00 am

Re: Gantt Series Bar Height and Spacing

Post by oneofsomany » Wed Oct 15, 2014 11:36 am

Thanks, that works great. However, there is a margin around the two bars which I don't want. how do I get rid of that, or keep it a fixed size? it presently resizes the same as the bars.

Also, how can I stop my mark text in each bar from being pushed upwards when the bar is resized smaller?

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

Re: Gantt Series Bar Height and Spacing

Post by Yeray » Wed Oct 15, 2014 12:19 pm

Hello,
oneofsomany wrote:Thanks, that works great. However, there is a margin around the two bars which I don't want. how do I get rid of that, or keep it a fixed size? it presently resizes the same as the bars.
Have you tried to enhance the example above to fit your needs?
Here it is what I think you are asking for:

Code: Select all

uses GanttCh;

var Series1: TGanttSeries;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.Align:=alClient;

  Series1:=Chart1.AddSeries(TGanttSeries) as TGanttSeries;
  Series1.FillSampleValues(2);

  Chart1.Axes.Left.SetMinMax(-0.5, 1.5);
  Chart1.Axes.Bottom.SetMinMax(Series1.StartValues.MinValue, Series1.EndValues.MaxValue);
  FitGantt;
end;

procedure TForm1.FitGantt;
var pointerSize, yminPos, ymaxPos: Integer;
    tmpMin, tmpMax: Double;
begin
  Chart1.Draw;

  Series1.Pointer.Size:=Chart1.Axes.Left.IAxisSize div 4;
end;

procedure TForm1.Chart1Resize(Sender: TObject);
begin
  FitGantt;
end;
oneofsomany wrote:Also, how can I stop my mark text in each bar from being pushed upwards when the bar is resized smaller?
I don't understand this part. Could you please show some images, or even better, could you please arrange a simple example project we can run as-is to reproduce the problem here?
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

oneofsomany
Newbie
Newbie
Posts: 5
Joined: Tue Oct 14, 2014 12:00 am

Re: Gantt Series Bar Height and Spacing

Post by oneofsomany » Wed Oct 15, 2014 12:49 pm

thanks. that worked and actually solved my mark problem anyway. :)

Post Reply