javascript - Converting stack() call from v3 to v4 -


i've had modified version of mike bostock's animated stack (seen here) working awhile now. on advice of others here i've been trying convert of d3 version 3 charts version 4, compatible moving forward.

unfortunately, can't seem figure out why code segment won't compile. it's throwing "uncaught typeerror". i've been told has newer version wanting array passed stack().

var stack = d3.stack()     .values(data, function(d) { return d.values; })     .x(function(d) { return d.date; })     .y(function(d) { return d.value; })     .out(function(d, y0) { d.valueoffset = y0; }); 

how should done correctly under d3 version 4?

edit: found this link support request on github, seems no 1 on there explain how convert chart either.

d3 v4 d3.stack() constructor don't have values, x, y , out chaining methods. it's syntax 3rd version. check docs here. @ this example of stacked bar chart. note, d3.stack uses in example:

...   g.append("g")    .selectall("g")    .data(d3.stack().keys(keys)(data))    .enter().append("g") ... 

update: rewrote "bl.ocks" mike bostock mentioned in question d3 v4. @ fiddle - https://jsfiddle.net/levvsha/vrbq7ebz/


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -