Commit f2d77709 authored by 陈龙's avatar 陈龙

feat: 优化历史曲线名称显示

parent 65e26fda
......@@ -171,7 +171,7 @@
"js-sha256": "^0.10.1",
"jszip": "^3.5.0",
"less": "^3.13.1",
"mathjs": "^12.2.0",
"mathjs": "^11.2.0",
"mqtt-client": "^1.0.12",
"npm": "^9.6.4",
"optimize-css-assets-webpack-plugin": "^6.0.1",
......
......@@ -22,7 +22,7 @@ path: /
## 单图表
[//]: # (<code src="./demos/index.js"></code>)
<code src="./demos/index.js"></code>
## 单图表-状态
......@@ -30,7 +30,7 @@ path: /
## 单图表-频率
<code src="./demos/indexForFrequency.js"></code>
[//]: # (<code src="./demos/indexForFrequency.js"></code>)
[//]: # '## 移动端'
[//]: # '<code src="./demos/mobile.js"></code>'
......
......@@ -166,10 +166,16 @@ const deviceParams = [
"sensors": "IC",
"deviceType": "水源井"
}*/
{
/* {
"deviceCode": "JYJZ00000002",
"sensors": "频率,泵1状态",
"deviceType": "加压机组"
}*/
/*铁山*/
{
"deviceCode": "SZ00000001",
"deviceType": "水质",
"sensors": "PH,浑浊度,氨氮,总氮,总磷,溶解氧,水温,电导率,叶绿素a,藻密度,高锰酸盐指数"
}
];
......
......@@ -65,11 +65,13 @@ const currentOption = isMobile() ? MOBILE_OPTION : PC_OPTION;
* @param {any} data
* @param {boolean} contrast 是否为同期对比
* @param {any} contrastOption 同期对比周期配置, day|month
* @param nameWithSensor
* @param {boolean} isSingle 是否是单设备,单设备的名称不带设备名
* @returns
*/
const nameFormatter = (data, contrast, contrastOption, nameWithSensor) => {
const nameFormatter = (data, contrast, contrastOption, nameWithSensor, isSingle) => {
const {equipmentName, sensorName, unit, dataModel, dateFrom, dateTo} = data;
let name = nameWithSensor ? `${equipmentName}-${sensorName}` : equipmentName;
let name = nameWithSensor ? (isSingle?`${sensorName}`:`${equipmentName}-${sensorName}`) : equipmentName;
if (contrast) {
const time = dateFrom.slice(0, contrastOption === 'day' ? 10 : 7).replace(/-/g, '');
name = `${name}-${time}`;
......@@ -515,6 +517,11 @@ const returnXAxis = ({
_filterArr.push(special.special1.name);
}
// 生成series
// 单设备情况下,不显示设备名称
let deviceNumber = dataSource?.reduce((final, cur) => {
if (!final.includes(cur.stationCode)) final.push(cur.stationCode);
return final
}, [])?.length;
let series = dataSource
.filter((item) => {
if (item.sensorName === '是否在线') {
......@@ -524,7 +531,7 @@ const returnXAxis = ({
})
.map((item, index) => {
const {sensorName, unit} = item;
const name = nameFormatter(item, contrast, contrastOption, nameWithSensor);
const name = nameFormatter(item, contrast, contrastOption, nameWithSensor, deviceNumber === 1);
const data = dataAccessor(item, contrast, contrastOption);
const type = 'line';
const areaStyle = areaStyleFormatter(item);
......
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