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

Timescale in ganttchart

Post by Hans » Mon Jan 24, 2005 9:08 am

If I set the x-scale to f.e. week for a gantt planning tool, the I get a timescale from monday 0:00 up to sunday 23:59.

Is it possible to show only dayparts like form 08:00 up to 17:00 as working time and then skip the 17:00 to 08:00 and go directly to the next day 08:00?

I like to show only the dayparts from f.e. 08:00 to 17:00.

Is that possible?

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Jan 25, 2005 9:21 am

Hi Hans,

yes, that's possible. This has to be done manually. There is an example of this feature available in TeeChart Pro demo features project (All Features -> Welcome ! -> Chart Styles -> Candle -> Axis Labels no Weekends ).

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

Post by Hans » Fri Feb 11, 2005 1:32 pm

Pep,

I downloaded your demo, but can't find the sourcecode, allthough I configured to the sources directory.

What to do?

Hans

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Feb 11, 2005 2:53 pm

Hi Hans,

You should set the sources path to "C:\Program Files\Steema Software\TeeChart 7 for Delphi X\Examples\Features" (Deaful English installation path). Another solution would be openning the full features demo project with Delphi so there you have the source code.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

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

Post by Hans » Fri Feb 11, 2005 3:49 pm

I'm sorry, but that directory doesn't exist.

The instal directory is : C:\Program Files\Steema Software\TeeChart Pro v7.02 Full Source Code\Sources

And the demo file is the executable file I downloaded from the site.

Hans

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Feb 11, 2005 3:58 pm

Hello Hans,
I'm sorry, but that directory doesn't exist.

The instal directory is : C:\Program Files\Steema Software\TeeChart Pro v7.02 Full Source Code\Sources


Ok, that's because you are source code customer.
And the demo file is the executable file I downloaded from the site.


For the demo source code you should download and install the binary installer from the Customer Download Area. This will install TeeChart components, help files, demos, examples, tutorials, etc.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

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

OK, and now the problem

Post by Hans » Fri Feb 11, 2005 4:09 pm

I can't find All Features -> Welcome ! -> Chart Styles -> Candle -> Axis Labels no Weekends .

I have Chart styles->other->big candle, but no other candle with period blocking.

Hans

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

Found the candle

Post by Hans » Fri Feb 11, 2005 4:19 pm

Found the candle without weekends.

But I cannot see how to program the skip of timeperiods on the X-scale.

Could you send me that code?

Hans

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

Code requested

Post by Hans » Mon Feb 14, 2005 4:09 pm

I would like to have some code to create the x-scale without the "night" hours.

Could you please help me, because in the examples I cannot find anything

Hans

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

Post by Marjan » Tue Feb 15, 2005 10:45 am

Hi, Hans.

I did an example of "removing weekends" a while ago for another customer. Please check the following post.
The example removes whole days, but using the same approach you can also remove hours.
Marjan Slatinek,
http://www.steema.com

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

Post by Hans » Tue Feb 15, 2005 4:47 pm

Marjan, thanks


I have a possibility to change between day, week and month, so the x-scale should be recalculated everytime after switching.

I tried to do following to see what happened: "Planbord.Axes.Bottom.Items.Clear;"

But where I tried it, everytime the X-axis were there again.
On_beforedrawaxis
On_beforedrawseries
?
Where can change this? At that place I can try your suggestion of creating new bottom axis.

Hans

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

Post by Marjan » Wed Feb 16, 2005 7:14 am

Hi, Hans.

I'd place the Clear (and repopulation) part in the same procedure you use to switch between different datetime formats. But you must repopulate axis labels (Items) - otherwise TeeChart internal algorithm will take over and generate the "usual" set of labels (no gaps).
Marjan Slatinek,
http://www.steema.com

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

Post by Hans » Thu Feb 17, 2005 3:51 pm

Marjan,

I tried something, but only see the labels change and not the gridlines.

I want to skip completely all gridlines and labels during the night.

So the last line to today is 17:00 and the next one(direct to the last ond of 17:00) is the 09:00 of tomorrow.

With each gridline at the same distance I like to see:

09:00 11:00 13:00 15:00 17:00 09:00 11:00 13:00 15:00 17:00 09:00 etc.

1. Is this possible?
2. How to do that? with code examples please.

Hans

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

help code wanted

Post by Hans » Mon Feb 21, 2005 2:30 pm

Marjan,

Could you please help me?

Hans

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

Post by Marjan » Thu Feb 24, 2005 10:31 am

Hi, Hans.

Using the *same* approach I quoted couple of posts above this one I was able to plot two days according to your specifications. With slight modifications you can use it for whole week, month, ...

Code: Select all

  private
    { Private declarations }
    ValidDates: Array [0..100] of TDate;
    DateCount : Integer;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  // generate dates ... you can get this from sql, etc...
  DateCount := 10;
  // day 1
  ValidDates[0] := EncodeDate(2005,1,31)+EncodeTime(9,0,0,0);
  ValidDates[1] := EncodeDate(2005,1,31)+EncodeTime(11,0,0,0);
  ValidDates[2] := EncodeDate(2005,1,31)+EncodeTime(13,0,0,0);
  ValidDates[3] := EncodeDate(2005,1,31)+EncodeTime(15,0,0,0);
  ValidDates[4] := EncodeDate(2005,1,31)+EncodeTime(17,0,0,0);
  // day 2
  ValidDates[5] := EncodeDate(2005,2,1)+EncodeTime(9,0,0,0);
  ValidDates[6] := EncodeDate(2005,2,1)+EncodeTime(11,0,0,0);
  ValidDates[7] := EncodeDate(2005,2,1)+EncodeTime(13,0,0,0);
  ValidDates[8] := EncodeDate(2005,2,1)+EncodeTime(15,0,0,0);
  ValidDates[9] := EncodeDate(2005,2,1)+EncodeTime(17,0,0,0);

  // populate bottom axis with labels
  // in this example user every 3rd label
  Chart1.Axes.Bottom.Items.Clear;
  for i := 0 to DateCount-1 do
    if i mod 2 = 0 then // show every 2nd label - otherwise you might end up with overlapped labels
      Chart1.Axes.Bottom.Items.Add(i,DateToStr(ValidDates[i])+#13+TimeToStr(ValidDates[i]));
  Chart1.Axes.Bottom.SetMinMax(0,DateCount-1);
  Chart1.Axes.Bottom.LabelsAngle := 90;
end;

function FindMatch(value: TDate; pool: Array of TDate; Const lo_bound, hi_bound: Integer): Integer;
var i: Integer;
begin
  Result := -1;
  for i := lo_bound to hi_bound do
    if value=pool[i] then
    begin
      Result := i;
      break;
    end; 
end;

procedure TForm1.Button1Click(Sender: TObject);
var xvals: Array[0..6] of TDateTime;
    yvals: Array[0..6] of double;
    i, xind: Integer;
begin
  // this is only sample array (example)
  // 1st day data
  xvals[0] := EncodeDate(2005,1,31)+EncodeTime(9,0,0,0);
  yvals[0] := 5.2;
  xvals[1] := EncodeDate(2005,1,31)+EncodeTime(11,0,0,0);
  yvals[1] := 7.2;
  xvals[2] := EncodeDate(2005,1,31)+EncodeTime(13,0,0,0);
  yvals[2] := 1.2;
  xvals[3] := EncodeDate(2005,1,31)+EncodeTime(15,0,0,0);
  yvals[3] := 5.8;
  xvals[4] := EncodeDate(2005,1,31)+EncodeTime(17,0,0,0);
  yvals[4] := 5.8;
  // 2nd day data
  xvals[5] := EncodeDate(2005,2,1)+EncodeTime(9,0,0,0);
  yvals[5] := 5.2;
  xvals[6] := EncodeDate(2005,2,1)+EncodeTime(13,0,0,0);
  yvals[6] := 7.2;
  // Add points to series
  // Note that points have real date x values =>
  // you have to map each value to internal index array
  Series1.Clear;
  for i := 0 to High(xvals) do
  begin
    xind := FindMatch(xvals[i],ValidDates,0,DateCount-1);
    if xind <> -1 then Series1.AddXY(xind,yvals[i]);
  end;
end;
Marjan Slatinek,
http://www.steema.com

Post Reply