Page 1 of 1

Org Chart

Posted: Tue May 04, 2010 1:39 pm
by 10548187
Are there any instructions/demos for setting up an orgchart series by linking it to a dataset?

thanks

Re: Org Chart

Posted: Wed May 05, 2010 7:45 am
by yeray
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.

Re: Org Chart

Posted: Wed May 05, 2010 7:59 am
by 10548187
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

Re: Org Chart

Posted: Wed May 05, 2010 6:33 pm
by 10548187
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.

Re: Org Chart

Posted: Thu May 06, 2010 8:26 am
by narcis
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!

Re: Org Chart

Posted: Fri May 07, 2010 8:41 am
by 10548187
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

Re: Org Chart

Posted: Fri May 07, 2010 10:44 am
by 10548187
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?

Re: Org Chart

Posted: Fri May 07, 2010 11:04 am
by yeray
Hi TCardinal,

Could you please attach an screenshot showing us this bad result?
Thank you in advance.

Re: Org Chart

Posted: Fri May 07, 2010 11:14 am
by 10548187
here you go

Re: Org Chart

Posted: Fri May 07, 2010 11:36 am
by yeray
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.

Re: Org Chart

Posted: Fri May 07, 2010 12:06 pm
by 10548187
Thanks Yeray.

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

Russell

Re: Org Chart

Posted: Fri May 07, 2010 3:57 pm
by 10548187
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.

Re: Org Chart

Posted: Mon May 10, 2010 1:43 pm
by yeray
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)

Re: Org Chart

Posted: Sun Mar 06, 2016 7:42 am
by 16477727
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

Re: Org Chart

Posted: Mon Mar 07, 2016 8:54 am
by yeray
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.