rickshaw
rickshaw copied to clipboard
Scaled series render "null" as "0"
null should be preserved and treated as they are when not using scale - which is to create a gap in the line or terminate the line at the last non null point
var palette = new Rickshaw.Color.Palette();
var graph = new Rickshaw.Graph( {
element: document.getElementById("chart"),
renderer: 'line',
interpolation: 'cardinal',
series: [
{
data: [ { x: 0, y: 19 }, { x: 1, y: 30 }, { x: 2, y: 22 }, { x: 3, y: 29 }, { x: 4, y: 26 }, { x: 5, y: 35 } ],
name: 'new york',
color: palette.color(),
scale:d3.scale.linear().domain([1, 50]).nice()
}, {
data: [ { x: 0, y: 49 }, { x: 1, y: 35 }, { x: 2, y: 32 }, { x: 3, y: 38 }, { x: 4, y: 37 } ],
name: 'boston',
color: palette.color(),
scale:d3.scale.linear().domain([1, 50]).nice()
}, {
data: [ { x: 0, y: 19 }, { x: 1, y: 22 }, { x: 2, y: 10 }, { x: 4, y: null }, { x: 5, y: 17 } ],
name: 'los angeles',
color: palette.color(),
scale:d3.scale.linear().domain([1, 50]).nice()
}, {
data: [ { x: 1, y: 9 }, { x: 2, y: 3 }, { x: 3, y: 50 }, { x: 4, y: null } ],
name: 'san francisco',
color: palette.color(),
scale:d3.scale.linear().domain([1, 50]).nice()
}
]
} );
graph.render();
new Rickshaw.Graph.HoverDetail({ graph: graph });
in Rickshaw.Graph.stackData
change
seriesData.forEach( function(d) {
d.y = series.scale(d.y);
} );
to
seriesData.forEach( function(d) {
if (d.y != null)
d.y = series.scale(d.y);
} );
https://github.com/pstanton/rickshaw/commit/2bd7ceabdffc35b96e4a51b1a9fd22703ffb6c8b