2022-04-25 09:18:31 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div class="affix-time">
|
|
|
|
<Affix :offset-top="100">
|
|
|
|
<div class="flex affix-box">
|
2022-04-25 18:09:49 +08:00
|
|
|
<affixTime :closeShop="true" @selected="clickBreadcrumb"/>
|
|
|
|
|
|
|
|
<InputNumber
|
|
|
|
placeholder="展示前N"
|
|
|
|
:max="200"
|
|
|
|
:min="10"
|
|
|
|
v-model="params.top"
|
|
|
|
></InputNumber>
|
|
|
|
<Button style="margin-left: 10px" @click="search">搜索</Button>
|
2022-04-25 09:18:31 +08:00
|
|
|
</div>
|
|
|
|
</Affix>
|
|
|
|
</div>
|
2022-08-11 10:32:26 +08:00
|
|
|
|
2022-04-25 18:09:49 +08:00
|
|
|
<div id="container"></div>
|
2022-08-11 10:32:26 +08:00
|
|
|
<Table border :columns="columns" :data="hotWordsData"></Table>
|
2022-04-25 09:18:31 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-04-25 18:09:49 +08:00
|
|
|
import {Chart} from "@antv/g2";
|
|
|
|
import {getHotWordsStatistics} from "@/api/index";
|
2022-04-25 09:18:31 +08:00
|
|
|
import affixTime from "@/views/lili-components/affix-time";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
affixTime,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
params: {
|
|
|
|
// 请求参数
|
|
|
|
searchType: "LAST_SEVEN",
|
|
|
|
year: "",
|
|
|
|
month: "",
|
2022-04-25 18:09:49 +08:00
|
|
|
top: 50
|
2022-04-25 09:18:31 +08:00
|
|
|
},
|
2022-08-11 10:32:26 +08:00
|
|
|
columns:[
|
|
|
|
{
|
|
|
|
title: "热词名称",
|
|
|
|
key: "keywords",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: "搜索次数",
|
|
|
|
key: "score",
|
|
|
|
},
|
|
|
|
],
|
2022-04-25 18:09:49 +08:00
|
|
|
hotWordsChart:"", //图表
|
|
|
|
hotWordsData:[] //数据
|
2022-04-25 09:18:31 +08:00
|
|
|
};
|
|
|
|
},
|
2022-04-25 18:09:49 +08:00
|
|
|
computed: {},
|
2022-04-25 09:18:31 +08:00
|
|
|
methods: {
|
|
|
|
clickBreadcrumb(val) {
|
2022-04-25 18:09:49 +08:00
|
|
|
this.params = {...this.params, ...val}
|
2022-04-25 09:18:31 +08:00
|
|
|
},
|
|
|
|
// 初始化图表
|
2022-04-25 18:09:49 +08:00
|
|
|
async search() {
|
2022-04-25 09:18:31 +08:00
|
|
|
const res = await getHotWordsStatistics(this.params);
|
|
|
|
if (res.success) {
|
2022-04-25 18:09:49 +08:00
|
|
|
this.hotWordsData=res.result;
|
|
|
|
this.hotWordsChart.data(this.hotWordsData)
|
|
|
|
this.hotWordsChart.render();
|
2022-04-25 09:18:31 +08:00
|
|
|
}
|
|
|
|
},
|
2022-04-25 18:09:49 +08:00
|
|
|
handleClickSearch() {
|
|
|
|
},
|
|
|
|
init(){
|
|
|
|
let chart = this.hotWordsChart
|
|
|
|
chart = new Chart({
|
|
|
|
container: "container",
|
|
|
|
autoFit: true,
|
|
|
|
height: 500,
|
|
|
|
padding: [50, 20, 50, 20],
|
|
|
|
});
|
|
|
|
chart.scale("score", {
|
|
|
|
alias: "搜索次数",
|
|
|
|
});
|
|
|
|
|
|
|
|
chart.axis("keywords", {
|
|
|
|
tickLine: {
|
|
|
|
alignTick: false,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
chart.axis("score", false);
|
|
|
|
|
|
|
|
chart.tooltip({
|
|
|
|
showMarkers: false,
|
|
|
|
});
|
|
|
|
chart.interval().position("keywords*score");
|
|
|
|
chart.interaction("element-active");
|
|
|
|
this.hotWordsChart=chart;
|
|
|
|
this.search();
|
|
|
|
}
|
2022-04-25 09:18:31 +08:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.init();
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.affix-time {
|
|
|
|
padding-left: 15px;
|
|
|
|
}
|
2022-08-11 10:32:26 +08:00
|
|
|
|
2022-04-25 09:18:31 +08:00
|
|
|
</style>
|