Echarts.js的简单封装
- 视图大小响应式变化
- 数据响应刷新
npm install vsechart echarts
<template>
<div id="app">
<vs-echart style="height:40vh" :option="option"></vs-echart>
<vs-echart style="height:40vh" :option="option" theme="dark" svg></vs-echart>
</div>
</template>
<script>
import VsEchart from "vsechart";
export default {
components: { VsEchart },
data: function () {
return {
//option的数据格式和Echart.js一致
option: {
title: {
text: "ECharts",
},
tooltip: {},
xAxis: {
data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"],
},
yAxis: {},
series: [
{
name: "销量",
type: "bar",
data: [15, 20, 36, 10, 10, 20],
},
],
},
};
},
};
</script>
Methods | Description |
---|---|
getInstance | return echarts instance |
version:1.0.3 使用vue2 eschrts 4.x
version:1.0.4 升级vue3
version:1.0.5 升级eschrts 5.x