Sunday, 15 April 2012

javascript - controlling which data to sort in d3.js -



javascript - controlling which data to sort in d3.js -

each object in json array has 2 properties: name & age. sort info in ascending order based on age. however, don't know how tell code sort info based on age only. below code have been using. when run code, seems utilize name property, comes first.

var sortsquares = function() { svg.selectall("rect") .sort(function(a, b) { homecoming d3.ascending(a, b) }) .transition() ..... .....

in order sort attributes of data, need tell d3.ascending attributes for. seek this:

.sort(function(a, b) { homecoming d3.ascending(a.age, b.age) })

javascript sorting d3.js

No comments:

Post a Comment