fill

Configuration Structure

fill: {
colors: any[],
opacity: number | number[],
type: string | string[],
gradient: { ... },
shade: string,
type: string,
shadeIntensity: number,
gradientToColors: string[],
inverseColors: boolean,
opacityFrom: number | number[],
opacityTo: number | number[],
stops: number[],
colorStops: Array,
image: { ... },
src: string | string[],
width: number,
height: number,
pattern: { ... },
style: string | string[],
width: number,
height: number,
strokeWidth: number,
}

colors

Default: undefined

Colors to fill the svg paths. Each index in the array corresponds to the series-index. Example


fill: {
  colors: ['#1A73E8', '#B32824']
}

Alternatively, if you are rendering a bar/pie/donut/radialBar chart, you can pass a function which returns color based on value.


fill: {
  colors: [function({ value, seriesIndex, w }) {
    if(value < 55) {
        return '#7E36AF'
    } else if (value >= 55 && value < 80) {
        return '#164666'
    } else {
        return '#D9534F'
    }
  }]
}

opacity

Default: 0.85

Opacity of the fill attribute.

type

Default: 'solid'

Whether to fill the paths with solid colors or gradient.
Available options

  • solid
  • gradient
  • pattern
  • image

In a multi-series chart, you can pass an array to allow a combination of fill types like this


fill: {
  type: 'gradient' 
}
/* OR */
fill: {
  type: ['solid', 'gradient']
}

gradient

shade

fill.gradient.shade
Default: 'dark'

Available options for gradient shade

  • light
  • dark

type

Default: 'solid'

Available options for gradient type

  • horizontal
  • vertical
  • diagonal1
  • diagonal2

shadeIntensity

fill.gradient.shadeIntensity
Default: 0.5

Intensity of the gradient shade.
Accepts from 0 to 1

gradientToColors

fill.gradient.gradientToColors
Default: undefined

Optional colors that ends the gradient to.
The main colors array becomes the gradientFromColors and this array becomes the end colors of the gradient. Each index in the array corresponds to the series-index.

inverseColors

fill.gradient.inverseColors
Default: true

Inverse the start and end colors of the gradient.

opacityFrom

fill.gradient.opacityFrom
Default: 1

Start color's opacity. If you want different opacity for different series, you can pass an array of numbers. For eg., opacityFrom: [0.2, 0.8]

opacityTo

fill.gradient.opacityTo
Default: 1

End color's opacity

stops

fill.gradient.stops
Default: [0, 50, 100]

Stops defines the ramp of colors to use on a gradient

colorStops

fill.gradient.colorStops
Default: []

Override everything and define your own stops with unlimited color stops.


[ 
  [
    {
      offset: 0,
      color: '#eee',
      opacity: 1
    },
    {
      offset: 0.6,
      color: 'green',
      opacity: 50
    },
    {
      offset: 100,
      color: 'red',
      opacity: 1
    }
  ],
  [
    {
      offset: 0,
      color: '#999',
      opacity: 1
    },
    {
      offset: 50,
      color: 'blue',
      opacity: 0.75
    },
    {
      offset: 100,
      color: '#ddd',
      opacity: 1
    }
  ]
]

Each index in the above code corresponds to a series.
Codepen Example

image

src

fill.image.src
Default: []

src accepts an array of image paths which will correspond to each series.

width

fill.image.width
Default: undefined

Width of each image for all the series

height

fill.image.height
Default: undefined

Height of each image for all the series

pattern

style

fill.pattern.style
Default: 'squares'

Available pattern styles

  • verticalLines
  • horizontalLines
  • slantedLines
  • squares
  • circles

width

fill.pattern.width
Default: 6

Pattern width which will be repeated at this interval

height

fill.pattern.height
Default: 6

Pattern height which will be repeated at this interval

strokeWidth

fill.pattern.strokeWidth
Default: 2

Pattern lines width indicates the thickness of the stroke of pattern.