gllona / lib-gg-orgchart

Javascript Organizational Chart Drawing Library
http://librerias.logicas.org/lib_gg_orgchart
Other
54 stars 21 forks source link

an empty children #12

Open dolphinotaku opened 9 years ago

dolphinotaku commented 9 years ago

First of all, i would say exhilarate to find this was being a powerful tool. I use PHP to create a OrgChart(), class OrgChart{ protected $id; protected $title; protected $root; constructor(){ $this->root = new OrgNode(); } }

class OrgNode{ public $id; public $supervisorID; public $title; public $subtitle; public $children; constructor(){ $this->children = array(); } ... }

when I convert OrgChart to json, an emprt "children":[] may exists. shell we replace typeof node.children != "undefined" with typeof node.children != "undefined" && node.children.length >0

or would you write a part of code to convert a query set to match json structure of this tool.

be side, I wanted to request the .render function allow to accept a javascript object, I think the most web based system will be happy to centralize the ajax call. and allow to re-render the org chart.

gllona commented 9 years ago

Hi Keith,

Thank you for your words.

I've a lot of work to do with the library. First I'll integrate the improvements some others did in their own forks. So I won't modify the code of the main branch until I get a full merge by myself.

The workaround I suggest you is to modify your PHP code. The OrgNode can be as:

... private $children; constructor() { ... $this->children = null; } public function addNode () { if ( $this->children === null ) { $this->children = array(); } ... } ...

In this way, you will never get a empty children[] array.

Some others have requested the ability to add and delete nodes dinamically (by clicking in the drawn orgchart). Another option could be a listener function in the JS library code that process these requests from other parts of the page view, or even from the server (i.e. using the push-to-crowser feature that you can found in node.js, or by lazy polling the server from the browser).

I know how to do that but I get problems when re-drawing the chart regarding the proper positioning of the regenerated chart.

The listener I'm talking about could be the best way to define a new structure; your regenerate idea can be implemented as a sequence of primitives (addChilden, deleteChildren, ...)

After I got this functioning I will publish a new version of the library.

Regards,

-Gorka

On 13/08/15 03:11, Keith POON wrote:

First of all, i would say exhilarate to find this was being a powerful tool. I use PHP to create a OrgChart(), class OrgChart{ protected $id; protected $title; protected $root; constructor(){ $this->root = new OrgNode(); } }

class OrgNode{ public $id; public $supervisorID; public $title; public $subtitle; public $children; constructor(){ $this->children = array(); } ... }

when I convert OrgChart to json, an emprt "children":[] may exists. shell we replace typeof node.children != "undefined" with typeof node.children != "undefined" && node.children.length >0

or would you write a part of code to convert a query set to match json structure of this tool.

be side, I wanted to request the .render function allow to accept a javascript object, I think the most web based system will be happy to centralize the ajax call. and allow to re-render the org chart.

— Reply to this email directly or view it on GitHub https://github.com/gllona/lib-gg-orgchart/issues/12.

Gorka G LLona

Email: gllona@gmail.com Phone: +593 9988 72340 WhatsApp: +593 9988 72340 Skype: gllona Hangouts: gllona@gmail.com Web: http://desarrolladores.logicos.org/gorka Github: http://github.com/gllona

Blog: http://gorka.club

Para intercambiar emails encriptados (sin posibilidad de lectura por terceros) contáctame directamente. In order to exchange encrypted emails (no chance of reading for third-parties) please contact me. O descarga directamente mi clave pública PGP/GPG: Or directly download my PGP/GPG public key: ID 0x31944392 de/at http://pgpkeys.mit.edu o/or https://sks-keyservers.net/i/#extract


/ | _ | | __ _ / | | | | | | | / | '| |/ / ` | | | | | | | / | ' \ / ` | | || | () | | | < (| | | || | | || || () | | | | (| | __|**/|| ||**,| | ||__/|| ||\,_|

<< We are all slaves of time >>