Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to hide zero-height bars in a bar chart?

For values of 0, Flot likes to draw a flat line where the bar would be. Is it possible to configure it to draw nothing?

like image 528
mph Avatar asked Jun 29 '11 19:06

mph


2 Answers

In my application I solved this issue by setting yaxis min to a value greater than 0 and less than the resolution I was working with. Borders visible, flat line hidden.

var options = {
series: {
    stack: 0,
    lines: { show: false, fill: true, steps: false },       
            bars: { show: true, barWidth: 0.6 } 
        },
    xaxis: {
        mode: "time",
        timeformat: "%H:%M"
    },
    yaxis: { 
        min: 0.5 
    },
    selection: { mode: "x" },
    grid: { hoverable: true }
};
like image 124
Ten Avatar answered Oct 05 '22 05:10

Ten


You can set the value to null when it's zero and that will prevent it from showing and allow you to keep borders around other bars.

like image 22
Justin Avatar answered Oct 05 '22 05:10

Justin