Re: [visualization-api] Treemap chart : unable to have 2 nodes with same ID but different parents

1,747 views
Skip to first unread message

Daniel LaLiberte

unread,
Jan 2, 2013, 4:36:03 PM1/2/13
to google-visua...@googlegroups.com
Ribardiere ,

I don't know of a reason that the ids have to be globally unique, other than it was assumed to be a reasonable assumption, so I agree with your assessment.  It doesn't seem so difficult to fix, but I won't know until I have time to look into it.  We might have to construct global unique ids for every node by using all the ancestors, for example.  Thanks for your posting about this issue.

dan

On Wed, Jan 2, 2013 at 3:45 PM, Ribardiere Olivier <olivier.r...@gmail.com> wrote:
Hi,

In a Treemap chart, 2 nodes should be able to have the same name if they don't have the same parent.

function drawVisualization({
  // Create and populate the data table.
  var data google.visualization.arrayToDataTable([
    ['Child' 'Parent''Size''Color'],
    ['Global',    null,                0,                               0],
    ['Child1',   'Global',             0,                               0],
    ['Child2',   'Global',             0,                               0],
    ['ChildA',   'Child1',            10,                               0],
    ['ChildB',   'Child1',            10,                               0],
    ['ChildA',   'Child2',            10,                               0],
    ['ChildB',   'Child2',            10,                               0]
  ]);

  // Create and draw the visualization.
  var treemap new google.visualization.TreeMap(document.getElementById('visualization'));
  treemap.draw(data{
    minColor'red',
    midColor'#ddd',
    maxColor'#0d0',
    maxDepth2,
    headerHeight15,
    fontColor'black',
    showScaletrue});
}

Following code raises "More than one row with the same ID (ChildA)", it should not.

Olivier

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/azc-Uov2mDMJ.
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.



--
dlaliberte@Google.com   562D 5CC, Cambridge MA
daniel.laliberte@GMail.com 9 Juniper Ridge Road, Acton MA

Tayeb Karim

unread,
Jan 2, 2013, 4:45:48 PM1/2/13
to google-visua...@googlegroups.com
Each cell in a data table has a Value(used as the id) and FormattedValue(what is shown).
IIRC, this used to be documented but I don't see it in the Treemap page.

The following example does as you wish;

function drawVisualization({
  // Create and populate the data table.
  var data google.visualization.arrayToDataTable([
    ['Child' 'Parent''Size''Color'],
    ['Global',    null,                0,                               0],
    ['Child1',   'Global',             0,                               0],
    ['Child2',   'Global',             0,                               0],
    [{v:'ChildA1'f:'ChildA'},   'Child1',            10,                               0],
    [{v:'ChildB1'f:'ChildB'},   'Child1',            10,                               0],
    [{v:'ChildA2'f:'ChildA'},   'Child2',            10,                               0],
    [{v:'ChildB2'f:'ChildB'},   'Child2',            10,                               0]
-
---
Tayeb Al Karim
t...@google.com

asgallant

unread,
Jan 2, 2013, 5:40:14 PM1/2/13
to google-visua...@googlegroups.com
All nodes with children must have globally unique id's, or else their child nodes won't be able to distinguish which node is their parent.  Since trees are programmatically extensible, it makes sense to enforce unique id's on all nodes, regardless of whether or not they have any child nodes at draw time (as a previously child-less node may have children on redraw).  The solution proposed by tay is probably the best way to handle the problem, absent significant modifications to the TreeMap code that determines the parent-child relationships.
Ribardiere ,
dan

To unsubscribe from this group, send email to google-visualization-api+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.
dlali...@Google.com   562D 5CC, Cambridge MA
daniel.l...@GMail.com 9 Juniper Ridge Road, Acton MA

Daniel LaLiberte

unread,
Jan 2, 2013, 6:00:19 PM1/2/13
to google-visua...@googlegroups.com
Drew,

You are right that there would be a problem referencing the parents if they are not globally unique.  A reference to a parent would have to use a fully qualified path starting from the root instead of just using the non-unique parent id.  This could be done, but is the added complexity worth it?

dan


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.
dlaliberte@Google.com   562D 5CC, Cambridge MA
daniel.laliberte@GMail.com 9 Juniper Ridge Road, Acton MA

asgallant

unread,
Jan 2, 2013, 7:23:12 PM1/2/13
to google-visua...@googlegroups.com
Using a fully qualified path adds an extra burden to the programmer to build the path.  If the only reason to offer them externally is to allow different nodes to have the same name, I don't think it's worth the effort, since we can achieve the same effect without fully qualified paths.  Maybe if you find a need for them internally to the API, they can be offered as an option externally for the users who do need them, but unless someone can come up with a use case where they are legitimately necessary, I wouldn't put much effort into it.
dan

Ribardiere ,
dan


To unsubscribe from this group, send email to google-visualization-api+unsubscr...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.
dlali...@Google.com   562D 5CC, Cambridge MA
daniel.l...@GMail.com 9 Juniper Ridge Road, Acton MA

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/efVJtGVWHDcJ.

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.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.

Scott Busche

unread,
Feb 20, 2015, 10:07:29 AM2/20/15
to google-visua...@googlegroups.com
I came across this issue today and Tay's response from two years ago worked wonderfully. Why hasn't the option of passing a value and formatted value for ID been documented yet?
...

Daniel LaLiberte

unread,
Feb 23, 2015, 9:48:09 AM2/23/15
to google-visua...@googlegroups.com
Hi Scott,

The ability to specify value and formatted value applies to any value, not just for the id in the treemap.   See the documentation for arrayToDataTable: https://developers.google.com/chart/interactive/docs/reference#google.visualization.arraytodatatable where it is mentioned, but it is not up to date.  More documentation on the various ways of specifying datatables are documented at https://developers.google.com/chart/interactive/docs/reference#dataparam and in the separate page: https://developers.google.com/chart/interactive/docs/datatables_dataviews

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.



--
dlaliberte@Google.com   5CC, Cambridge MA
daniel.laliberte@GMail.com 9 Juniper Ridge Road, Acton MA
Reply all
Reply to author
Forward
0 new messages