Reputation: 41
My Cumulative Line Chart is not building the yScale correct.
Given the data to be build the chart:
var data = [{
key: "Page view",
values: [
["2013-07-01 00:00:00", 1],
["2013-08-01 00:00:00", 17],
["2013-09-01 00:00:00", 5],
["2013-10-01 00:00:00", 13]
]
}];
The max value that should display 17 on the yScale it's displaying 8 as you can see here:
That is my code:
nv.addGraph(function () {
var chart;
chart = nv.models.cumulativeLineChart()
.x(function(d) { return moment(d[0]) })
.y(function(d) { return d[1] })
.color(d3.scale.category10().range())
.transitionDuration(300)
.showControls(false);
chart.xAxis
.tickFormat(function (d) {
return d3.time.format('%d/%m/%y')(new Date(d))
});
chart.xScale(d3.time.scale());
d3.select('#chart svg')
.datum(data)
.call(chart);
nv.utils.windowResize(chart.update);
return chart;
});
https://gist.github.com/lemanchester/9919615
I've tried to use:
chart.yScale().domain([0, 50]);
or/and
chart.forceY ([0, 50])
Upvotes: 3
Views: 1496
Reputation: 41
Problem Solved!
It's that Cumulative Line Chart it has to starts with 0 on the Y axis
var data = [{
key: "Page view",
values: [
["2013-06-01 00:00:00", 0],
["2013-07-01 00:00:00", 1],
["2013-08-01 00:00:00", 17],
["2013-09-01 00:00:00", 5],
["2013-10-01 00:00:00", 13]
]
}];
As you can see:
PS. Thanks Bob
Upvotes: 1