提交 9fde2e28 编写于 作者: chase_the_air's avatar chase_the_air

Auto Commit

上级 0d714d92
...@@ -8,7 +8,7 @@ import LineChart from './components/LineChart.vue' ...@@ -8,7 +8,7 @@ import LineChart from './components/LineChart.vue'
<img alt="Vue logo" class="logo" src="./assets/logo.svg" width="125" height="125" /> <img alt="Vue logo" class="logo" src="./assets/logo.svg" width="125" height="125" />
<div class="wrapper"> <div class="wrapper">
<HelloChart/> <HelloChart/>
<LineChart/> - <LineChart/>
</div> </div>
</header> </header>
</template> </template>
......
<template> <template>
<div class="line-chart" id="line-chart"> <div class="line-chart" id="line-chart">
</div> </div>
</template> </template>
<script setup> <script>
defineProps({ import * as echarts from 'echarts'
export default {
}) data() {
return {
chart: {}
}
},
mounted() {
this.initOption()
window.addEventListener('resize', () => {
this.chart.resize()
})
},
methods: {
resizeChart() {
if (Object.keys(this.chart).length) {
this.chart.resize()
}
},
disposeChart() {
if (Object.keys(this.chart).length) {
this.chart.dispose()
}
},
initChart() {
this.chart = echarts.init(document.getElementById('line-chart'))
},
initOption() {
this.disposeChart()
this.initChart()
let option = {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [
{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'line',
smooth: true
}
]
}
this.chart.on('click','series',(param)=>{
console.log(param)
})
this.chart.setOption(option)
}
}
}
</script> </script>
<style scoped> <style scoped>
.line-chart {
width: 100%;
height: 500px;
}
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册