rickshaw
rickshaw copied to clipboard
Workaround for inconsistent series data in unstacked area charts
After implementation of issue #121 it is still not easily possible to create such chart:
- on initialization,
validateSeriesandstackDataare being called beforegraph.renderer.unstack = truecan be set - this leads to the infamous
stacked series cannot have differing numbers of points: 2 vs 6; see Rickshaw.Series.fill()exception
Workaround I've found is to subclass the area chart renderer and use that:
Rickshaw.namespace('Rickshaw.Graph.Renderer.UnstackedArea');
Rickshaw.Graph.Renderer.UnstackedArea = Rickshaw.Class.create(Rickshaw.Graph.Renderer.Area, {
name: 'unstackedarea',
defaults: function($super) {
return Rickshaw.extend($super(), {
unstack: true,
fill: false,
stroke: false
});
}
} );
This works as unstack is already true when Rickshaw.Graph gets created.
Is there a more elegant solution?
At the moment, this is a good workaround. We've run into this from time to time too. We'll look into moving that validation to happen around the stacking rather than from within the graph constructor.