Search code examples
javascriptchartsbackground-colorlightningchartspider-chart

How can we change spider chart background color?


Refer this image to see what i am looking at:

[1]

With this code :

const colors = [ColorRGBA(0, 255, 125, 0), ColorRGBA(255, 125, 0, 0)]
const fillStyles = colors.map((color) => new SolidFill({ color: color.setA(150) }))

const chart = db.createSpiderChart({
  columnIndex: 1,
  rowIndex: 0,
  columnSpan: 1,
  rowSpan: 2
})
  .setTitle('Spider chart')
  .setBackgroundFillStyle(fillStyles[0])

I am getting this result :

[2]


Solution

  • You can change the background color of the chart by using the method setChartBackgroundFillStyle with the wanted FillStyle

    For example:

    const colors = [ColorRGBA(0, 255, 125, 0), ColorRGBA(255, 125, 0, 0)]
    const fillStyles = colors.map((color) => new SolidFill({ color: color.setA(150) }))
    
    const chart = db.createSpiderChart({
      columnIndex: 1,
      rowIndex: 0,
      columnSpan: 1,
      rowSpan: 2
    })
      .setTitle('Spider chart')
      .setBackgroundFillStyle(fillStyles[0])
      .setChartBackgroundFillStyle(fillStyles[1])