This commit is contained in:
lb 2024-01-04 16:44:15 +08:00
parent ac772e2caf
commit e1e73b341d
4 changed files with 19 additions and 10 deletions

View File

@ -145,7 +145,7 @@ function getOptions(data, chart_type) {
axisPointer: { axisPointer: {
type: "shadow", type: "shadow",
}, },
className: 'xc-chart-tooltip' className: "xc-chart-tooltip",
// backgroundColor: '' // backgroundColor: ''
}, },
xAxis: { xAxis: {
@ -207,7 +207,9 @@ function getOptions(data, chart_type) {
fontSize: 10, fontSize: 10,
color: "#fffc", color: "#fffc",
}, },
data: (dataList || []).map((item) => item.value), data: (dataList || []).map((item) =>
item.value == null || isNaN(+item.value) ? null : (+item.value).toFixed(2)
),
}, },
], ],
}; };

View File

@ -147,7 +147,10 @@ function getOptions(period, trend) {
}, },
}, },
series: { series: {
data: trend[period].map((item) => item.qty), // !(item.value == null || isNaN(+item.value)) ? (+item.value).toFixed(2) : null
data: trend[period].map((item) =>
item.qty == null || isNaN(+item.qty) ? null : (+item.qty).toFixed(2)
),
type: "line", type: "line",
symbol: "circle", symbol: "circle",
symbolSize: 6, symbolSize: 6,

View File

@ -4,7 +4,7 @@ export function lunarYear(year) {
return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0); return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0);
} }
export function getOptions(period, source, trend, options={}) { export function getOptions(period, source, trend, options = {}) {
if (trend[period].length == 0) return null; if (trend[period].length == 0) return null;
const today = new Date(); const today = new Date();
const currentYear = today.getFullYear(); const currentYear = today.getFullYear();
@ -40,7 +40,7 @@ export function getOptions(period, source, trend, options={}) {
.fill(1) .fill(1)
.map((_, index) => { .map((_, index) => {
if (period == "week") { if (period == "week") {
const dtimestamp = today - (index+1) * 24 * 60 * 60 * 1000; const dtimestamp = today - (index + 1) * 24 * 60 * 60 * 1000;
return `${new Date(dtimestamp).getMonth() + 1}.${new Date( return `${new Date(dtimestamp).getMonth() + 1}.${new Date(
dtimestamp dtimestamp
).getDate()}`; ).getDate()}`;
@ -65,7 +65,7 @@ export function getOptions(period, source, trend, options={}) {
}, },
}, },
yAxis: { yAxis: {
name: source == 'elec' ? '单位/kWh' : "单位/Nm³", name: source == "elec" ? "单位/kWh" : "单位/Nm³",
nameTextStyle: { nameTextStyle: {
color: "#fff", color: "#fff",
fontSize: 10, fontSize: 10,
@ -96,10 +96,14 @@ export function getOptions(period, source, trend, options={}) {
{ {
data: data:
source == "elec" source == "elec"
? trend[period].map((item) => item.qty) ? trend[period].map((item) =>
item.qty == null || isNaN(+item.qty)
? null
: (+item.qty).toFixed(2)
)
: trend[period], : trend[period],
type: "line", type: "line",
symbol: 'circle', symbol: "circle",
symbolSize: 6, symbolSize: 6,
areaStyle: { areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
@ -119,6 +123,6 @@ export function getOptions(period, source, trend, options={}) {
className: "xc-chart-tooltip", className: "xc-chart-tooltip",
// backgroundColor: '' // backgroundColor: ''
}, },
...options ...options,
}; };
} }

View File

@ -124,8 +124,8 @@ new XClient(
new XClient( new XClient(
{ {
url: "ws://10.70.2.2:8080/websocket/message?userId=ENERGY" + newUser, url: "ws://10.70.2.2:8080/websocket/message?userId=ENERGY" + newUser,
// url: "ws://192.168.1.74:48080/websocket/message?userId=ENERGY" + newUser,
name: "MES_DATA", name: "MES_DATA",
// "ws://192.168.1.74:48080/websocket/message?userId=ENERGY" + newUser,
// "ws://192.168.1.74:48080/websocket/message?userId=ENERGY111", // "ws://192.168.1.74:48080/websocket/message?userId=ENERGY111",
}, },
energeHandler energeHandler