Commit ce5ae648 authored by wanli's avatar wanli

update

parent d286cb0a
...@@ -25,14 +25,12 @@ ...@@ -25,14 +25,12 @@
</el-form> </el-form>
<LineChart :chartData="evm" :dataList="evmList"></LineChart> <LineChart :chartData="evm" :dataList="evmList"></LineChart>
<LvglChart :chartData="lvgl"></LvglChart> <LvglChart :chartData="lvgl"></LvglChart>
<ImageChart :chartData="image"></ImageChart>
</div> </div>
</template> </template>
<script> <script>
import { getWatchList, getMonitorData } from "@/api/index"; import { getWatchList, getMonitorData } from "@/api/index";
import LineChart from "./components/EvmChart"; import LineChart from "./components/EvmChart";
import LvglChart from "./components/LvglChart"; import LvglChart from "./components/LvglChart";
import ImageChart from "./components/ImageChart";
import { wsNotify } from "@/utils/eventBus.js"; import { wsNotify } from "@/utils/eventBus.js";
export default { export default {
name: "AppChart", name: "AppChart",
...@@ -59,7 +57,6 @@ export default { ...@@ -59,7 +57,6 @@ export default {
components: { components: {
LineChart, LineChart,
LvglChart, LvglChart,
ImageChart,
}, },
methods: { methods: {
sendMsg() { sendMsg() {
......
...@@ -113,12 +113,7 @@ export default { ...@@ -113,12 +113,7 @@ export default {
data: seriesData.stack_used_size, data: seriesData.stack_used_size,
}, },
], ],
legendData: [ legendData: Object.keys(seriesData),
"heap_total_size",
"heap_used_size",
"stack_total_size",
"stack_used_size",
],
}; };
}, },
watch: { watch: {
...@@ -229,13 +224,14 @@ export default { ...@@ -229,13 +224,14 @@ export default {
// show: false, // show: false,
// }, // },
axisLabel: { axisLabel: {
formatter: "{hh}:{mm}:{ss}", formatter: "{HH}:{mm}:{ss}",
}, },
}, },
yAxis: { yAxis: {
type: "value", type: "value",
scale: true, scale: true,
boundaryGap: [0, "100%"], // boundaryGap: [0, "100%"],
// splitNumber: 10,
splitLine: { splitLine: {
show: false, show: false,
}, },
......
...@@ -7,6 +7,8 @@ import * as echarts from "echarts"; ...@@ -7,6 +7,8 @@ import * as echarts from "echarts";
require("echarts/theme/macarons"); require("echarts/theme/macarons");
import resize from "./mixins/resize"; import resize from "./mixins/resize";
let chart = null
const seriesData = { const seriesData = {
heap_total_size: [], heap_total_size: [],
heap_used_size: [], heap_used_size: [],
...@@ -42,7 +44,6 @@ export default { ...@@ -42,7 +44,6 @@ export default {
data() { data() {
return { return {
loading: null, loading: null,
chart: null,
series: [ series: [
{ {
name: "heap_total_size", name: "heap_total_size",
...@@ -54,7 +55,7 @@ export default { ...@@ -54,7 +55,7 @@ export default {
focus: "series", focus: "series",
blurScope: "coordinateSystem", blurScope: "coordinateSystem",
}, },
data: seriesData.heap_total_size, data: [],
}, },
{ {
name: "heap_used_size", name: "heap_used_size",
...@@ -65,7 +66,7 @@ export default { ...@@ -65,7 +66,7 @@ export default {
focus: "series", focus: "series",
blurScope: "coordinateSystem", blurScope: "coordinateSystem",
}, },
data: seriesData.heap_used_size, data: [],
}, },
{ {
name: "stack_total_size", name: "stack_total_size",
...@@ -76,7 +77,7 @@ export default { ...@@ -76,7 +77,7 @@ export default {
focus: "series", focus: "series",
blurScope: "coordinateSystem", blurScope: "coordinateSystem",
}, },
data: seriesData.stack_total_size, data: [],
}, },
{ {
name: "stack_used_size", name: "stack_used_size",
...@@ -87,15 +88,10 @@ export default { ...@@ -87,15 +88,10 @@ export default {
focus: "series", focus: "series",
blurScope: "coordinateSystem", blurScope: "coordinateSystem",
}, },
data: seriesData.stack_used_size, data: [],
}, },
], ],
legendData: [ legendData: Object.keys(seriesData),
"heap_total_size",
"heap_used_size",
"stack_total_size",
"stack_used_size",
],
}; };
}, },
watch: { watch: {
...@@ -112,25 +108,40 @@ export default { ...@@ -112,25 +108,40 @@ export default {
}); });
}, },
beforeDestroy() { beforeDestroy() {
if (!this.chart) { if (!chart) {
return; return;
} }
this.chart.dispose(); chart.clear();
this.chart = null; chart.dispose();
}, },
methods: { methods: {
handleData(data) { handleData(data) {
Object.keys(seriesData).forEach((key) => { Object.keys(seriesData).forEach((key) => {
seriesData[key] = []; seriesData[key] = [];
}); });
// this.series.forEach((item) => {
// item.data = [];
// });
// this.chart.setOption({ series: this.series });
this.series.forEach((item) => {
item.data = [];
});
// chart.setOption({ series: this.series });
data.forEach((item) => { data.forEach((item) => {
this.handleMessage(item); this.handleMessage(item);
}); });
let temp = Object.assign(this.series);
temp.forEach(item => {
if (Object.prototype.hasOwnProperty.call(seriesData, item.name)) {
item.data = seriesData[item.name]
}
});
this.series = temp;
this.$nextTick(() => {
chart &&
chart.setOption({
series: this.series,
});
});
}, },
handleMessage(data) { handleMessage(data) {
Object.keys(data).forEach((k) => { Object.keys(data).forEach((k) => {
...@@ -141,20 +152,13 @@ export default { ...@@ -141,20 +152,13 @@ export default {
}); });
} }
}); });
this.$nextTick(() => {
this.chart &&
this.chart.setOption({
series: this.series,
});
});
}, },
initChart() { initChart() {
this.chart = echarts.init(this.$el, "macarons"); chart = echarts.init(this.$el, "macarons");
this.setOptions(); this.setOptions();
}, },
setOptions() { setOptions() {
this.chart.setOption({ chart.setOption({
title: { title: {
text: "EVM", text: "EVM",
}, },
...@@ -169,13 +173,12 @@ export default { ...@@ -169,13 +173,12 @@ export default {
// show: false, // show: false,
// }, // },
axisLabel: { axisLabel: {
formatter: "{hh}:{mm}:{ss}", formatter: "{HH}:{mm}:{ss}",
}, },
}, },
yAxis: { yAxis: {
type: "value", type: "value",
scale: true, scale: true,
boundaryGap: [0, "100%"],
splitLine: { splitLine: {
show: false, show: false,
}, },
......
...@@ -207,12 +207,12 @@ export default { ...@@ -207,12 +207,12 @@ export default {
show: false, show: false,
}, },
axisLabel: { axisLabel: {
formatter: "{hh}:{mm}:{ss}", formatter: "{HH}:{mm}:{ss}",
}, },
}, },
yAxis: { yAxis: {
type: "value", type: "value",
boundaryGap: [0, "100%"], // boundaryGap: [0, "100%"],
splitLine: { splitLine: {
show: false, show: false,
}, },
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
import * as echarts from "echarts"; import * as echarts from "echarts";
require("echarts/theme/macarons"); require("echarts/theme/macarons");
import resize from "./mixins/resize"; import resize from "./mixins/resize";
import { getDateTimeString } from "@/utils/utils";
const seriesData = { const seriesData = {
frag_pct: [], frag_pct: [],
...@@ -56,7 +55,7 @@ export default { ...@@ -56,7 +55,7 @@ export default {
focus: "series", focus: "series",
blurScope: "coordinateSystem", blurScope: "coordinateSystem",
}, },
data: seriesData.frag_pct, data: [],
}, },
{ {
name: "free_biggest_size", name: "free_biggest_size",
...@@ -66,7 +65,7 @@ export default { ...@@ -66,7 +65,7 @@ export default {
focus: "series", focus: "series",
blurScope: "coordinateSystem", blurScope: "coordinateSystem",
}, },
data: seriesData.free_biggest_size, data: [],
}, },
{ {
name: "free_cnt", name: "free_cnt",
...@@ -76,7 +75,7 @@ export default { ...@@ -76,7 +75,7 @@ export default {
focus: "series", focus: "series",
blurScope: "coordinateSystem", blurScope: "coordinateSystem",
}, },
data: seriesData.free_cnt, data: [],
}, },
{ {
name: "free_size", name: "free_size",
...@@ -86,7 +85,7 @@ export default { ...@@ -86,7 +85,7 @@ export default {
focus: "series", focus: "series",
blurScope: "coordinateSystem", blurScope: "coordinateSystem",
}, },
data: seriesData.free_size, data: [],
}, },
{ {
name: "total_size", name: "total_size",
...@@ -96,7 +95,7 @@ export default { ...@@ -96,7 +95,7 @@ export default {
focus: "series", focus: "series",
blurScope: "coordinateSystem", blurScope: "coordinateSystem",
}, },
data: seriesData.total_size, data: [],
}, },
{ {
name: "used_cnt", name: "used_cnt",
...@@ -106,28 +105,20 @@ export default { ...@@ -106,28 +105,20 @@ export default {
focus: "series", focus: "series",
blurScope: "coordinateSystem", blurScope: "coordinateSystem",
}, },
data: seriesData.used_cnt, data: [],
}, },
{ {
name: "used_pctused_pct", name: "used_pct",
type: "line", type: "line",
showSymbol: false, showSymbol: false,
emphasis: { emphasis: {
focus: "series", focus: "series",
blurScope: "coordinateSystem", blurScope: "coordinateSystem",
}, },
data: seriesData.used_pctused_pct, data: [],
}, },
], ],
legendData: [ legendData: Object.keys(seriesData),
"frag_pct",
"free_biggest_size",
"free_cnt",
"free_size",
"total_size",
"used_cnt",
"used_pctused_pct",
],
}; };
}, },
watch: { watch: {
...@@ -158,22 +149,19 @@ export default { ...@@ -158,22 +149,19 @@ export default {
this.series.forEach(item => { this.series.forEach(item => {
item.data = [] item.data = []
}); });
this.chart.setOption({ series: this.series }); // this.chart.setOption({ series: this.series });
data.forEach((item) => { data.forEach((item) => {
this.handleMessage(item); this.handleMessage(item);
}); });
},
handleMessage(data) { let temp = Object.assign(this.series);
Object.keys(data).forEach((k) => { temp.forEach(item => {
var t = getDateTimeString(new Date()); if (Object.prototype.hasOwnProperty.call(seriesData, item.name)) {
if (k == "timestamp") t = data[k]; item.data = seriesData[item.name]
if (this.legendData.includes(k)) }
seriesData[k].push({
name: k,
value: [t, data[k]],
});
}); });
this.series = temp;
this.$nextTick(() => { this.$nextTick(() => {
this.chart && this.chart &&
...@@ -182,6 +170,15 @@ export default { ...@@ -182,6 +170,15 @@ export default {
}); });
}); });
}, },
handleMessage(data) {
Object.keys(data).forEach((k) => {
if (this.legendData.includes(k))
seriesData[k].push({
name: k,
value: [data.timestamp, data[k]],
});
});
},
initChart() { initChart() {
this.chart = echarts.init(this.$el, "macarons"); this.chart = echarts.init(this.$el, "macarons");
this.setOptions(); this.setOptions();
...@@ -197,12 +194,11 @@ export default { ...@@ -197,12 +194,11 @@ export default {
show: false, show: false,
}, },
axisLabel: { axisLabel: {
formatter: "{hh}:{mm}:{ss}", formatter: "{HH}:{mm}:{ss}",
}, },
}, },
yAxis: { yAxis: {
type: "value", type: "value",
boundaryGap: [0, "100%"],
splitLine: { splitLine: {
show: false, show: false,
}, },
......
...@@ -37,8 +37,8 @@ ...@@ -37,8 +37,8 @@
> >
<el-form-item><el-button @click="onReset">重置</el-button></el-form-item> <el-form-item><el-button @click="onReset">重置</el-button></el-form-item>
</el-form> </el-form>
<EvmHistoryChart :dataList="[]"></EvmHistoryChart> <EvmHistoryChart :dataList="evmList"></EvmHistoryChart>
<LvglHistoryChart :dataList="[]"></LvglHistoryChart> <LvglHistoryChart :dataList="lvglList"></LvglHistoryChart>
</div> </div>
</template> </template>
<script> <script>
...@@ -100,6 +100,12 @@ export default { ...@@ -100,6 +100,12 @@ export default {
}, },
methods: { methods: {
fetchData() { fetchData() {
const loading = this.$loading({
lock: true,
text: "Loading",
spinner: "el-icon-loading",
background: "rgba(0, 0, 0, 0.7)",
});
let params = { let params = {
watch: this.watch_id, watch: this.watch_id,
}; };
...@@ -113,6 +119,7 @@ export default { ...@@ -113,6 +119,7 @@ export default {
} }
getMonitorData(params) getMonitorData(params)
.then((res) => { .then((res) => {
console.log("====>", res.type);
if (res.type == "object") { if (res.type == "object") {
this.evmList = res.data.evm; this.evmList = res.data.evm;
this.lvglList = res.data.lvgl; this.lvglList = res.data.lvgl;
...@@ -125,6 +132,9 @@ export default { ...@@ -125,6 +132,9 @@ export default {
}) })
.catch((err) => { .catch((err) => {
this.$message.warning(err.msg); this.$message.warning(err.msg);
})
.finally(() => {
loading.close();
}); });
}, },
fetchSelectData() { fetchSelectData() {
...@@ -132,7 +142,6 @@ export default { ...@@ -132,7 +142,6 @@ export default {
getWatchList() getWatchList()
.then((res) => { .then((res) => {
if (res.code == 200) this.watchs = res.data; if (res.code == 200) this.watchs = res.data;
console.log(this.watchs);
}) })
.catch((err) => { .catch((err) => {
this.$message.warning(err.msg); this.$message.warning(err.msg);
......
...@@ -306,7 +306,17 @@ export default { ...@@ -306,7 +306,17 @@ export default {
this.lvgl = [{ ...msg.lvgl }]; this.lvgl = [{ ...msg.lvgl }];
this.evm = [{ ...msg.evm }]; this.evm = [{ ...msg.evm }];
this.request = [{ ...msg.request }]; this.request = [{ ...msg.request }];
this.image = msg.image; // 这里需要特殊处理下,先判断uri是否存在,不存在则添加,存在则更新
let uris = [];
this.image.forEach((img) => {
uris.push(img.uri)
});
msg.image.forEach((item) => {
if (!uris.includes(item.uri)) {
this.image.push(item)
}
});
// this.image = msg.image;
}, },
onSelectChange(res) { onSelectChange(res) {
this.device = res; this.device = res;
...@@ -316,22 +326,22 @@ export default { ...@@ -316,22 +326,22 @@ export default {
}, },
mounted() {}, mounted() {},
created() { created() {
this.socket = wsNotify this.socket = wsNotify;
wsNotify.eventBus.$on("open", (message) => { wsNotify.eventBus.$on("open", (message) => {
this.sendMsg(); this.sendMsg();
this.$nextTick(() => { this.$nextTick(() => {
console.log(message) console.log(message);
}); });
}); });
wsNotify.eventBus.$on("close", (message) => { wsNotify.eventBus.$on("close", (message) => {
this.$nextTick(() => { this.$nextTick(() => {
console.log(message) console.log(message);
}); });
}); });
wsNotify.eventBus.$on("message", (message) => { wsNotify.eventBus.$on("message", (message) => {
this.$nextTick(() => { this.$nextTick(() => {
console.log(message) console.log(message);
this.handleMessage(message) this.handleMessage(message);
}); });
}); });
// this.initWebSocket(); // this.initWebSocket();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment