option = {
graphic: [
{
type: 'text',
left: 10,
top: 10,
z: 100,
style: {
text: 'Hello, ECharts!',
fill: 'red',
font: 'bold 16px Arial'
}
},
{
type: 'rect',
left: 10,
top: 40,
z: 100,
shape: {
width: 100,
height: 50
},
style: {
fill: 'blue',
stroke: 'green',
lineWidth: 2
}
},
// 可以添加更多的 graphic 元素...
],
series: [
{
type: 'bar',
data: [10, 20, 15, 25, 30, 18],
// 其他 series 配置项...
}
],
// 其他配置项...
};
在上面的例子中,graphic 数组中包含两个图形元素,一个是文本元素,另一个是矩形元素。type 属性指定了图形元素的类型,可以是 'text'、'rect',也可以是其他类型,如 'image'、'circle' 等。
每个图形元素都可以通过具体的配置项来设置位置、样式等属性。例如,left 和 top 分别表示元素的左上角坐标,z 表示元素的层级关系,style 中的属性则表示元素的样式,如文本的颜色、字体,矩形的填充色、边框色等。
你可以根据实际需求添加更多的 graphic 元素,以实现更复杂的自定义图形。在 ECharts 的官方文档中,你可以找到更多有关 graphic 组件的配置选项和示例:[ECharts Graphic](https://echarts.apache.org/examples/en/editor.html?c=doc-example/graphic)。
转载请注明出处:http://www.zyzy.cn/article/detail/5377/ECharts