| | |
| | | <script> |
| | | import * as echarts from 'echarts'; |
| | | let lineChart = null; |
| | | let observer = null; |
| | | export default { |
| | | name: 'DataChart', |
| | | data() { |
| | |
| | | }, |
| | | { |
| | | name: 'XX运维公司3', |
| | | state: { '1月': 1000, '2月': 2131, '3月': 1233, '4月': 2132, '5月': 3211,'6月': 1321 }, |
| | | state: { '1月': 1000, '2月': 2131, '3月': 1233, '4月': 2132, '5月': 3211, '6月': 1321 }, |
| | | state2: { '1月': 123, '2月': 213, '3月': 123, '4月': 23, '5月': 123 } |
| | | }, |
| | | { |
| | |
| | | initChart() { |
| | | const option = { |
| | | legend: { |
| | | right: '2%', |
| | | top: '5%', |
| | | right: 'right', |
| | | top: 'top', |
| | | orient: "vertical", |
| | | icon: 'rect', |
| | | data: [ |
| | | { |
| | | |
| | | name: '正常数', |
| | | itemStyle: { |
| | | color: 'rgba(62, 144, 247, 1)' |
| | |
| | | } |
| | | }, |
| | | |
| | | // 过滤 |
| | | filterData() { |
| | | |
| | | // 监听变化 |
| | | observe() { |
| | | if (!observer) { |
| | | observer = new ResizeObserver(entries => { |
| | | this.handleResize(); |
| | | }) |
| | | } |
| | | observer.observe(this.$refs.chartContent); |
| | | }, |
| | | // 窗口变换 |
| | | handleResize() { |
| | | if (lineChart) { |
| | | lineChart.resize() |
| | | lineChart.resize(); |
| | | } |
| | | } |
| | | |
| | |
| | | this.company = this.acitveData.name; |
| | | lineChart = echarts.init(this.$refs.chartContent); |
| | | this.initChart(); |
| | | window.addEventListener('resize', this.handleResize) |
| | | this.observe(); |
| | | }, |
| | | beforeDestroy() { |
| | | window.removeEventListener('resize', this.handleResize) |
| | | if (lineChart) { |
| | | lineChart.dispose(); |
| | | observer.unobserve(this.$refs.chartContent); |
| | | } |
| | | }, |
| | | } |
| | | </script> |
| | |
| | | align-items: center; |
| | | z-index: 2; |
| | | |
| | | |
| | | .more-button { |
| | | cursor: pointer; |
| | | font-size: 16px; |
| | |
| | | margin: 0 20px; |
| | | width: 180px; |
| | | } |
| | | </style> |
| | | </style> |