feat:对接接口、完善功能
This commit is contained in:
@@ -1,20 +1,17 @@
|
||||
<template>
|
||||
<div class="wordCloud" id="wordCloud" />
|
||||
<div class="wordCloud" :id="id" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import * as echarts from 'echarts'
|
||||
import 'echarts-wordcloud'
|
||||
import { fitChartSize } from '@/utils/dataUtil'
|
||||
import { getHotWordApi } from '@/api/sentiment'
|
||||
import { useEchart } from '@/hooks/echart'
|
||||
|
||||
let wordChart = null
|
||||
const { id, setOption } = useEchart()
|
||||
const initChart = async () => {
|
||||
const dom = document.getElementById('wordCloud')
|
||||
wordChart = echarts.init(dom)
|
||||
let res = await getHotWordApi()
|
||||
wordChart.setOption({
|
||||
//你的代码
|
||||
setOption({
|
||||
series: [
|
||||
{
|
||||
type: 'wordCloud',
|
||||
@@ -52,16 +49,8 @@
|
||||
]
|
||||
})
|
||||
}
|
||||
const resize = () => {
|
||||
if (wordChart) {
|
||||
wordChart.dispose()
|
||||
wordChart = null
|
||||
initChart()
|
||||
}
|
||||
}
|
||||
onMounted(() => {
|
||||
initChart()
|
||||
window.addEventListener('resize', resize)
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user