Commit f94a56bb authored by 李纪文's avatar 李纪文

feat: 组态增加图层设置

parent 451437c1
......@@ -12,6 +12,10 @@ const HistoryTrend = (props) => {
const prefixCls = getPrefixCls('history-trend');
const { deviceCode, sensors, deviceType, changeSpin } = props;
const chartRef = useRef(null);
const infoRef = useRef({
decimalPoint: 2,
unit: '',
})
const [sensitive, setSensitive] = useState(10); // 敏感度
const [timeType, setTimeType] = useState('近7日'); // 时间
......@@ -76,6 +80,11 @@ const HistoryTrend = (props) => {
let historyData = [];
results.forEach((result) => {
const _historyData = result?.data?.[0]?.dataModel || [];
const info = result?.data?.[0] || {};
infoRef.current = {
decimalPoint: info?.decimalPoint || 2,
unit: info?.unit || ''
}
historyData = historyData.concat([..._historyData]);
});
console.log(historyData);
......@@ -161,11 +170,12 @@ const HistoryTrend = (props) => {
let max = Math.max(...pvArr);
let min = Math.min(...pvArr);
console.log(max, min);
const decimalPoint = infoRef.current.decimalPoint || 2;
const data = [
(min * (1 - sensitive / 100)).toFixed(2) * 1,
(min * (1 + sensitive / 100)).toFixed(2) * 1,
(max * (1 - sensitive / 100)).toFixed(2) * 1,
(max * (1 + sensitive / 100)).toFixed(2) * 1,
(min * (1 - sensitive / 100)).toFixed(decimalPoint) * 1,
(min * (1 + sensitive / 100)).toFixed(decimalPoint) * 1,
(max * (1 - sensitive / 100)).toFixed(decimalPoint) * 1,
(max * (1 + sensitive / 100)).toFixed(decimalPoint) * 1,
];
const color = ['#CB2D2D', '#0087F7'];
const name = ['低低限', '低限', '高限', '高高限'];
......
......@@ -80,7 +80,7 @@ const LimitCurve = (props) => {
<Modal
closable={false}
centered
width={width || '1200px'}
width={width || '1300px'}
footer={null}
open={open}
visible={open}
......
......@@ -37,9 +37,25 @@
display: flex;
}
&-propose-box {
display: flex;
flex-direction: column;
}
&-propose-list {
display: flex;
align-items: center;
margin-bottom: 5px;
&:last-of-type {
margin-bottom: 0px;
}
}
&-propose-select {
margin: 10px;
display: flex;
align-items: center;
}
&-value-list {
......
......@@ -54,3 +54,18 @@ export const chartArr = [
export const average = (arr) => {
return arr.reduce((acc, cur) => acc + cur, 0) / arr.length;
};
// 中位数方法
export const median = (data) => {
if (data.length === 0) return 0;
data.sort((a, b) => {
return a - b;
});
const half = Math.floor(data.length / 2);
if (data.length % 2) return data[half];
return (data[half - 1] + data[half]) / 2;
};
......@@ -2373,6 +2373,7 @@ const ConfigurationView = (props) => {
relinkableTo: true,
zOrder: 1,
},
new go.Binding('layerName', 'layerName').makeTwoWay(),
new go.Binding('fromSpot', 'fromPort', (d) => {
return spotConverter(d);
}),
......@@ -2422,6 +2423,7 @@ const ConfigurationView = (props) => {
relinkableTo: true,
zOrder: 1,
},
new go.Binding('layerName', 'layerName').makeTwoWay(),
new go.Binding('fromSpot', 'fromPort', function (d) {
return spotConverter(d);
}),
......
......@@ -3017,6 +3017,7 @@ const ConfigurationView = (props) => {
relinkableTo: true,
zOrder: 1,
},
new go.Binding('layerName', 'layerName').makeTwoWay(),
new go.Binding('fromSpot', 'fromPort', (d) => {
return spotConverter(d);
}),
......@@ -3066,6 +3067,7 @@ const ConfigurationView = (props) => {
relinkableTo: true,
zOrder: 1,
},
new go.Binding('layerName', 'layerName').makeTwoWay(),
new go.Binding('fromSpot', 'fromPort', function (d) {
return spotConverter(d);
}),
......
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