| | |
| | | components: {}, |
| | | data() { |
| | | //这里存放数据 |
| | | return {}; |
| | | return { myChart }; |
| | | }, |
| | | mounted() { |
| | | this.lineChart(); |
| | | this.$bus.$on('resizeEchart', (res) => { |
| | | this.myChart.resize(); |
| | | }); |
| | | }, |
| | | //方法集合 |
| | | methods: { |
| | | lineChart() { |
| | | let option = { |
| | | title: { |
| | | text: "资金使用和预算对比", |
| | | text: '资金使用和预算对比', |
| | | textStyle: { |
| | | color: "#fff", |
| | | color: '#fff', |
| | | }, |
| | | }, |
| | | tooltip: { |
| | | trigger: "axis", |
| | | trigger: 'axis', |
| | | axisPointer: { |
| | | type: "shadow", |
| | | type: 'shadow', |
| | | }, |
| | | }, |
| | | legend: { |
| | | data: ["剩余金额", "已使用金额", "预算金额"], |
| | | data: ['剩余金额', '已使用金额', '预算金额'], |
| | | }, |
| | | grid: { |
| | | left: "3%", |
| | | right: "4%", |
| | | bottom: "3%", |
| | | left: '3%', |
| | | right: '4%', |
| | | bottom: '3%', |
| | | containLabel: true, |
| | | }, |
| | | xAxis: [ |
| | | { |
| | | type: "value", |
| | | type: 'value', |
| | | axisLabel: { |
| | | show: true, |
| | | textStyle: { |
| | | color: "#fff", |
| | | color: '#fff', |
| | | }, |
| | | }, |
| | | }, |
| | | ], |
| | | yAxis: [ |
| | | { |
| | | type: "category", |
| | | type: 'category', |
| | | axisTick: { |
| | | show: false, |
| | | }, |
| | | data: ["A2", "A3", "A4", "A5", "A6", "A7"], |
| | | data: ['A2', 'A3', 'A4', 'A5', 'A6', 'A7'], |
| | | axisLabel: { |
| | | show: true, |
| | | textStyle: { |
| | | color: "#fff", |
| | | color: '#fff', |
| | | }, |
| | | }, |
| | | }, |
| | | ], |
| | | series: [ |
| | | { |
| | | name: "剩余", |
| | | type: "bar", |
| | | name: '剩余', |
| | | type: 'bar', |
| | | label: { |
| | | show: true, |
| | | position: "inside", |
| | | position: 'inside', |
| | | }, |
| | | emphasis: { |
| | | focus: "series", |
| | | focus: 'series', |
| | | }, |
| | | data: [1200, 1440, 240, 350, 300, 630], |
| | | }, |
| | | { |
| | | name: "预算金额(万元)", |
| | | type: "bar", |
| | | stack: "Total", |
| | | name: '预算金额(万元)', |
| | | type: 'bar', |
| | | stack: 'Total', |
| | | label: { |
| | | show: true, |
| | | }, |
| | | emphasis: { |
| | | focus: "series", |
| | | focus: 'series', |
| | | }, |
| | | data: [2000, 1800, 800, 1000, 600, 700], |
| | | }, |
| | | { |
| | | name: "已使用金额(万元)", |
| | | type: "bar", |
| | | stack: "Total", |
| | | name: '已使用金额(万元)', |
| | | type: 'bar', |
| | | stack: 'Total', |
| | | label: { |
| | | show: true, |
| | | position: "left", |
| | | position: 'left', |
| | | }, |
| | | emphasis: { |
| | | focus: "series", |
| | | focus: 'series', |
| | | }, |
| | | data: [-800, -360, -560, -650, -300, -70], |
| | | }, |
| | | ], |
| | | }; |
| | | let myChart = this.$echarts.init(document.getElementById("echart45")); |
| | | myChart.setOption(option); |
| | | window.addEventListener("resize", function () { |
| | | myChart.resize(); |
| | | this.myChart = this.$echarts.init(document.getElementById('echart45')); |
| | | this.myChart.setOption(option); |
| | | window.addEventListener('resize', function () { |
| | | this.myChart.resize(); |
| | | }); |
| | | }, |
| | | }, |