-
tnJuly 1, 2016 at 5:14 am #6294
Hi Visuly,
If I am visualizing positive and negative flows, how can I account for the negative ones? The function prepData on line 69 in the weightedtree_test.js removes all negative numbers. Is it possible to include the numbers if the total in the rollup is greater than 0? Any thoughts or suggestions would be helpful.
Thank you,
TNtnJuly 1, 2016 at 6:12 am #6298I took out the code that removes the negative numbers and pushed all the numbers. Now, negative numbers display as greyed out circles. Any thoughts on how I would go about using the absolute values of the negative numbers but displaying them in a different color? I.E. green for positive and red for negative?
Thank you,
TNvizulyJuly 1, 2016 at 6:12 am #6299Hello TN,
That is a good question. The reason why negative numbers are being removed as it would not make sense to “visually” display a negative number with the tree – as you can represent a tree branch or node with a thickness or diameter of less than 0.
But, I understand that you want that data to roll up into aggregate sums.
I suggest removing that line in the
prepData()
function and keeping the negative numbers in the raw data. Then in theweightedtree.js updateNode()
function going through and removing any tree nodes that have a value of 0 or less. This will allow the aggregation to occur while still not trying to display negative values.– Tom
vizulyJuly 1, 2016 at 6:15 am #6300Hello TN,
Looks like our forum posts crossed paths.
In the theme file you could select all the nodes and look at the value of the node.datum to determine how you might want to style it. You would modify the
applyTheme()
function and instead of using the skin value for the fill, put your special conditional logic.– Tom
tnJuly 1, 2016 at 7:04 am #6301Ok thank you Tom.
I like how the visualization is handling the opacity of the negative nodes. If the node is negative it makes it more opaque. And I see how to change the opacity and colors in the theme/weightedtree.js
I am wondering about how to change the size of the nodes so that the radius is based on the absolute value of the value of the node. Currently the smaller the negative number, the smaller the node. I would like it so the more negative the number, the node would become larger. Does that make sense?
Looking at the radius code in viz/weightedtree.js:
//Used to calc our node radius for each node based on min/max values per depth. 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)); }
How would I tell it to ignore the negative and take the absolute value of the negative for size? Perhaps this is not the right piece of code to be modifying. So far my attempts have not been fruitful.
Thank you,
TNtnJuly 1, 2016 at 7:06 am #6302Also, if I successfully modify the radius size for the negative values to be absolute values. Will it automatically adjust the thickness of the connecting line?
vizulyJuly 1, 2016 at 7:21 am #6303Hi TN,
You can add this to the top of that function:
if (scope.value(node)) < 0) { return myAbsoluteValue; } And yes, the links thickness will respect your new custom value. - Tom
tnJuly 1, 2016 at 7:52 am #6304Hi Vizuly,
Thank you for all the help. I was able to make the change. I also had to change the maxValues and minValues calculations to consider absolute values so the scale would not only account for account for absolute values and no negatives ones.
Thank you again,
TN -
|
You must be logged in to reply to this topic.