图表Echart组件封装
<template>
<div>
<div class="charts-box" :id="idCode" :style="{width: width, height: height}"></div>
</div>
</template>
import * as echarts from 'echarts/lib/echarts'
import 'echarts/lib/component/tooltip';
import 'echarts/lib/component/title';
import 'echarts/lib/component/legend';
// 柱状图
import 'echarts/lib/chart/bar';
import {
DataZoomComponent, GridComponent} from 'echarts/components';
echarts.use([DataZoomComponent, GridComponent]);
// 饼状图
import 'echarts/lib/chart/pie';
// 仪表盘
import 'echarts/lib/chart/gauge';
//折线图
import 'echarts/lib/chart/line'
export default {
name: "chart",
props: {
type: {
type: String
},
value: {
type: [Object, Array, Number]
},
width: {
type: String,
default: '100%',
required: true
},
height: {
type: String,
default: '25rem',
required: true
},
chartId: {
type: String
},
title: {
type: String
}
},
data() {
return {
chartType: null,
chartValue: null,
chartTitle: '',
myChart: null,
}
},
mounted() {
this.init()
},
methods: {
init() {
let chart = document.getElementById(this.idCode