Treemap with repeated ID

75 views
Skip to first unread message

Leandro Dariva Pinto

unread,
Sep 15, 2023, 8:18:33 AM9/15/23
to Google Visualization API
Hi,

According to the API documentation for treemap each line on the dataset should have a unique value for the column 0 which is displayed as a node header.
So, how can we deal in a sittuation where we have a node header that exists under different parents? For example, suppose that I would like to plot
the number of car models per country segregate by brand. So will have the following levels in my dataset

-Country
--Brand
---Model

I could have some data like this

child parent value
US Root 10000
France France 5000
Toyota US 4000
Ford US 6000
Toyota France 4000
Ford France 1000
Corolla Toyota 1000
Carmy Toyota 2000

The problem is in the brand level. For example. How can we decide If the Corolla belongs to Toyota in US or France?
The solution I came with (no very elegant) is to add index to the child names like this

child parent value
US Root 10000
France France 5000
Toyota US 4000
Ford US 6000
Toyota_0 France 4000
Ford_0 France 1000
Corolla Toyota_1 1000
Carmy Toyota_1 2000

This makes the treemap work properly but the node header show this nasty suffix which is something not very cool.

Is there any way I could presente the node header without this suffix?

Maybe in a future release we it could be included an additional column in the dataset for header node so we could have something like this

child parent value hearder
US Root 10000   US
France France 5000 France
Toyota US 4000 Toyota
Ford US 6000 Ford
Toyota_0 France 4000 Toyota
Ford_0 France 1000 Ford
Corolla Toyota_1 1000 Corolla
Carmy Toyota_1 2000 Carmy

Regards

Leandro Dariva Pinto

unread,
Sep 15, 2023, 12:31:53 PM9/15/23
to Google Visualization API
Reply all
Reply to author
Forward
0 new messages