生成图片

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// 将图表保存为图片
var dataURL = echarts.getDataURL({
pixelRatio: 1, // 图片的分辨率,默认为 1
//backgroundColor: '#fff' // 图片的背景颜色,默认为透明
});

// 把图片添加到echarts中
var img = new Image();
img.src = dataURL
img.onload = ()=>{
console.log(dataURL);
this.echartsMap.setOption({
graphic: [
{
type: 'image',
id: 'logo', // 图片的唯一标识符
left: 'center',
top: 'middle',
coordinateSystem: "geo",
z: 10,
bounding: 'all',
style: {
image: dataURL, // 替换为您的 Base64 图片数据
width: window.innerWidth,
height: window.innerHeight
}
}
]
})
}