How to fill a flot line graph without opacity?
Asked Answered
P

3

7

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

lines: {
    show: true,
    fill: true,
    lineWidth:1
   }
Pansypant answered 20/5, 2013 at 10:51 Comment(2)
'No opacity' means 'completely transparent', i.e. just fill:false. Is that what you want, or do you mean something else?Galton
i dont want opacity, it should be filled with color (excluding opacity)Pansypant
G
15

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.

Galton answered 20/5, 2013 at 13:28 Comment(1)
Thank You!!... Din't know that part of the graphPansypant
M
5

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.

Minter answered 17/10, 2013 at 10:3 Comment(0)
I
1

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
}
Ide answered 19/2, 2015 at 22:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.