简体   繁体   English

是否可以在vega或vega-lite中为绘图添加背景图像?

[英]Is it possible to add a background image to a plot in vega or vega-lite?

I see from https://vega.github.io/vega-lite/docs/config.html that it is possible to change the background color. 我从https://vega.github.io/vega-lite/docs/config.html看到可以更改背景颜色。 But i don't see any docs for adding an underlay background image. 但是我看不到任何用于添加参考底图的文档。

vega-lite creates a canvas element. vega-lite创建一个canvas元素。

So adding a background image is explained in a question about how to add a background to a canvas element. 因此,在有关如何向画布元素添加背景的问题中解释了添加背景图像。

HTML5 Canvas background image HTML5 Canvas背景图片

But you can just do it with css: 但是您可以使用CSS来做到这一点:

canvas {
  background: url("my_background.png");
}

This is just like any other background image css. 就像其他任何背景图片CSS一样。

https://developer.mozilla.org/en-US/docs/Web/CSS/background-image https://developer.mozilla.org/en-US/docs/Web/CSS/background-image

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM