Pratyush Kumar Mishra
Pratyush Kumar Mishra

Reputation: 77

implementing threshold for bar graphs using flot api

i am using flot to plot a graph. i want to implement the functionality such that i am able to highlight a 10% growth in my graph showing in a different color other than the color i am using now. the code i am using is :

var options_blue = {
    series: {
        color: 'blue',
        threshold: { above: 5, color: 'green' },
        bars: { show: true, barWidth: 20 * 20 }
    },
    xaxis: { show: false, min: 1 },
    yaxis: { show: false, min: 1, max: max_value }
};

var options_red = {
    series: {
        color: '#ff0000',
        threshold: { above: 10, color:'green' },    
        bars: { show: true, barWidth: 20 * 20 }
    },
    threshold: { above: 5, color: "yellow" },
    xaxis: { show: false, min: 1 },
    yaxis: { show: false, min: 5, max: max_value }
};

I am using the jquery.flot.threshold.js, but there is no change in the graph colors beyond the threshold.

Upvotes: 1

Views: 1353

Answers (1)

DNS
DNS

Reputation: 38189

You're using 'above', but the threshold plugin only supports 'below'. So you just need to swap your series and threshold colors, and use 'below' instead.

Also note that in your options_red, you have a second threshold options outside of the series options. The threshold plugin only looks for options within the series options, so that second one will get ignored.

Upvotes: 3

Related Questions