Gantt chart and display

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
AB Prod
Newbie
Newbie
Posts: 10
Joined: Wed Apr 10, 2013 12:00 am
Location: Paris France

Gantt chart and display

Post by AB Prod » Thu Apr 25, 2013 2:26 pm

Hi,

i'm using TeeChart Pro 2012 VCL (i'm pretty new in it) with Delphi XE2.

I add to a gantt serie 20 to 30 objects, by code using "AddGantt" method, and i wish to control a little better how it is displayed.

1. How can i force the drawing of the Gantt so it will not be displayed under the bottom axis Or on it (Only up)?

2. Which property do i need to use in order to control the spacing between each Gantt object? Sometimes i will draw 3 objects, other times it can be 20 or more, so esthetically speaking it will be nice if the spacing between the items could be kept.

3. There is a way to catch the new value of an extremity (right or left) of a Gantt object after it was modified by mouse(expanded or contracted)?

Best regards

Laurent

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

Re: Gantt chart and display

Post by Yeray » Thu Apr 25, 2013 3:53 pm

Hi Laurent and welcome,
AB Prod wrote:1. How can i force the drawing of the Gantt so it will not be displayed under the bottom axis Or on it (Only up)?
I'm not sure to understand what do you exactly mean. Could you please attach some screenshot or image showing it?
AB Prod wrote:2. Which property do i need to use in order to control the spacing between each Gantt object? Sometimes i will draw 3 objects, other times it can be 20 or more, so esthetically speaking it will be nice if the spacing between the items could be kept.
You should play with the axes scale for this. When the scale is automatic, the minimum and maximum are internally calculated to fit the values that are going to be drawn. Knowing the values that can be drawn, you can set the appropriate stale manually with SetMinMax function.
AB Prod wrote:3. There is a way to catch the new value of an extremity (right or left) of a Gantt object after it was modified by mouse(expanded or contracted)?
Yes. The TGanttSeries has StartValues and EndValues TChartValueLists that store the star and end values of the gantt points. Note these values are TDateTimes, and delphi stores them as Doubles so you may have to transform them.
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

AB Prod
Newbie
Newbie
Posts: 10
Joined: Wed Apr 10, 2013 12:00 am
Location: Paris France

Re: Gantt chart and display

Post by AB Prod » Thu Apr 25, 2013 4:03 pm

Hi Yeray,

tnx for the welcome and the answers.

I'm attaching a snapshot about the first question.

About 2, i will check it.

About 3, i need TDateTime so it is perfect.

Best regards

Laurent
Attachments
Gantt_bottom_axis.JPG
Look at the bottom of the snapshot, there is much more data under the bottom axis, and i wish to display it from the bottom axis up and not form top like it is done now.
Gantt_bottom_axis.JPG (176.62 KiB) Viewed 9757 times

AB Prod
Newbie
Newbie
Posts: 10
Joined: Wed Apr 10, 2013 12:00 am
Location: Paris France

Re: Gantt chart and display

Post by AB Prod » Thu Apr 25, 2013 4:37 pm

Hi,

i found my mistake about my first question, i set the following values upon creation of the form:

// chtResults.LeftAxis.StartPosition := 0;
// chtResults.LeftAxis.EndPosition := 200;

By removing it, i now see data displayed above the bottom axis!

I tried what you wrote for the second point, it is ok now, but still i found it odd, that when setting the following (initialization stuff):
chtResults.LeftAxis.Automatic := False; // necessary for manual set of Min/Max
chtResults.LeftAxis.SetMinMax(0, 30);
then later adding the Gantt object (via AddGantt) that i do not need to recalculate the max value?

chtResults.LeftAxis.SetMinMax(0, 30*FPos); // this line in fact glue all the objects in the same area of the TChart making a mess
By commenting this line, the display got exactly the look i intend.

And for my third question, the TChartValueLists hold all the objects drawn on my Gantt chart isn't it? I can iterate through it to get the values of each Gantt object?

BR

Laurent

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

Re: Gantt chart and display

Post by Yeray » Fri Apr 26, 2013 7:32 am

Hi Laurent,
AB Prod wrote:i found my mistake about my first question, i set the following values upon creation of the form:

// chtResults.LeftAxis.StartPosition := 0;
// chtResults.LeftAxis.EndPosition := 200;

By removing it, i now see data displayed above the bottom axis!
Great!
AB Prod wrote:I tried what you wrote for the second point, it is ok now, but still i found it odd, that when setting the following (initialization stuff):
chtResults.LeftAxis.Automatic := False; // necessary for manual set of Min/Max
chtResults.LeftAxis.SetMinMax(0, 30);
then later adding the Gantt object (via AddGantt) that i do not need to recalculate the max value?

chtResults.LeftAxis.SetMinMax(0, 30*FPos); // this line in fact glue all the objects in the same area of the TChart making a mess
By commenting this line, the display got exactly the look i intend.
Note you don't need to set the Automatic property before calling SetMinMax method; it only should be set if you were going to set the Minimum and Maximum properties directly.
I'm not sure to understand what are you trying to do here, what is FPos?
However, it seems it works as you expected right now. Otherwise, don't hesitate to let us know and please try to arrange a simple example project we can runa s-is to reproduce the situation here.
AB Prod wrote:And for my third question, the TChartValueLists hold all the objects drawn on my Gantt chart isn't it? I can iterate through it to get the values of each Gantt object?
Right. For example, this would move one hour forward all the Gantt values in a TGanttSeries:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var i: Integer;
begin
  for i:=0 to Series1.Count-1 do
  begin
    Series1.StartValues[i]:=Series1.StartValues[i]+DateTimeStep[dtOneHour];
    Series1.EndValues[i]:=Series1.EndValues[i]+DateTimeStep[dtOneHour];
  end;
  Chart1.Draw;
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

AB Prod
Newbie
Newbie
Posts: 10
Joined: Wed Apr 10, 2013 12:00 am
Location: Paris France

Re: Gantt chart and display

Post by AB Prod » Fri Apr 26, 2013 8:53 am

Hi,

tnx for the piece of code on the series.

About the SetMaxMin: tnx for the precision.

The "FPos" is an integer incremented (+1) on each AddGantt call, to avoid all the objects to be drawn on the same position. It seems logic to me that setting the Min/Max by code that the Max must be updated each time i add a Gantt object, somehow the max should increase each time, no?

BR

Laurent

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

Re: Gantt chart and display

Post by Yeray » Fri Apr 26, 2013 3:08 pm

Hi Laurent,
AB Prod wrote:It seems logic to me that setting the Min/Max by code that the Max must be updated each time i add a Gantt object, somehow the max should increase each time, no?
When the Automatic property is set to true this works as you describe: the axs minimum and maximum are internally calculated to fit all the values in the series associated to that axis.
However, setting Automatic to false (or calling SetMinMax function, that sets Automatic to false) you are who has to control it. Imagine you have some thousand points in a series but you only want to show a hundred at a time. This could be done with a SetMinMax call. And then you could have a button to scoll to the next hundred points simply calling SetMinMax with different arguments.
In your case, you just have to adjust the axis each time you add a point (or gantt value).

If you still find problems with it, please try to arrange a simple example project we can run as-is to reproduce the situation here.

Thanks in advance.
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

Post Reply