开发者

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

For values of 0, Flot likes to draw a flat line where 开发者_如何学Pythonthe bar would be. Is it possible to configure it to draw nothing?


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 }
};


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.


One solution: set the lineWidth of the bars to 0. This eliminates the border around the bars.

This comes at the cost of the nice visibility for small values Flot has. With borders, even when your chart has large values, 1 and 2 for example are distinct. Without borders, the small numbers can be hard to see, but this effect can be offset by sticking to darker fillColor values for your bars.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜