fix:数据库监控页面曲线图

This commit is contained in:
orgin 2023-12-27 17:19:40 +08:00
parent 2b510ea460
commit eb394d11e8
2 changed files with 1280 additions and 54 deletions

View File

@ -8,8 +8,9 @@
<script> <script>
import * as echarts from 'echarts' import * as echarts from 'echarts'
import BoxTitle from '../../components/boxTitle.vue'; import BoxTitle from '../../components/boxTitle.vue';
import moment from 'moment'
export default { export default {
props: ["title", "layout", "color", "dataSource"], props: ["title", "layout", "color", "dataSource", "units", "newUnits"],
components: { components: {
BoxTitle, BoxTitle,
}, },
@ -28,11 +29,26 @@ export default {
}, },
methods: { methods: {
drawChart() { drawChart() {
let seriesData = this.dataSource.map(function(item) {
return [item.date, item.value];
})
seriesData.forEach(function(item) {
item.date = new Date(item.date * 1000); //
});
const isCompute = this.units === 'B' || this.units === 'Kb'
let myLine = echarts.init(document.getElementById(`${this.layout}`)) let myLine = echarts.init(document.getElementById(`${this.layout}`))
this.option = { this.option = {
color: this.color, color: this.color,
tooltip: { tooltip: {
trigger: 'axis' trigger: 'axis',
title: this.title,
formatter: (text) => {
let num = text.value
if(isCompute){
num = text.value + this.newUnits
}
return { name: moment(text.date * 1000).format('HH:mm'), value: num}
},
}, },
grid: { grid: {
left: 0, left: 0,
@ -42,7 +58,8 @@ export default {
containLabel: true containLabel: true
}, },
xAxis: { xAxis: {
type: 'category', type: 'time',
// type: 'category',
axisTick: { axisTick: {
show:false show:false
}, },
@ -53,21 +70,24 @@ export default {
}, },
axisLabel: { axisLabel: {
color: "rgba(173, 230, 238, 1)", color: "rgba(173, 230, 238, 1)",
formatter: (value,index)=>{ // formatter: (value,index)=>{
if(index === 0) { // if(index === 0) {
return ' ' + value; // return ' ' + value;
} // }
if(index === this.xData.length -1) { // if(index === this.xData.length -1) {
return value + ' '; // return value + ' ';
} // }
return value // return value
} // }
}, },
boundaryGap: false, boundaryGap: false,
data: this.xData // data: this.xData
}, },
yAxis: { yAxis: {
type: 'value', type: 'value',
title:{
text: isCompute ? "unit:" + this.newUnits : null,
},
splitLine: { splitLine: {
show: true, show: true,
lineStyle: { lineStyle: {
@ -86,19 +106,20 @@ export default {
}, },
series: [ series: [
{ {
name: 'login',
type: 'line', type: 'line',
symbol: 'none', // symbol: 'none',
lineStyle: { lineStyle: {
width: 0.8 width: 8
}, },
areaStyle: { // areaStyle: {
opacity: 1, // opacity: 1,
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ // color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: this.color[0] }, // { offset: 0, color: this.color[0] },
{ offset: 1, color: this.color[1] }, // { offset: 1, color: this.color[1] },
]) // ])
}, // },
data: this.dataSource data: seriesData
} }
] ]
}; };

File diff suppressed because it is too large Load Diff