nrainer February 2016

Is it possible to stack only some data series?

I have a chart with 3 stacked lines. The area below each line is filled. Now I want to add two further non-stacked lines.

Currently, I have

this.flotOptions.series.stack = true;

and use another y-axis (with the same range) for the two new lines. However, they the all lines still are stacked.

Is it possible to specify which data series shall be stacked?

Answers


jmbucknall February 2016

Of course you can. Since you provided no code for us to look at (not a good idea, in my view), I'm going to have to guess you are just using an array of data points for a series and passing an array of those series to $.plot. Flow actually allows for an array of series objects, of which only one property is the data, the other properties allow you to configure the plot for that series in any way you like.

For example, here's a jsFiddle that shows how it can be done. The relevant code is

$.plot("#chart", [
    { data: series1, lines: {fill: true}, label: "one" }, 
    { data: series2, lines: {fill: true}, label: "two" }, 
    { data: series3, lines: {fill: false}, label: "three" }, 
    { data: series4, lines: {fill: false}, label: "four" }
]);

Post Status

Asked in February 2016
Viewed 1,674 times
Voted 14
Answered 1 times

Search




Leave an answer