Timescale in ganttchart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Hans
Newbie
Newbie
Posts: 28
Joined: Mon Jan 03, 2005 5:00 am

Post by Hans » Thu Mar 03, 2005 10:41 am

Marjan,

The scales seems ok now, but:

0. The timgrid (under the lines) is not the same as what the chart shows. This is difficult for handling mouseclicks, read and edit the Gantt serie items, etc.
1. I use addganttcolor instead of addXY and with addganttcolor I don't see any Gantt appear in the chart. The
2. I have lines on every 2 hours over 7 days. What to do with adding gantts if the time of the serievalue is in between the lines? f.e. if you have lines at 08:00 , 10:00, 12:00,etc and a gantt starting time at 09:37?

3. How do you manage the reading of the series on mouseclicks?
4. How do you manage the reading of the chart(timescale display) on mousemovement?

Hans

Hans
Newbie
Newbie
Posts: 28
Joined: Mon Jan 03, 2005 5:00 am

Still not working

Post by Hans » Tue Mar 08, 2005 2:02 pm

Marjan,

Do you have time to check my above mentioned "new" problem?

Thanks,
Hans

Hans
Newbie
Newbie
Posts: 28
Joined: Mon Jan 03, 2005 5:00 am

please help us, we are waiting for weeks now

Post by Hans » Wed Mar 16, 2005 7:07 am

Marjan,

Do you have time to check my above mentioned "new" problem?

Thanks,
Hans

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Thu Mar 17, 2005 12:53 pm

Hi, Hans.

Re #0 : What exactly do you mean by "time grid" ? Chart and series OnMouse and OnClick events will (as usual) return clicked series point index. Because you used sequential values for x values, in your case ValueIndex is equal to point x value. You'll have to store actual datetime (x) in separate array and then make the connection by yourself.

Re #1 : If you're using AddGanttColor method then you're specifying start and end point for "x value" so you'll have to apply the same rules as for single point -> collect all valid dates, then use the approach I suggested, but this time for start and end x value.

Re #2 : Hmm... You'll have to recreate valid datetime array and repopulate series with data. Using the trick I showed you. It can get complicated, but eventually you'll still be able to get the results you're after.

Re #3 & #4: Use Series OnClick event to retrieve clicked point ValueIndex (index). Then use this integer value to find a match in your datetime arrays (or in series YValues values, if you need the vertical position of each Gannt bar).
Marjan Slatinek,
http://www.steema.com

Hans
Newbie
Newbie
Posts: 28
Joined: Mon Jan 03, 2005 5:00 am

Extra Code requested

Post by Hans » Thu Mar 17, 2005 6:28 pm

It looks like we have to write complete new tables, indexes, coordinates,etc. Very complex.

Re #1 Could you give some delphi code for the Addganttcolor? This is what I don't understand and tried, but not succeeded. Based on your example.

Thanks
Hans

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Mon Mar 21, 2005 2:59 pm

Hi, Hans.
some delphi code for the Addganttcolor?
Sure, no problem. The idea is the same as for simple x-y series type (as outlined in my prevous posts):
1) generate the list of all "valid" (date)time values
2) for each x value find a match in the ValidDate array and then use returned index as point x value.

For AddGanttColor this only means that you have to map Gantt bar start and end value:

Code: Select all

// + code from my previous posts
var startxvals: Array[0..1] of TDateTime; 
      endxvals: Array[0..1] of TDateTime; 
      yvals: Array[0..1] of double;
      i,sind,eind: Integer; 
begin
   // 1st Gannt bar
  startxvals[0] := EncodeDate(2005,1,31)+EncodeTime(9,0,0,0); 
  endtxvals[0] := EncodeDate(2005,1,31)+EncodeTime(11,0,0,0); 
  yvals[0] := 1; 
   // 2nd Gannt bar
  startxvals[1] := EncodeDate(2005,1,31)+EncodeTime(13,0,0,0); 
  endtxvals[1] := EncodeDate(2005,1,31)+EncodeTime(15,0,0,0); 
  yvals[0] := 0;
  Series1.Clear; 
  for i := 0 to High(startxvals) do 
  begin 
    sind := FindMatch(startxvals[i],ValidDates,0,DateCount-1); 
    eind := FindMatch(endxvals[i],ValidDates,0,DateCount-1); 
    if (sind <> -1) and (eind <> -1) then Series1.AddGanttColor(sind,eind,yvals[i],clTeecolor); 
  end;
Marjan Slatinek,
http://www.steema.com

Post Reply