How can i add an image as background in Chartjs?

北城以北 提交于 2020-02-03 22:02:55

问题


I am using chart.js lib on a programmable device i need to add an image as background to my chart, if that is not possible how can i change background color to black?. I cannot use Jquery as it is not supported by the Platform.

Thank you


回答1:


You can style the canvas element. Something like this will work

canvas {
    background-color: black;
}

Fiddle - https://jsfiddle.net/w1yhp03h/




回答2:


Thank you!

I didn't think to CSS, i added an image too in a similar way

canvas {
   background-image: url(backgroundimage.jpg);
}


来源:https://stackoverflow.com/questions/30754136/how-can-i-add-an-image-as-background-in-chartjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!