So half man mir herauszufinden, wie die y-Achse setzen reicht also dachte ich, Id versuchen und revanchieren, auch wenn es sechs Monate später ist
ich mit dem Quellcode aus dem Multi-Chart Beispiel
gestartet https://github.com/nvd3-community/nvd3/blob/gh-pages/examples/multiChart.html
Was Sie tun möchten, ist das Maximum Ihrer Daten zu berechnen und dann innerhalb der chart.yDomain1()
Funktion zu verwenden.
Beispiel Geige - https://jsfiddle.net/q72tzyaL/1/
var data = [{
"key": "key",
"type": "bar",
"values": [
{ x: 2012, y: 40 },
{ x: 2013, y: 36 }
]
}, {
"key": "key",
"type": "bar",
"values": [
{ x: 2012, y: 40 },
{ x: 2013, y: 36 }
]
}];
// each item is an object from the array with an array of values
// get the values that we need from that array and then get the max of that
function getMax(item) {
return d3.max(item.values.map(function(d){ return d.y; }));
}
// get the max. Pass in your data array and the function to get max
var max = d3.max(data, getMax);
nv.addGraph(function() {
var chart = nv.models.multiChart()
.margin({top: 30, right: 60, bottom: 50, left: 70})
.yDomain1([0, max]);
d3.select('#chart1 svg')
.datum(data)
.transition().duration(500).call(chart);
return chart;
});