Chart.js line chart set background color

后端 未结 4 1471
伪装坚强ぢ
伪装坚强ぢ 2020-12-18 22:14

I\'m working with Chart.js and want to convert a line chart to a PNG. The problem is that the image always downloads with a transparent background, which is not what I need.

4条回答
  •  情歌与酒
    2020-12-18 22:53

    Why don't you try to use css? A canvas element is just like a normal HTML element right? So you can either set it's background colour or set it's background to an image using css.

    $('#myChart').css('background-color', 'rgba(0, 0, 0, 0)'); // this worked for me but I'm guessing you can set a background image using css like you normally do.
    

提交回复
热议问题