google / google-visualization-issues

288 stars 35 forks source link

Google Chart Explicit WordTree ignores 'size' option I decided #2639

Open AlbyTree opened 6 years ago

AlbyTree commented 6 years ago

The chart I want to create in a Javascript file looks something like this:

var data = [ ['id', 'childLabel', 'parent', 'size', {role: 'style'}] ,
                        [0, 'cats', -1, 1, 'green'],
                        [1, 'are', 0, 2, 'green'],
                        [2, 'really', 1, 3, 'red'],
                        [3, 'awesome', 2, 1, 'red'] ];

But the chart result doesn't take in account the 'size' option I decided(here's an example result).

According to the google chart page:

... format: 'explicit'

You tell the word tree what connects to what, how big to make each subphrase, and what colors to use. The word tree in the previous section was an implicit Word Tree: we just specified an array of phrases, and the word tree figured out how big to make each word.

In an explicit word tree, the chart creator directly provides information about which words link to which, their color, and size.

But what I think is happening is that the 'size' is calculated like the tree is implicit. According to the google chart page:

In implicit word trees, the actual display size of each word is affected by two things: the size specified for the word, and the size specified for all the words below it (that is, to the right) in the tree. In the above word tree, Life has three children: Archaea (size 1), Eukarya (size 5), and Bacteria (size 1). Archaea is displayed at a larger size than its siblings because it has five children, all of size 1. If we add the 21 phyla of bacteria, the relative sizes will change...

As a matter of fact, in this example it seems it's behaving like an implicit tree. The calculus could be something like this:

Even the first explicit tree example on the google page behaves like an implicit tree.

Is there something I'm missing, is the google page wrong or is there a bug in explicit tree?

penguinboi commented 5 years ago

Hello, we also ran into this issue with word trees. Right now, for both implicit and explicit trees, size is ignored for all but leaf nodes. A non leaf's size is a sum of each child node's size only.

Note in the included example that 'cat's size is set to 30 but it is only getting its size from the child 'are' making it 5. The node 'are' should be size 2 but it is getting the sum of the nodes to the right of it.

https://jsfiddle.net/sqmga71u/