I have an issue with d3.max() returning a number 10% higher than the actual largest number in the set.
I'm using d3js and c3js.
CSV
date,count
2003-01-10,4
2002-01-14,5
2001-01-09,6
JavaScript
values: function(d){
var tickNumber = 3, //Set tick number
tickValues = [],
increment = d3.max(d) / tickNumber;
for (i = 1; i <= tickNumber; i++){
tickValues.push(
numeral(increment * i).format('0')
);
console.log(d3.max(d));
// returns 6.6, not 6
};
return tickValues;
}
I've made this work for me by changing this line
increment = d3.max(d) / tickNumber;
To
increment = (d3.max(d)-(d3.max(d)/10)) / tickNumber;
It works but it's a hack and I'm not really satisfied with it. Can you please help me understand why d3.max(d) returns 6.6, not 6?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire