Fixed spacing between gantt bars
Posted: Sun Nov 13, 2022 9:44 pm
Hello.
I have a TChart with alClient alignment on a resizable form.
This is a code snippet of how the chart & series is set up:
As I change the height of the form, the spacing between the gantt bars change such that the 1st bar is at the bottom of the form and the last bar is at the top of the form.
Regarding the Left axis, how can I have fixed spacing between gantt bars (x pixels or y% of the height of a gantt bar) regardless of (i) the height of the chart and (ii) the min/max position?
Regards
Mark
I have a TChart with alClient alignment on a resizable form.
This is a code snippet of how the chart & series is set up:
Code: Select all
FGanttSeries := TGanttSeries.Create(GanttChart);
GanttChart.AddSeries(FGanttSeries);
FGanttSeries.Marks.Visible := true;
FGanttSeries.InflateMargins := true;
FGanttSeries.ColorEachPoint := false;
FGanttSeries.Pointer.Size := 8; FGanttSeries.Pointer.SizeUnits := suPixels;
FGanttSeries.Pointer.Pen.Visible := false; // no border around bars
FGanttSeries.Marks.Transparent := true;
FGanttSeries.Marks.Font.Color := clWhite;
FGanttSeries.Marks.Margins.Left := 0;
FGanttSeries.Marks.Margins.Right := 0;
FGanttSeries.Marks.Margins.Top := 0;
FGanttSeries.Marks.Margins.Bottom := 0;
while not eof do begin
LBarIndex := FGanttSeries.AddGanttColor(FieldByName(FView.ScheduleFieldStart).AsDateTime, FieldByName(FView.ScheduleFieldEnd).AsDateTime,
LPos, FieldByName(FView.ScheduleFieldDesc).AsString, LColour);
Next;
end;
GanttChart.LeftAxis.Automatic := false
GanttChart.LeftAxis.SetMinMax(LMinPos, LMaxPos);
GanttChart.BottomAxis.SetMinMax(LStartDate, LStartDate + LDateRange);
GanttChart.BottomAxis.Title.Caption := DateToStr(LStartDate);
Regarding the Left axis, how can I have fixed spacing between gantt bars (x pixels or y% of the height of a gantt bar) regardless of (i) the height of the chart and (ii) the min/max position?
Regards
Mark