Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wisdom-components
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
wisdom-components
Commits
dd8a3519
Commit
dd8a3519
authored
Aug 16, 2023
by
陈龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复抽稀为0的问题
parent
536d7df1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
23 deletions
+21
-23
index.js
packages/extend-components/EC_HistoryView/src/demos/index.js
+8
-7
index.js
packages/extend-components/EC_HistoryView/src/index.js
+6
-7
utils.js
packages/extend-components/EC_HistoryView/src/utils.js
+7
-9
No files found.
packages/extend-components/EC_HistoryView/src/demos/index.js
View file @
dd8a3519
...
...
@@ -3,12 +3,13 @@ import HistoryView from '../index';
import
{
MobileHistoryChart
}
from
"../mobile"
;
const
deviceParams
=
[
/*
{
{
deviceCode
:
'EGBF00000141'
,
sensors: '进水压力,出水瞬时流量,出水累计流量',
// sensors: '进水压力,出水瞬时流量,出水累计流量',
sensors
:
'进水压力'
,
deviceType
:
'二供泵房'
,
pointAddressID
:
208
,
},
*/
},
/* {
// deviceCode: 'EGBF00000002',
// deviceCode: 'EGBF00000018',
...
...
@@ -20,17 +21,17 @@ const deviceParams = [
deviceType: '熊猫压力表',
pointAddressID: 4,
},*/
/*
{
/*
{
deviceCode: 'EGJZ00000226',
sensors: '出水压力',
deviceType: '二供机组',
pointAddressID: 4,
},
*/
{
},*/
/*
{
"deviceCode": "LLJ00000055",
"sensors": "正累计流量,瞬时流量,是否在线",
"deviceType": "流量计"
}
}
*/
/* {
"deviceCode": "EGJZ00000163",
"sensors": "进水压力,是否在线",
...
...
packages/extend-components/EC_HistoryView/src/index.js
View file @
dd8a3519
...
...
@@ -610,7 +610,6 @@ const HistoryView = (props) => {
// 格式化时间对齐数据, 生成行数
const timeData = {};
const buildDefaultData = (time) => {
const obj = {key: time, time: time};
data.forEach((item, index) => {
...
...
@@ -683,11 +682,11 @@ const HistoryView = (props) => {
return Promise.resolve();
});
};
const handleTime = (diffDays, base = 1000) => {
/*
const handleTime = (diffDays, base = 1000) => {
let unit = 'min', zoom = 0;
zoom = Math.ceil(
diffDays * 24 * 60 / 1000).toFixed(
);
zoom = Math.ceil(
(diffDays || 1) * 24 * 60 / base).toFixed(0
);
return {unit, zoom};
}
}
*/
const handleDataThinKey = (diffDays) => {
// edit by zy 根据选择的时长控制抽稀频度
if (diffDays >= 7 && diffDays < 15) {
...
...
@@ -723,7 +722,7 @@ const HistoryView = (props) => {
if (i.sensors && i.deviceCode && i.deviceCode)
acrossTables.push(_.omit(i, ['pointAddressID']));
});
if (!acrossTables?.length
||
!dateRange.length) {
if (!acrossTables?.length
||
!dateRange.length) {
handleTableData([]);
setChartDataSource([]);
return;
...
...
@@ -740,8 +739,8 @@ const HistoryView = (props) => {
isBoxPlots: isBoxPlots,
};
let diffDays = moment(item.dateTo).diff(moment(item.dateFrom), 'days');
//
let zoomParam = activeTabKey === 'curve' ? handleDataThinKey(diffDays) : {};
let zoomParam = activeTabKey === 'curve' ? handleTime(diffDays,50) : {};
let zoomParam = activeTabKey === 'curve' ? handleDataThinKey(diffDays) : {};
// let zoomParam = activeTabKey === 'curve' ? handleTime(diffDays, 100) : {}; // 备用方案
requestArr.push(getHistoryInfo({...param, ...zoomParam}));
});
setLoading(true);
...
...
packages/extend-components/EC_HistoryView/src/utils.js
View file @
dd8a3519
...
...
@@ -88,9 +88,7 @@ const nameFormatter = (data, contrast, contrastOption, nameWithSensor) => {
*/
const
dataAccessor
=
(
data
,
contrast
,
contrastOption
)
=>
{
const
dataModel
=
data
?.
dataModel
??
[];
let
_currentYear
=
moment
().
format
(
'YYYY'
);
const
formatStr
=
contrastOption
===
'day'
?
`
${
_currentYear
}
-01-01 HH:mm:00`
:
`
${
_currentYear
}
-01-DD HH:mm:00`
;
const
formatStr
=
contrastOption
===
'day'
?
'2020-01-01 HH:mm:00'
:
'2020-01-DD HH:mm:00'
;
return
dataModel
.
filter
((
item
)
=>
item
.
sensorName
!==
'是否在线'
)
.
map
((
item
)
=>
{
...
...
@@ -304,10 +302,10 @@ export const buildDefaultLegend = (option) => {
};
};
const
headTemplate
=
(
param
)
=>
{
const
headTemplate
=
(
param
,
opt
)
=>
{
if
(
!
param
)
return
''
;
const
{
name
,
axisValueLabel
,
axisType
,
axisValue
}
=
param
;
const
timeFormat
=
'YYYY-MM-DD HH:mm:ss'
;
const
timeFormat
=
opt
&&
opt
.
contrast
?
(
opt
.
contrastOption
===
'day'
?
'HH:mm:ss'
:
'YYYY-MM-DD'
)
:
'YYYY-MM-DD HH:mm:ss'
;
const
text
=
axisType
===
'xAxis.time'
?
moment
(
axisValue
).
format
(
timeFormat
)
:
name
||
axisValueLabel
;
return
`<div style="border-bottom: 1px solid #F0F0F0; color: #808080; margin-bottom:
${
handlePx
(
5
,
'px'
)}
; padding-bottom:
${
handlePx
(
5
,
'px'
)}
;">
${
text
}
</div>`
;
...
...
@@ -354,18 +352,18 @@ const seriesTemplate = (param, unit) => {
<
/div
>
`;
};
const tooltipAccessor = (unit) => {
const tooltipAccessor = (unit
, contrastOption
) => {
return {
formatter: function (params, ticket, callback) {
let tooltipHeader = '';
let tooltipContent = '';
if (isArray(params)) {
tooltipHeader = headTemplate(params[0]);
tooltipHeader = headTemplate(params[0]
, contrastOption
);
params.forEach((param) => {
tooltipContent += seriesTemplate(param, unit?.[param?.seriesIndex]);
});
} else {
tooltipHeader = headTemplate(params);
tooltipHeader = headTemplate(params
, contrastOption
);
tooltipContent += seriesTemplate(params, unit?.[params?.seriesIndex]);
}
return `
...
...
@@ -725,7 +723,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
};
}
}
else
{
tooltip
=
tooltipAccessor
(
series
.
map
(
item
=>
item
.
unit
));
tooltip
=
tooltipAccessor
(
series
.
map
(
item
=>
item
.
unit
)
,
{
contrastOption
,
contrast
}
);
}
tooltip
.
timeFormat
=
tooltipTimeFormat
;
let
_legendData
=
series
.
filter
(
item
=>
!
[
'最大值'
,
'最小值'
].
includes
(
item
.
name
)).
map
(
item
=>
item
.
name
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment