| | |
| | | </div> |
| | | </template> |
| | | <script> |
| | | let echarts = require("echarts"); |
| | | import options from "./chartOptions"; |
| | | let echarts = null; |
| | | let $bar; |
| | | let $pie; |
| | | let $line; |
| | | |
| | | async function loadEcharts() { |
| | | if (!echarts) { |
| | | const module = await import("echarts"); |
| | | echarts = module.default || module; |
| | | } |
| | | return echarts; |
| | | } |
| | | |
| | | export default { |
| | | mounted() { |
| | | async mounted() { |
| | | echarts = await loadEcharts(); |
| | | $bar = echarts.init(document.getElementById("bar-0001")); |
| | | $bar.setOption(this.options.bar); |
| | | }, |
| | |
| | | this.width = document.documentElement.clientWidth - 240; |
| | | }, |
| | | methods: { |
| | | tabClick(name) { |
| | | async tabClick(name) { |
| | | if (name.props.name == "pie") { |
| | | if (!$pie) { |
| | | echarts = await loadEcharts(); |
| | | $pie = echarts.init(document.getElementById("pie-0001")); |
| | | $pie.setOption(this.options.pie); |
| | | |
| | | } |
| | | } else if (name.props.name == "line") { |
| | | if (!$line) { |
| | | echarts = await loadEcharts(); |
| | | $line = echarts.init(document.getElementById("line-0001")); |
| | | $line.setOption(this.options.line); |
| | | |