fix: statistic tooltips
This commit is contained in:
@@ -127,8 +127,11 @@ type StatisticData struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type LatestSendData struct {
|
type LatestSendData struct {
|
||||||
Day string `json:"day"`
|
Day string `json:"day"`
|
||||||
Num int `json:"num"`
|
Num int `json:"num"`
|
||||||
|
SuccNum int `json:"succ_num"`
|
||||||
|
DaySuccNum int `json:"day_succ_num"`
|
||||||
|
DayFailedNum int `json:"day_failed_num"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WayCateData struct {
|
type WayCateData struct {
|
||||||
@@ -161,6 +164,8 @@ SUM(CASE WHEN status != 1 or status is null THEN 1 ELSE 0 END) AS today_failed_n
|
|||||||
Table(logt).
|
Table(logt).
|
||||||
Select(`
|
Select(`
|
||||||
CAST(DATE(created_on) AS CHAR) AS day,
|
CAST(DATE(created_on) AS CHAR) AS day,
|
||||||
|
SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) AS day_succ_num,
|
||||||
|
SUM(CASE WHEN status != 1 or status is null THEN 1 ELSE 0 END) AS day_failed_num,
|
||||||
COUNT(*) AS num`).
|
COUNT(*) AS num`).
|
||||||
Where(" created_on >= CURDATE() - INTERVAL ? DAY", days).
|
Where(" created_on >= CURDATE() - INTERVAL ? DAY", days).
|
||||||
Group("DATE(created_on)").
|
Group("DATE(created_on)").
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
GridComponent,
|
GridComponent,
|
||||||
DatasetComponent,
|
DatasetComponent,
|
||||||
TransformComponent,
|
TransformComponent,
|
||||||
|
LegendComponent,
|
||||||
} from "echarts/components";
|
} from "echarts/components";
|
||||||
|
|
||||||
// 标签自动布局,全局过渡动画等特性
|
// 标签自动布局,全局过渡动画等特性
|
||||||
@@ -28,6 +29,7 @@ echarts.use([
|
|||||||
PieChart,
|
PieChart,
|
||||||
LabelLayout,
|
LabelLayout,
|
||||||
UniversalTransition,
|
UniversalTransition,
|
||||||
|
LegendComponent,
|
||||||
CanvasRenderer,
|
CanvasRenderer,
|
||||||
LineChart,
|
LineChart,
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -46,8 +46,8 @@
|
|||||||
<el-divider />
|
<el-divider />
|
||||||
|
|
||||||
<div class="echarts-box">
|
<div class="echarts-box">
|
||||||
<div id="daily-chart" style="width: 65%; height: 350px;"></div>
|
<div ref="dailyChart" style="width: 65%; height: 350px;"></div>
|
||||||
<div id="send-cate-chart" style="width: 35%; height: 350px;"></div>
|
<div ref="sendCateChart" style="width: 35%; height: 320px;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -61,7 +61,7 @@ import {
|
|||||||
CaretTop,
|
CaretTop,
|
||||||
Warning,
|
Warning,
|
||||||
} from '@element-plus/icons-vue'
|
} from '@element-plus/icons-vue'
|
||||||
import { reactive, toRefs, onMounted, onUnmounted, inject } from 'vue'
|
import { reactive, toRefs, onMounted, onUnmounted, inject, ref } from 'vue'
|
||||||
import { request } from '@/api/api'
|
import { request } from '@/api/api'
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { CommonUtils } from "@/util/commonUtils.js";
|
import { CommonUtils } from "@/util/commonUtils.js";
|
||||||
@@ -71,11 +71,12 @@ export default {
|
|||||||
ArrowRight,
|
ArrowRight,
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
|
const dailyChart = ref(null);
|
||||||
|
const sendCateChart = ref(null);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
data: {},
|
data: {},
|
||||||
dailyChart: {},
|
displayCharts: [],
|
||||||
sendCateChart: {},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const echart = inject('$echarts');
|
const echart = inject('$echarts');
|
||||||
@@ -112,24 +113,33 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
state.dailyChart.dispose();
|
state.displayCharts.forEach(element => {
|
||||||
state.sendCateChart.dispose();
|
element.dispose();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getLasteDetailData = (key) => {
|
||||||
|
let result = [];
|
||||||
|
state.data.latest_send_data.forEach(element => {
|
||||||
|
result.push(element[key]);
|
||||||
|
})
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// 最近30天数据图
|
// 最近30天数据图
|
||||||
function initDailyChart() {
|
function initDailyChart() {
|
||||||
state.dailyChart = echart.init(document.getElementById("daily-chart"));
|
let chartobj = echart.init(dailyChart.value);
|
||||||
|
state.displayCharts.push(chartobj);
|
||||||
|
|
||||||
let xAxisdata = [];
|
let xAxisdata = [];
|
||||||
state.data.latest_send_data.forEach(element => {
|
state.data.latest_send_data.forEach(element => {
|
||||||
xAxisdata.push(element.day);
|
xAxisdata.push(element.day);
|
||||||
});
|
});
|
||||||
let yAxisdata = [];
|
|
||||||
state.data.latest_send_data.forEach(element => {
|
|
||||||
yAxisdata.push(element.num);
|
|
||||||
});
|
|
||||||
|
|
||||||
state.dailyChart.setOption({
|
chartobj.setOption({
|
||||||
|
tooltip: {
|
||||||
|
trigger: 'axis'
|
||||||
|
},
|
||||||
title: {
|
title: {
|
||||||
subtext: '最近消息30天发送数据',
|
subtext: '最近消息30天发送数据',
|
||||||
top: 0,
|
top: 0,
|
||||||
@@ -139,7 +149,8 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: "category",
|
type: 'category',
|
||||||
|
boundaryGap: false,
|
||||||
data: xAxisdata
|
data: xAxisdata
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
@@ -148,28 +159,46 @@ export default {
|
|||||||
yAxis: {
|
yAxis: {
|
||||||
type: "value"
|
type: "value"
|
||||||
},
|
},
|
||||||
|
// legend: {
|
||||||
|
// data: ['发送数', '成功数', '失败数']
|
||||||
|
// },
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
data: yAxisdata,
|
name: '发送数',
|
||||||
|
data: getLasteDetailData('num'),
|
||||||
type: "line",
|
type: "line",
|
||||||
smooth: true
|
smooth: true
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
name: '成功数',
|
||||||
|
data: getLasteDetailData('day_succ_num'),
|
||||||
|
type: "line",
|
||||||
|
smooth: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '失败数',
|
||||||
|
data: getLasteDetailData('day_failed_num'),
|
||||||
|
type: "line",
|
||||||
|
smooth: true
|
||||||
|
},
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
window.onresize = function () {
|
|
||||||
state.dailyChart.resize();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送消息实例类别图
|
// 发送消息实例类别图
|
||||||
function initSendCateChart() {
|
function initSendCateChart() {
|
||||||
state.sendCateChart = echart.init(document.getElementById("send-cate-chart"));
|
let chartobj = echart.init(sendCateChart.value);
|
||||||
|
state.displayCharts.push(chartobj);
|
||||||
|
|
||||||
let data = [];
|
let data = [];
|
||||||
state.data.way_cate_data.forEach(element => {
|
state.data.way_cate_data.forEach(element => {
|
||||||
data.push({ name: element.way_name, value: element.count_num });
|
data.push({ name: element.way_name, value: element.count_num });
|
||||||
});
|
});
|
||||||
state.sendCateChart.setOption({
|
chartobj.setOption({
|
||||||
|
tooltip: {
|
||||||
|
trigger: 'item'
|
||||||
|
},
|
||||||
grid: {
|
grid: {
|
||||||
width: '60%',
|
width: '60%',
|
||||||
height: '60%',
|
height: '60%',
|
||||||
@@ -191,14 +220,10 @@ export default {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
window.onresize = function () {
|
|
||||||
state.sendCateChart.resize();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...toRefs(state), formatFailedNumStyle, clickErrorNumDetail
|
...toRefs(state), formatFailedNumStyle, clickErrorNumDetail, dailyChart, sendCateChart
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user