This commit is contained in:
lb 2023-12-29 11:06:07 +08:00
parent 3f44cb9e9a
commit a73d61fad8
4 changed files with 115 additions and 10 deletions

View File

@ -85,18 +85,31 @@ function preHandleStatisticData(data, legend) {
data: [], data: [],
})); }));
const seriesData = [];
legend.forEach((item, index) => { legend.forEach((item, index) => {
series[index].name = item; series[index].name = item;
data.forEach((d, idx) => { data.forEach((d, idx) => {
// if (index == 0) { if (index == legend.length - 1) {
// series[index].label = { series[index].label = {
show: true,
position: "top",
distance: 10,
color: "#fffc",
formatter: (params) => data[params.dataIndex].sum,
};
}
// const sum = d.sum;
// console.log("d", d, sum);
// series[index].label = ((fff) => {
// console.log("===>", fff);
// return {
// show: true, // show: true,
// position: "top", // position: "top",
// distance: 10, // distance: 10,
// color: "#fffc", // color: "#fffc",
// formatter: "asdf" + fff,
// }; // };
// } // })(sum);
series[index].data.push(obj[d.name][item] || 0); series[index].data.push(obj[d.name][item] || 0);
}); });
}); });
@ -107,9 +120,10 @@ function preHandleStatisticData(data, legend) {
function getOptions(series, isra, currentStatistic) { function getOptions(series, isra, currentStatistic) {
return { return {
color: ["#2760FF", "#8167F6", "#5B9BFF", "#99D66C", "#FFD160", "#FF8A40"], color: ["#2760FF", "#8167F6", "#5B9BFF", "#99D66C", "#FFD160", "#FF8A40"],
grid: { top: 42, right: 12, bottom: 20, left: 48 }, grid: { top: 80, right: 12, bottom: 20, left: 48 },
legend: { legend: {
top: 10, top: 10,
left: 60,
padding: 5, padding: 5,
itemWidth: 12, itemWidth: 12,
itemHeight: 12, itemHeight: 12,

View File

@ -21,7 +21,7 @@ export default function handler(msg: MessageEvent) {
console.log("[*] websocket: [unable to serialize] ---> ", msg); console.log("[*] websocket: [unable to serialize] ---> ", msg);
} }
// console.log("[CUTTING DATA] ---> ", serializedData); console.log("[CUTTING DATA] ---> ", serializedData);
if (serializedData == null) return; if (serializedData == null) return;

View File

@ -70,7 +70,8 @@ new XClient(
// 烟气处理相关数据 // 烟气处理相关数据
new XClient( new XClient(
// "ws://10.70.27.122:8080/websocket/message?userId=CUTTING", // "ws://10.70.27.122:8080/websocket/message?userId=CUTTING",
"ws://10.70.2.2:8080/websocket/message?userId=GAS" + newUser, // "ws://10.70.2.2:8080/websocket/message?userId=GAS" + newUser,
"ws://192.168.1.62:48082/websocket/message?userId=GAS" + newUser,
"SMOKE_DATA", "SMOKE_DATA",
smokeHandler smokeHandler
); );

View File

@ -1,7 +1,89 @@
import { store } from "../store"; import { store } from "../store";
type SmokeMessageItem = {
type: string;
realtime: {
SO2_float: number;
NOX_float: number;
O2_float: number;
dust_float: number;
};
dayTrend: {
SO2_float: Array<{
time: string;
value: number;
}>;
NOX_float: Array<{
time: string;
value: number;
}>;
O2_float: Array<{
time: string;
value: number;
}>;
dust_float: Array<{
time: string;
value: number;
}>;
};
weekTrend: {
SO2_float: Array<{
time: string;
value: number;
}>;
NOX_float: Array<{
time: string;
value: number;
}>;
O2_float: Array<{
time: string;
value: number;
}>;
dust_float: Array<{
time: string;
value: number;
}>;
};
monthTrend: {
SO2_float: Array<{
time: string;
value: number;
}>;
NOX_float: Array<{
time: string;
value: number;
}>;
O2_float: Array<{
time: string;
value: number;
}>;
dust_float: Array<{
time: string;
value: number;
}>;
};
yearTrend: {
SO2_float: Array<{
time: string;
value: number;
}>;
NOX_float: Array<{
time: string;
value: number;
}>;
O2_float: Array<{
time: string;
value: number;
}>;
dust_float: Array<{
time: string;
value: number;
}>;
};
};
export default function handler(msg: MessageEvent) { export default function handler(msg: MessageEvent) {
let serializedData: { type: string; data: any } | null = null; let serializedData: SmokeMessageItem | null = null;
try { try {
serializedData = JSON.parse(msg.data); serializedData = JSON.parse(msg.data);
} catch (error) { } catch (error) {
@ -11,9 +93,17 @@ export default function handler(msg: MessageEvent) {
case "exhaustGas": { case "exhaustGas": {
store.dispatch({ store.dispatch({
type: "smoke/setInfo", type: "smoke/setInfo",
payload: serializedData.data.realtime, payload: serializedData.realtime,
});
store.dispatch({
type: "smoke/setTrend",
payload: {
dayTrend: serializedData.dayTrend,
weekTrend: serializedData.weekTrend,
monthTrend: serializedData.monthTrend,
yearTrend: serializedData.yearTrend,
},
}); });
store.dispatch({ type: "smoke/setTrend", payload: serializedData.data });
break; break;
} }