<template>
<div class="container">
<h1>Echarts图表</h1>
<div id="myChart" style="width:1500px;height:500px;margin:auto;"></div>
<img src="../../assets/img/fangxiang-left.png"></img>
<img :src="imgsrc"></img>
</div>
</template>
<script setup lang="ts">
import * as echarts from 'echarts'
import { onMounted, ref } from "vue";
import aj1 from '../../assets/img/fangxiang-left.png';
let imgsrc = ref('')
imgsrc.value = aj1
onMounted(() => { // 需要在页面加载完毕后展示图表,这里使用Vue3的组合式生命周期钩子 onMounted()
let myChart = echarts.init(document.getElementById("myChart"));
// 设置图表配置项,可以直接从Echarts的示例中,将配置项复制下来后放入下列的myChart.setOption()中实现图表的样式更换
myChart.setOption({
title: {
text: 'Stacked Area Chart'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
toolbox: {
feature: {
saveAsImage: {}
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
scale: true
},
yAxis: {
scale: true
},
series: [
{
type: 'effectScatter',
//symbol:'image://./../../assets/img/fangxiang-down.png',
symbol: 'image://' + aj1,
symbolSize: 20,
data: [
[112.7, 205.2],
[123.4, 142]
]
},
]
});
window.onresize = function () { // 自适应大小
myChart.resize();
};
});
</script>
<style scoped>
</style>
Vue3下Echarts的scatter使用本地图片
于 2025-01-23 16:21:13 首次发布