javascript - writing a custom function inside d3.json -


i trying add numbers tag. using d3.json reference file. mixing jquery in , think not going well.

how should this?

once sum mathematical operations on reduce value of consumption_gj_ can pass radius circle this.

here how code looks like:

var sum = 0; //adding values     function radiusdata(d){         +sum = d.consumption_gj_;         alert(sum)     }      //here trying append total div      $('.test').append(sum);     

right doing d.consumption_gj_ / 10000 come reasonable number not working out.

here fiddle http://jsfiddle.net/sghoush1/vn7mf/9/

you need loop iterate on values , add them sum:

data.foreach(function(d) { sum += +d.consumption_gj_; }); 

modified jsfiddle here.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -