synchonize two Gantt Charts

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Henksr
Newbie
Newbie
Posts: 3
Joined: Mon May 28, 2018 12:00 am

synchonize two Gantt Charts

Post by Henksr » Thu Nov 29, 2018 10:43 am

Hello,
The two Gantt Charts are related. The Timelines are different, however. How can I achieve that they are equal?
Edit the lower Gantt so that it is equal to the upper one?

Henk
Gantt.PNG
Gantt.PNG (98.18 KiB) Viewed 238 times

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

Re: synchonize two Gantt Charts

Post by Yeray » Mon Dec 03, 2018 8:03 am

Hello,

You can change the bottom axis scale for the lower chart. Ie:

Code: Select all

  lowerChart.Axes.Bottom.SetMinMax(upperChart.Axes.Bottom.Minimum, upperChart.Axes.Bottom.Maximum);
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Image Please read our Bug Fixing Policy

Henksr
Newbie
Newbie
Posts: 3
Joined: Mon May 28, 2018 12:00 am

Re: synchonize two Gantt Charts

Post by Henksr » Wed Dec 05, 2018 11:05 am

Hello,

Something strange happens: setting the bottom axis happens with a delay of a click. See Video
The Bottomaxis automatic is set to false.

The code is:

Code: Select all

procedure TWerktijdoverzichtDag.SetChart;
var
  startT, endT: TTime;
  activiteit: string;
  kleur: TColor;
  i, Y: Integer;
  Itemnummer: Integer;
begin
  Series1.Clear;
  Chart1.Title.Caption := nxMTL_Medewerkers.FieldByName('naam').AsString + ' datum: ' + DateToStr(AdvDateTimePicker1.Date);
  Series1.XValues.DateTime := true;
  Y := 10;
  i := 0;
  nxQL_Activiteiten.First;
  while not nxQL_Activiteiten.eof do
  begin
    startT := TimeOf(nxQL_Activiteiten.FieldByName('WT_VanDT').AsDateTime);
    endT := TimeOf(nxQL_Activiteiten.FieldByName('WT_TotDT').AsDateTime);
    activiteit := nxQL_Activiteiten.FieldByName('A_Activiteitsoort').AsString;
    kleur := nxQL_Activiteiten.FieldByName('A_Activiteitkleur').AsInteger;
    Y := Y + 20;
    Series1.AddGanttColor(startT, endT, Y, activiteit, kleur); // met kleur
    recinfo1[i] := nxQL_Activiteiten.FieldByName('WT_Autonum').AsInteger;
    inc(i);
    nxQL_Activiteiten.Next;
  end;
  // WO toevoegen:
  GanttSeries1.Clear;
  GanttSeries1.XValues.DateTime := true;
  Chart2.Title.Caption := nxMTL_Medewerkers.FieldByName('naam').AsString + ' datum: ' + DateToStr(AdvDateTimePicker1.Date);
  Chart2.Axes.Bottom.SetMinMax(Chart1.Axes.Bottom.Minimum, Chart1.Axes.Bottom.Maximum);
  nxQL_Werkopdrachten.First;
  Y := 10;
  i := 0;
  while not nxQL_Werkopdrachten.eof do
  begin
    startT := TimeOf(nxQL_Werkopdrachten.FieldByName('Van').AsDateTime);
    endT := TimeOf(nxQL_Werkopdrachten.FieldByName('Tot').AsDateTime);
    activiteit := nxQL_Werkopdrachten.FieldByName('Werksoort').AsString;
    kleur := clRed; // nxQL_Activiteiten.FieldByName('A_Activiteitkleur').AsInteger;
    Y := Y + 20;
    Itemnummer := GanttSeries1.AddGanttColor(startT, endT, Y, activiteit, kleur); // met kleur
    GanttSeries1.Marks.Item[Itemnummer].Text.Add('Werk voor: ' + nxQL_Werkopdrachten.FieldByName('Voor').AsString);
    GanttSeries1.Marks.Item[Itemnummer].Text.Add('Van: ' + nxQL_Werkopdrachten.FieldByName('VanT').AsString);
    GanttSeries1.Marks.Item[Itemnummer].Text.Add('Tot: ' + nxQL_Werkopdrachten.FieldByName('TotT').AsString);
    recinfo2[i] := nxQL_Werkopdrachten.FieldByName('Nummer').AsInteger;
    inc(i);
    nxQL_Werkopdrachten.Next;
  end;
end;
Link to video:
https://www.dropbox.com/s/ot4p98yeuvgku ... 4.mp4?dl=0

Henksr
Newbie
Newbie
Posts: 3
Joined: Mon May 28, 2018 12:00 am

Re: synchonize two Gantt Charts

Post by Henksr » Wed Dec 05, 2018 2:26 pm

Problem solved by putting a Chart1.Repaint

Code: Select all

procedure TWerktijdoverzichtDag.SetChart;
var
  startT, endT: TTime;
  activiteit: string;
  kleur: TColor;
  i, Y: Integer;
  Itemnummer: Integer;
begin
  Series1.Clear;
  Chart1.Title.Caption := nxMTL_Medewerkers.FieldByName('naam').AsString + ' datum: ' + DateToStr(AdvDateTimePicker1.Date);
  Series1.XValues.DateTime := true;
  Y := 10;
  i := 0;
  nxQL_Activiteiten.First;
  while not nxQL_Activiteiten.eof do
  begin
    startT := TimeOf(nxQL_Activiteiten.FieldByName('WT_VanDT').AsDateTime);
    endT := TimeOf(nxQL_Activiteiten.FieldByName('WT_TotDT').AsDateTime);
    activiteit := nxQL_Activiteiten.FieldByName('A_Activiteitsoort').AsString;
    kleur := nxQL_Activiteiten.FieldByName('A_Activiteitkleur').AsInteger;
    Y := Y + 20;
    Series1.AddGanttColor(startT, endT, Y, activiteit, kleur); // met kleur
    recinfo1[i] := nxQL_Activiteiten.FieldByName('WT_Autonum').AsInteger;
    inc(i);
    nxQL_Activiteiten.Next;
  end;
  Chart1.Repaint;   //<----------------------------
  // WO toevoegen:
  GanttSeries1.Clear;
  GanttSeries1.XValues.DateTime := true;
  Chart2.Title.Caption := nxMTL_Medewerkers.FieldByName('naam').AsString + ' datum: ' + DateToStr(AdvDateTimePicker1.Date);
  Chart2.Axes.Bottom.SetMinMax(Chart1.Axes.Bottom.Minimum, Chart1.Axes.Bottom.Maximum);
  nxQL_Werkopdrachten.First;
  Y := 10;
  i := 0;
  while not nxQL_Werkopdrachten.eof do
  begin
    startT := TimeOf(nxQL_Werkopdrachten.FieldByName('Van').AsDateTime);
    endT := TimeOf(nxQL_Werkopdrachten.FieldByName('Tot').AsDateTime);
    activiteit := nxQL_Werkopdrachten.FieldByName('Werksoort').AsString;
    kleur := clRed; // nxQL_Activiteiten.FieldByName('A_Activiteitkleur').AsInteger;
    Y := Y + 20;
    Itemnummer := GanttSeries1.AddGanttColor(startT, endT, Y, activiteit, kleur); // met kleur
    GanttSeries1.Marks.Item[Itemnummer].Text.Add('Werk voor: ' + nxQL_Werkopdrachten.FieldByName('Voor').AsString);
    GanttSeries1.Marks.Item[Itemnummer].Text.Add('Van: ' + nxQL_Werkopdrachten.FieldByName('VanT').AsString);
    GanttSeries1.Marks.Item[Itemnummer].Text.Add('Tot: ' + nxQL_Werkopdrachten.FieldByName('TotT').AsString);
    recinfo2[i] := nxQL_Werkopdrachten.FieldByName('Nummer').AsInteger;
    inc(i);
    nxQL_Werkopdrachten.Next;
  end;
end;
Henk

Post Reply