Org Chart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
TCardinal
Newbie
Newbie
Posts: 10
Joined: Thu Jan 31, 2008 12:00 am

Org Chart

Post by TCardinal » Tue May 04, 2010 1:39 pm

Are there any instructions/demos for setting up an orgchart series by linking it to a dataset?

thanks

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

Re: Org Chart

Post by Yeray » Wed May 05, 2010 7:45 am

Hi TCardinal,

Have you tried following the instructions form the Tutorial 8 - Database access. You should find Tutorials, User Guide and demo examples at TeeChart programs group.
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

TCardinal
Newbie
Newbie
Posts: 10
Joined: Thu Jan 31, 2008 12:00 am

Re: Org Chart

Post by TCardinal » Wed May 05, 2010 7:59 am

Hi

I have no problem connecting a TChart to a dataset as I have done it many times. I have not used the Org Chart before and cannot make it display, so I was after anything which had any does and don'ts / instructions for this particular series type.

Thanks

TCardinal
Newbie
Newbie
Posts: 10
Joined: Thu Jan 31, 2008 12:00 am

Re: Org Chart

Post by TCardinal » Wed May 05, 2010 6:33 pm

just a bit of info.

I have a dataset:

KeyField: integer
ParentKey: integer
Text: string

each record has a unique key (KeyField) and are linked to their parent records through the ParentKey (child.parentkey = parent.KeyField).

the record(s) at the top of the tree have a null value in the ParentKey.

in the OrgSeries component I have tried linking X and Y each way, but the chart doesn't show. The key values can be large (typically they are in the hundreds) would this cause a problem?

I have added the unit to my project and stepped through - it definately calls the AddNode methods but the chart does not display.

Thanks for any help.

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

Re: Org Chart

Post by Narcís » Thu May 06, 2010 8:26 am

Hi TCardinal,

For populating TOrgSeries you should use TOrgSeriesAdd(const Text:String; Superior:Integer=-1):Integer; method. Text is the text displayed in the node. Superior is the parent node. Root nodes have Superior=-1. The integer value that Add method returns is node's index (a sequential value starting from 0 to Series.Count-1 according to the orther in which node are added to the series) so you can use it later for adding children nodes, for example:

Code: Select all

procedure TOrgSeries.AddSampleValues(NumValues: Integer;
  OnlyMandatory: Boolean);

const
  MaxNames=8;

  Names:Array[0..MaxNames] of String=
    ('John','Anne','Mary','Paul','Bob','Mike','Lisa','Brad','Peter');

  SurNames:Array[0..MaxNames] of String=
    ('Smith','Shane','Wizard','Smart','Best','Patson','Hood','Dale','Scarlet');

  function RandomName:String;
  begin
    result:=Names[Random(MaxNames+1)]+' '+SurNames[Random(MaxNames+1)]+TeeLineSeparator;
  end;

var tmp,
    tmp1 : Integer;
begin
  tmp:=Add(RandomName+'President');
         Add(RandomName+'Sales Director',tmp);
   tmp1:=Add(RandomName+'Product Manager'+TeeLineSeparator+'USA',tmp);
          Add(RandomName+'Asian Sales',tmp1);
   tmp1:=Add(RandomName+'Human Relations',tmp);
          Add(RandomName+'Assistant',tmp1);
end;
Having said that, with your dataset it would be:

Code: Select all

KeyField:=Add(Text, ParentKey);
TOrgSeries' Add method would be the equivalent of Add(YValue, Label) in standard series. So you should add ParentKey to YValues ValueList and Text to labels ValueList.

Hope this helps!
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

TCardinal
Newbie
Newbie
Posts: 10
Joined: Thu Jan 31, 2008 12:00 am

Re: Org Chart

Post by TCardinal » Fri May 07, 2010 8:41 am

Hi Narcis

thanks for this.

Just so I fully understand, I need to create the data in code I can't just link in the dataset unless the keys are sequential?

Thanks

TCardinal
Newbie
Newbie
Posts: 10
Joined: Thu Jan 31, 2008 12:00 am

Re: Org Chart

Post by TCardinal » Fri May 07, 2010 10:44 am

Just to say I have this working now. Excellent.

However is there a way for the series to better calculate the spacing so that it doesn't create overlaps between the boxes?

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

Re: Org Chart

Post by Yeray » Fri May 07, 2010 11:04 am

Hi TCardinal,

Could you please attach an screenshot showing us this bad result?
Thank you 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

TCardinal
Newbie
Newbie
Posts: 10
Joined: Thu Jan 31, 2008 12:00 am

Re: Org Chart

Post by TCardinal » Fri May 07, 2010 11:14 am

here you go
Attachments
orgChart.png
orgseries overlap
orgChart.png (32.01 KiB) Viewed 24445 times

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

Re: Org Chart

Post by Yeray » Fri May 07, 2010 11:36 am

Hi TCardinal,

Yes, I see it is reproducible with the following code:

Code: Select all

uses TeeOrgSeries;

procedure TForm1.FormCreate(Sender: TObject);
var Org1: TOrgSeries;
begin
  Org1:=TOrgSeries(Chart1.AddSeries(TOrgSeries.Create(self)));

  Org1.Add('Metals');

  Org1.Add('Alloys', 0);
  Org1.Add('Base Metals', 0);

  Org1.Add('Bronze',1);
  Org1.Add('Cooper alloy',1);

  Org1.Add('Iron',2);
  Org1.Add('Tin',2);
end;
This series is quite simple right now. I've added it to the wish list to be improved in future releases (TV52014866).

Note that for more complex diagrams like this, there is also the TeeTree component given with TeeChart. You should have a demo of the TeeTree component features in your TeeChart installation path, into the Examples folder.
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

TCardinal
Newbie
Newbie
Posts: 10
Joined: Thu Jan 31, 2008 12:00 am

Re: Org Chart

Post by TCardinal » Fri May 07, 2010 12:06 pm

Thanks Yeray.

Yes, the series needs to calculate it's spacing from the bottom up I guess.

Russell

TCardinal
Newbie
Newbie
Posts: 10
Joined: Thu Jan 31, 2008 12:00 am

Re: Org Chart

Post by TCardinal » Fri May 07, 2010 3:57 pm

Just another thing I noticed. I played with the spacing and got the boxes separated, but it doesn't seem that the horizontal lines terminate for anything but the very end boxes, ie you cannot tell which parent the children belong to.

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

Re: Org Chart

Post by Yeray » Mon May 10, 2010 1:43 pm

Hi TCardinal,

I'm not sure to understand you. I think an example could clarify what you are trying to achieve.
In the example I posted above,

Index - Name - ParentIndex
0 - 'Metals' - NULL (root)
1 - 'Alloys' - 0 (Metals)
2 - 'Base Metals' - 0 (Metals)
3 - 'Bronze' - 1 (Alloys)
4 - 'Cooper alloy' - 1 (Alloys)
5 - 'Iron' - 2 (Base Metals)
6 - 'Tin' - 2 (Base Metals)
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

Fratod68
Newbie
Newbie
Posts: 1
Joined: Mon Feb 22, 2016 12:00 am

Re: Org Chart

Post by Fratod68 » Sun Mar 06, 2016 7:42 am

Hello all,
the last post is dated 10 May 2010. Now we have 2016 and we have the same Problems with ORGCHART. Nothing changed. You make great things on all platforms and for many IDEs. Can you take a programmer for a couple of weeks and let him work on the OrgChart component, so that it works as it should? This spacing issue makes the component unusable.
Thanks in advance,
Francesco

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

Re: Org Chart

Post by Yeray » Mon Mar 07, 2016 8:54 am

Hello,

I've moved the old ticket TV52014866 to the new public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1457

Feel free to add your mail to the CC list to be automatically notified when an update arrives.

Note the TOrgSeries hasn't received much attention because the TeeTree component may be more suitable for those kind of designs, as stated previously in this conversation.
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