How do I create an OrgChart with all nodes collapsed when first displayed?

6,836 views
Skip to first unread message

gwiens

unread,
Feb 12, 2010, 5:59:13 PM2/12/10
to Google Visualization API
I looked through the documentation and scanned this discussion group
looking for syntax help, but I have not found it.

My experiments with this include calling the method
collapse('ndx','collapsed') (where ndx is an integer). However, none
of my permutations has made any difference in the tree -- all nodes
still are created fully expanded.

Can I get an example of node creation which will produce a collapsed
node?

Or do I need to create the tree, then visit each node while calling
the collapse method on each?

Thanks

Viz Kid

unread,
Feb 15, 2010, 7:39:20 AM2/15/10
to google-visua...@googlegroups.com

Hi.

I think that indeed the only way to make all the nodes collapsed is to run collapse on all the rows.

Best,
  Viz Kid


--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.


gwiens

unread,
Feb 17, 2010, 3:20:58 PM2/17/10
to Google Visualization API
Could I get an example of how to use the "collapse" function and where
to place it in the sequence of creating an OrgChart?

> > google-visualizati...@googlegroups.com<google-visualization- api%2Bunsu...@googlegroups.com>

Viz Kid

unread,
Feb 18, 2010, 3:00:19 AM2/18/10
to google-visua...@googlegroups.com

Have a look at the playground at the org chart example: http://code.google.com/apis/ajax/playground/#org_chart

Modify the last line which draws the chart with:

  // Create and draw the visualization.
  var chart new google.visualization.OrgChart(document.getElementById('visualization'));
  chart.draw(data{allowHtmltrueallowCollapsetrue});
  
  for (var 0data.getNumberOfRows()i++{
    chart.collapse(itrue);
  }


Hope this helps,
  Viz Kid

To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.

gwiens

unread,
Feb 19, 2010, 10:29:18 AM2/19/10
to Google Visualization API
Thanks for the example. However, I could not get nodes to present in
collapsed mode when I ran the modified playground code. I had tried
this before and thought I didn't understand the syntax or placing of
the for loop.

I do my testing using Chrome. However, I thought maybe another browser
was called for, so I also tried using IE. Same effect -- nodes all are
drawn in fully expanded mode.

> > > > google-visualizati...@googlegroups.com<google-visualization- api%2Bunsu...@googlegroups.com><google-visualization-
> > api%2Bunsu...@googlegroups.com <api%252Buns...@googlegroups.com>>

Viz Kid

unread,
Feb 19, 2010, 11:57:49 AM2/19/10
to google-visua...@googlegroups.com

Have you added the additional option flag {allowCollapsetrue}?
This exact code in the playground worked for me on every browser I tried (Safari, Chrome and Firefox - all on mac).

To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.

gwiens

unread,
Feb 19, 2010, 11:58:14 PM2/19/10
to Google Visualization API
I missed declaring the putting the "var chart = " before new
google.visualization.OrgChart... bit. Thanks -- it did indeed work.

> > ><google-visualization-
> > > > api%2Bunsu...@googlegroups.com<api%252Buns...@googlegroups.com><
> > api%252Buns...@googlegroups.com<api%25252Bun...@googlegroups.com >

Tim Kasper

unread,
Jan 17, 2014, 1:56:04 PM1/17/14
to google-visua...@googlegroups.com
Four year later...

This has saved me about three hours of works that otherwise would have frustrated me to no end.

Thank you so much Viz Kid. All the best,

Tim

> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-visualization-api?hl=en.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualization-api+unsub...@googlegroups.com.

Mandar Kamate

unread,
Aug 25, 2016, 7:26:30 AM8/25/16
to Google Visualization API
Hi ,
I could show default all rows collapse nodes using above code.But the requirement is now to collpase upto 3 levels from bottom of hierarchy. in other words show hierarchy default as expanded to 3 levels only.I have tried above code by giving hard coding valued for row index,but it collapses the node vertically and not horizontally.
Any help will be greatly appreciated.?

Thanks,
Mandar

Rajat Shukla

unread,
May 3, 2019, 2:50:55 AM5/3/19
to Google Visualization API
Thank you very much.

> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-visualization-api?hl=en.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualization-api+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages