NPashaP / Viz

BSD 3-Clause "New" or "Revised" License
106 stars 39 forks source link

How to export var data values #11

Closed CCC416 closed 7 years ago

CCC416 commented 7 years ago

Hello, my English is not good

I first used D3.JS, I find it very interesting

I tried using "biPartite" and would like to ask

How do I use the output percentage instead of displaying the value in "var data"?

I tried to modify ".text (function (d) {return d3.format (d.percent)})"

But display object.

NPashaP commented 7 years ago

I am not sure what you mean by the "var data", could you post an example in JSFiddle?

Does the following example do what you want to do? it shows the formatted percentage values: http://bl.ocks.org/NPashaP/3ba0031d3d555afca4713e5264455025

CCC416 commented 7 years ago

Hello, please refer to the picture, I hope the figures are displayed directly, rather than in percentage http://imgur.com/a/fTipG

Please refer to line 97-101 https://jsfiddle.net/awk5az2g/

NPashaP commented 7 years ago

I see, so you want to display the value and not the percentage?

The bound data has a value attribute that you can use.

In your example, lines 96-97 should be (remove data bind and in text function return d.value )

    .attr("y",d=>+6)
    .text(function(d){ return d.value; })

and lines 107 and 115 should be

    .text(function(s){ return s.value;});

I hope that helps.