Page 1 of 2

Timescale in ganttchart

Posted: Mon Jan 24, 2005 9:08 am
by 9340459
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?

Posted: Tue Jan 25, 2005 9:21 am
by Pep
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 ).

Posted: Fri Feb 11, 2005 1:32 pm
by 9340459
Pep,

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

What to do?

Hans

Posted: Fri Feb 11, 2005 2:53 pm
by narcis
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.

Posted: Fri Feb 11, 2005 3:49 pm
by 9340459
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

Posted: Fri Feb 11, 2005 3:58 pm
by narcis
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.

OK, and now the problem

Posted: Fri Feb 11, 2005 4:09 pm
by 9340459
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

Found the candle

Posted: Fri Feb 11, 2005 4:19 pm
by 9340459
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

Code requested

Posted: Mon Feb 14, 2005 4:09 pm
by 9340459
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

Posted: Tue Feb 15, 2005 10:45 am
by Marjan
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.

Posted: Tue Feb 15, 2005 4:47 pm
by 9340459
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

Posted: Wed Feb 16, 2005 7:14 am
by Marjan
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).

Posted: Thu Feb 17, 2005 3:51 pm
by 9340459
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

help code wanted

Posted: Mon Feb 21, 2005 2:30 pm
by 9340459
Marjan,

Could you please help me?

Hans

Posted: Thu Feb 24, 2005 10:31 am
by Marjan
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;