-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
782 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<template> | ||
<div element-loading-text="Loading..." v-loading="loading" ref="echartRef" ></div> | ||
</template> | ||
|
||
<script> | ||
import { onMounted, ref } from 'vue'; | ||
import * as echarts from 'echarts'; | ||
export default { | ||
name: 'EChart', | ||
props: ['legend', 'yName'], | ||
setup(props) { | ||
const loading = ref(true); | ||
const echartRef = ref(); | ||
const option = { | ||
title: { | ||
text: '', | ||
}, | ||
tooltip: { | ||
trigger: 'axis' | ||
}, | ||
legend: { | ||
data: props.legend, | ||
}, | ||
grid: { | ||
left: '3%', | ||
right: '4%', | ||
bottom: '3%', | ||
containLabel: true | ||
}, | ||
xAxis: { | ||
type: 'category', | ||
boundaryGap: false, | ||
data: [], | ||
}, | ||
yAxis: { | ||
name : props.yName, | ||
type: 'value' | ||
}, | ||
series: [], | ||
}; | ||
let chart = null; | ||
const update = (time,series) => { | ||
option.xAxis.data = time; | ||
option.series = series; | ||
// 更新图表 | ||
if (chart) { | ||
loading.value = true; | ||
chart.setOption(option); | ||
} | ||
}; | ||
onMounted(() => { | ||
// 初始化ECharts实例并应用配置项 | ||
chart = echarts.init(echartRef.value); | ||
chart.on('rendered', function() { | ||
loading.value = false; | ||
}); | ||
loading.value = true; | ||
chart.setOption(option); | ||
chart.resize(); | ||
}); | ||
return { | ||
echartRef, | ||
update, | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped > | ||
/* 文本不可选中 */ | ||
.no-select { | ||
user-select: none; | ||
} | ||
</style> |
Oops, something went wrong.