Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fill a flot line graph without opacity?

How can i fill a flot line graph with no opacity?

lines: {
    show: true,
    fill: true,
    lineWidth:1
   }
like image 379
Sweetz Avatar asked May 20 '13 10:05

Sweetz


3 Answers

I think you've mixed-up the terms 'opacity' and 'transparency'. It sounds like what you actually want is no transparency, i.e. a solid color that doesn't allow anything in the background to show through.

To control transparency in Flot, change the 'fill' option from 'true' to a number from 0 to 1, where 0 is fully-transparent and 1 is fully opaque. See customizing the data series in the API docs for more info.

like image 192
DNS Avatar answered Nov 12 '22 21:11

DNS


Flot documentation agrees with DNS's answer, but at least in current stable version (0.8.1) I couldn't make it work.

Checking the Flot source I came up with this solution:

'bars': {
            show: true,
            fill: 1.0,
            fillColor: 'rgba(255,230,230,0.5)',
            lineWidth: 1,
        }

I didn't test it for lines, but it should work with them too.

like image 5
johndodo Avatar answered Nov 12 '22 22:11

johndodo


If you're using flotr2, you'll notice that none of these solutions work. Instead, try:

lines: {
  fillOpacity:1.0,
  show: true,
  fill: true,
  lineWidth:1
}
like image 1
William Neely Avatar answered Nov 12 '22 21:11

William Neely