Removed workaroudn with the data on the stacked, now it uses the data as is, also fixed issue now stacked will always hav 0 min

master-patched
Bob Monteverde 12 years ago
parent 91215e2d15
commit 1880f11775

@ -49,7 +49,7 @@ nv.addGraph({
var width = $(window).width() - 20,
height = $(window).height() - 20;
height = $(window).height() - 40;
var chart = nv.models.stackedAreaWithLegend()
.width(width)
@ -95,7 +95,7 @@ nv.addGraph({
$(window).resize(function() {
var width = $(window).width() - 20,
height = $(window).height() - 20,
height = $(window).height() - 40,
margin = graph.margin();

@ -229,3 +229,16 @@ text {
fill-opacity: 1;
}
*/
/**********
* Stacked Area
*/
.d3stackedarea path {
fill-opacity: .75;
stroke-opacity: .75;
}

@ -27,25 +27,22 @@ nv.models.stackedArea = function() {
// Need to leave data alone to switch between stacked, stream, and expanded
var dataCopy = JSON.parse(JSON.stringify(data));
//log(dataCopy);
dataCopy = dataCopy.map(function(series) { return series.values })
//compute the data based on offset and order (calc's y0 for every point)
//dataCopy = d3.layout.stack().offset(offset).order(order).values(function(d){ return d.values })(dataCopy);
dataCopy = d3.layout.stack().offset(offset).order(order)(dataCopy);
dataCopy = d3.layout.stack().offset(offset).order(order).values(function(d){ return d.values })(dataCopy);
var mx = dataCopy[0].length - 1, // assumes that all layers have same # of samples & that there is at least one layer
var mx = dataCopy[0].values.length - 1, // assumes that all layers have same # of samples & that there is at least one layer
my = d3.max(dataCopy, function(d) {
return d3.max(d, function(d) {
return d3.max(d.values, function(d) {
return d.y0 + d.y;
});
});
// Select the wrapper g, if it exists.
var wrap = d3.select(this).selectAll('g.d3stream').data([dataCopy]);
var wrap = d3.select(this).selectAll('g.d3stackedarea').data([dataCopy]);
// Create the skeletal chart on first load.
var gEnter = wrap.enter().append('g').attr('class', 'd3stream').append('g');
var gEnter = wrap.enter().append('g').attr('class', 'd3stackedarea').append('g');
var g = wrap.select('g')
@ -68,18 +65,15 @@ nv.models.stackedArea = function() {
var path = g.selectAll('path')
.data(function(d) { return d });
//.data(dataCopy);
path.enter().append('path');
d3.transition(path.exit())
.attr('d', zeroArea)
.attr('d', function(d,i) { return zeroArea(d.values,i) })
.remove();
path
.style('fill-opacity', .75)
.style('stroke-opacity', .75)
.style('fill', function(d,i){ return color[i % 10] })
.style('stroke', function(d,i){ return color[i % 10] });
d3.transition(path)
.attr('d', area);
.attr('d', function(d,i) { return area(d.values,i) })
});

@ -41,9 +41,8 @@ nv.models.stackedAreaWithLegend = function() {
x .domain(d3.extent(d3.merge(series), getX ))
.range([0, width - margin.left - margin.right]);
//TODO: remove if stream
y .domain(stacked.offset() == 'zero' ?
d3.extent(d3.merge(series), getY ) :
y .domain(stacked.offset() == 'zero' ?
[0, d3.max(d3.merge(series), getY )] :
[0, 1] // 0 - 100%
)
.range([height - margin.top - margin.bottom, 0]);

Loading…
Cancel
Save