-
richardMay 16, 2016 at 10:56 pm #6155
Hello,
How do you calculate the scale and radius? I tried to create a weighted tree graph with the data below, but the size of nodes is not proportional.
Category,Level1,Level2,Level3,Level4,Federal
Sickness and disability,Pensions,Sickness and disability,,,0
Special Benefits,Pensions,Old age,Federal employee retirement and disability (602),Special Benefits,1
Foreign Service Retirement and Disability Fund,Pensions,Old age,Federal employee retirement and disability (602),Foreign Service Retirement and Disability Fund,2
Armed Forces Retirement Home,Pensions,Old age,Federal employee retirement and disability (602),Armed Forces Retirement Home,3
“Long Term Debt Outstanding Full Faith and Credit Other, NEC (Disc. 2005) (41X)”,Gross Public Debt,Public Debt,”Long Term Debt Outstanding Full Faith and Credit Other, NEC (Disc. 2005) (41X)”,,1
Long Term Debt Outstanding Nonguaranteed Water Utilities (Disc. 2005) (44A),Gross Public Debt,Public Debt,Long Term Debt Outstanding Nonguaranteed Water Utilities (Disc. 2005) (44A),,3
Long Term Debt Outstanding Nonguaranteed Electric Utilities (Disc. 2005) (44B),Gross Public Debt,Public Debt,Long Term Debt Outstanding Nonguaranteed Electric Utilities (Disc. 2005) (44B),,3vizulyMay 17, 2016 at 6:13 am #6157Hello Richard,
The code that determines the scale of the tree path’s and node circles can be found in the src/viz/weightedtree.js file at line 80:
var nodeRadius = function (node) { //Set max size/2 for root node. if (node.depth == 0) return nodeScale.range()[1]/2; nodeScale.domain([minValues[node.depth],maxValues[node.depth]]); return nodeScale(scope.value(node)); }
Hopefully this will point you in the right direction to troubleshoot your data or make other changes.
– Tom
richardMay 18, 2016 at 11:30 am #6159Thanks Tom for the reply. When I debugged it I saw node.depth=7 and 6, and the result is 153 and 3, respectively. nodeScale is calling a log function. I don’t understand why the consequences are so much different.
vizulyMay 18, 2016 at 12:56 pm #6160Hi Richard,
Without actually seeing your data in the debugger myself it is a little hard to be more specific on the results you are seeing.
To help clarify, the scales are being set at each “level” of the tree depth. So for a given level on the tree all values are being scaled with respect to each other. This is just a general overall approach, but you may want to modify for your data. For instance, you might want all children of a given tree branch to scale relative to their direct siblings (as opposed to all of their cousin nodes as well.)
My guess the issue are seeing is how the scale domain is being set. I would suggest comparing the actual node value to the domain min/max to see where it sets. Try experimenting with a linear scale for now, or some other absolute comparison to track down the issue.
This is the fun/challenge of data viz – tweaking the algorithms to best communicate what your data is saying.
– Tom
vizulyMay 18, 2016 at 12:56 pm #6161Hi Richard,
Without actually seeing your data in the debugger myself it is a little hard to be more specific on the results you are seeing.
To help clarify, the scales are being set at each “level” of the tree depth. So for a given level on the tree all values are being scaled with respect to each other. This is just a general overall approach, but you may want to modify for your data. For instance, you might want all children of a given tree branch to scale relative to their direct siblings (as opposed to all of their cousin nodes as well.)
My guess, is that the issue are seeing is how the scale domain is being set. I would suggest comparing the actual node value to the domain min/max to see how it compares. Try experimenting with a linear scale for now, or some other absolute comparison to track down the issue.
This is the fun/challenge of data viz – tweaking the algorithms to best communicate what your data is saying.
– Tom
RichardMay 18, 2016 at 8:14 pm #6162Hi Tom,
My data was actually in my original post. It was a simplified version of the example dataset. The first level only contains two branches, Pensions and Gross Public Debt. The add up values are 6 and 7, respectively. Obviously the min/max is 6/7. The circle of first branch is tiny compared to the second one, although their values are not much different. If I understand you correctly, the size of the min/max value is fixed, and whatever in between is linear. Is there a way to define the min/max value in the domain?
vizulyMay 19, 2016 at 6:30 am #6164Hi Richard,
The min/max values for the domain get calculated automatically as a convenience, but you can set them to what ever you feel works best in that routine I describe above.
I have not imported your data into the example to debug it directly, but from what you describe you have two values 6 and 7. One is the min, one is the max, so the the radius of the two respective child nodes would be one at the minimum of the range and one at the max (thus the small and big circles). You can adjust the code in the weightedtree.js to fit your needs by modifying the scale domain to a larger range, perhaps nodeScale.domain([0,10]), thus you will see a smaller difference in the node size.
Feel free to customize the weightedtree.js directly, that is the purpose of vizuly – to have a relatively simple architecture with code you can tweak to meet your needs. Don’t worry about breaking things.
– Tom
-
|
You must be logged in to reply to this topic.