Page 1 of 1
Gantt Series Bar Height and Spacing
Posted: Tue Oct 14, 2014 3:38 pm
by 16870423
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?
Re: Gantt Series Bar Height and Spacing
Posted: Wed Oct 15, 2014 9:54 am
by yeray
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;
Re: Gantt Series Bar Height and Spacing
Posted: Wed Oct 15, 2014 11:36 am
by 16870423
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?
Re: Gantt Series Bar Height and Spacing
Posted: Wed Oct 15, 2014 12:19 pm
by yeray
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?
Re: Gantt Series Bar Height and Spacing
Posted: Wed Oct 15, 2014 12:49 pm
by 16870423
thanks. that worked and actually solved my mark problem anyway.