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
a7f8ce51
Commit
a7f8ce51
authored
Oct 07, 2023
by
陈龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 标题被legend覆盖问题的优化;相同数据的轴合并
parent
e3b48dbb
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
21 deletions
+27
-21
legend.js
packages/base-components/BasicChart/src/utils/legend.js
+0
-2
GridChart.js
packages/extend-components/EC_HistoryView/src/GridChart.js
+21
-13
index.js
packages/extend-components/EC_HistoryView/src/demos/index.js
+6
-6
utils.js
packages/extend-components/EC_HistoryView/src/utils.js
+0
-0
No files found.
packages/base-components/BasicChart/src/utils/legend.js
View file @
a7f8ce51
...
@@ -18,8 +18,6 @@ export const buildDefaultLegend = (option) => {
...
@@ -18,8 +18,6 @@ export const buildDefaultLegend = (option) => {
textStyle
:
{
textStyle
:
{
padding
:
[
0
,
0
,
0
,
4
],
padding
:
[
0
,
0
,
0
,
4
],
color
:
'#2d2d2d'
,
color
:
'#2d2d2d'
,
width
:
120
,
overflow
:
'truncate'
},
},
tooltip
:{
tooltip
:{
show
:
true
show
:
true
...
...
packages/extend-components/EC_HistoryView/src/GridChart.js
View file @
a7f8ce51
import
React
,
{
memo
,
useMemo
}
from
'react'
;
import
React
,
{
memo
,
useMemo
}
from
'react'
;
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
{
BasicChart
}
from
'@wisdom-components/basicchart'
;
import
{
BasicChart
}
from
'@wisdom-components/basicchart'
;
import
PandaEmpty
from
'@wisdom-components/empty'
;
import
PandaEmpty
from
'@wisdom-components/empty'
;
import
optionGenerator
from
'./utils'
;
import
optionGenerator
from
'./utils'
;
const
ChartTitle
=
({
prefixCls
,
title
,
unit
})
=>
{
const
ChartTitle
=
({
prefixCls
,
title
,
unit
})
=>
{
const
cls
=
`
${
prefixCls
}
-grid-item-title`
;
const
cls
=
`
${
prefixCls
}
-grid-item-title`
;
return
(
return
(
<
div
className
=
{
cls
}
>
<
div
className
=
{
cls
}
>
...
@@ -13,7 +13,6 @@ const ChartTitle = ({ prefixCls, title, unit }) => {
...
@@ -13,7 +13,6 @@ const ChartTitle = ({ prefixCls, title, unit }) => {
<
/div
>
<
/div
>
);
);
};
};
const
GridChart
=
memo
((
props
)
=>
{
const
GridChart
=
memo
((
props
)
=>
{
const
{
const
{
dataSource
,
dataSource
,
...
@@ -22,11 +21,11 @@ const GridChart = memo((props) => {
...
@@ -22,11 +21,11 @@ const GridChart = memo((props) => {
smooth
=
true
,
smooth
=
true
,
curveCenter
,
curveCenter
,
}
=
props
;
}
=
props
;
const
{
prefixCls
}
=
props
;
const
{
prefixCls
}
=
props
;
const
gridData
=
useMemo
(()
=>
{
const
gridData
=
useMemo
(()
=>
{
const
grids
=
dataSource
.
reduce
((
pre
,
item
,
index
)
=>
{
const
grids
=
dataSource
.
reduce
((
pre
,
item
,
index
)
=>
{
const
{
sensorName
,
deviceType
}
=
item
;
const
{
sensorName
,
deviceType
}
=
item
;
const
key
=
`
${
deviceType
}
_
${
sensorName
}
`
;
// 同设备类型同指标才在同一组
const
key
=
`
${
deviceType
}
_
${
sensorName
}
`
;
// 同设备类型同指标才在同一组
let
grid
=
pre
.
find
((
g
)
=>
g
.
key
===
key
);
let
grid
=
pre
.
find
((
g
)
=>
g
.
key
===
key
);
if
(
!
grid
)
{
if
(
!
grid
)
{
...
@@ -46,21 +45,27 @@ const GridChart = memo((props) => {
...
@@ -46,21 +45,27 @@ const GridChart = memo((props) => {
const
options
=
useMemo
(()
=>
{
const
options
=
useMemo
(()
=>
{
let
_options
=
gridData
.
map
((
item
)
=>
{
let
_options
=
gridData
.
map
((
item
)
=>
{
const
{
key
,
list
,
equipmentName
,
sensorName
,
stationCode
,
unit
}
=
item
;
const
{
key
,
list
,
equipmentName
,
sensorName
,
stationCode
,
unit
}
=
item
;
let
max
=
300
;
// 5:左侧竖条的宽度;10:标题部分的左侧margin;
// sensorName长度*单个宽度16.7;5:单位部分的左侧margin;
// 91:单位部分的宽度(格式固定,宽度相对固定)
let
maxTitleLength
=
5
+
10
+
sensorName
.
length
*
16.7
+
5
+
91
;
let
finalLength
=
maxTitleLength
>
max
?
max
:
maxTitleLength
const
cusOption
=
{
const
cusOption
=
{
title
:
{
title
:
{
show
:
true
,
show
:
true
,
// text: `{prefix|}{t|${sensorName}}${unit ? '{suffix|(单位:' + unit + ')}' : ''}`,
// text: `{prefix|}{t|${sensorName}}${unit ? '{suffix|(单位:' + unit + ')}' : ''}`,
text
:
' '
,
text
:
' '
,
textStyle
:
{
textStyle
:
{
width
:
200
,
width
:
finalLength
,
overflow
:
'truncate'
,
overflow
:
'truncate'
,
},
},
},
},
legend
:
{
legend
:
{
// orient: 'vertical',
// orient: 'vertical',
itemGap
:
10
,
itemGap
:
10
,
padding
:
[
0
,
0
,
0
,
200
],
padding
:
[
0
,
0
,
0
,
finalLength
],
textStyle
:
{
textStyle
:
{
width
:
120
,
width
:
120
,
overflow
:
'truncate'
,
overflow
:
'truncate'
,
...
@@ -71,7 +76,10 @@ const GridChart = memo((props) => {
...
@@ -71,7 +76,10 @@ const GridChart = memo((props) => {
curveCenter
,
curveCenter
,
nameWithSensor
:
false
,
nameWithSensor
:
false
,
showGridLine
:
true
,
showGridLine
:
true
,
isMultiple
:
gridData
.
length
>
1
});
});
// 在多图表里,底部缩放条的高度减小
return
{
return
{
key
,
key
,
option
:
option
,
option
:
option
,
...
@@ -83,7 +91,7 @@ const GridChart = memo((props) => {
...
@@ -83,7 +91,7 @@ const GridChart = memo((props) => {
return
(
return
(
<
div
className
=
{
`
${
prefixCls
}
-grid`
}
>
<
div
className
=
{
`
${
prefixCls
}
-grid`
}
>
{
options
.
map
((
item
,
index
)
=>
{
{
options
.
map
((
item
,
index
)
=>
{
const
{
sensorName
,
unit
}
=
gridData
[
index
];
const
{
sensorName
,
unit
}
=
gridData
[
index
];
const
isEmpty
=
const
isEmpty
=
!
item
.
option
.
series
.
length
||
!
item
.
option
.
series
.
length
||
!
item
.
option
.
series
.
find
((
e
)
=>
e
.
data
&&
e
.
data
.
length
>
0
);
!
item
.
option
.
series
.
find
((
e
)
=>
e
.
data
&&
e
.
data
.
length
>
0
);
...
@@ -97,12 +105,12 @@ const GridChart = memo((props) => {
...
@@ -97,12 +105,12 @@ const GridChart = memo((props) => {
}}
}}
>
>
<
div
className
=
{
`
${
prefixCls
}
-grid-item-wrap`
}
>
<
div
className
=
{
`
${
prefixCls
}
-grid-item-wrap`
}
>
<
ChartTitle
prefixCls
=
{
prefixCls
}
title
=
{
sensorName
}
unit
=
{
unit
}
/
>
<
ChartTitle
prefixCls
=
{
prefixCls
}
title
=
{
sensorName
}
unit
=
{
unit
}
/
>
{
isEmpty
?
(
{
isEmpty
?
(
<
PandaEmpty
/>
<
PandaEmpty
/>
)
:
(
)
:
(
<
BasicChart
<
BasicChart
style
=
{{
width
:
'100%'
,
height
:
'100%'
}}
style
=
{{
width
:
'100%'
,
height
:
'100%'
}}
option
=
{
item
.
option
}
option
=
{
item
.
option
}
notMerge
notMerge
/>
/>
...
...
packages/extend-components/EC_HistoryView/src/demos/index.js
View file @
a7f8ce51
...
@@ -4,25 +4,25 @@ import { MobileHistoryChart } from "../mobile";
...
@@ -4,25 +4,25 @@ import { MobileHistoryChart } from "../mobile";
const
deviceParams
=
[
const
deviceParams
=
[
/*10.182*/
/*10.182*/
/*
{
/*
{
deviceCode: 'EGBF00000141',
deviceCode: 'EGBF00000141',
// sensors: '进水压力,出水瞬时流量,出水累计流量',
// sensors: '进水压力,出水瞬时流量,出水累计流量',
sensors: '进水压力',
sensors: '进水压力',
deviceType: '熊猫二供泵房',
deviceType: '熊猫二供泵房',
pointAddressID: 208,
pointAddressID: 208,
},
*/
},*/
/* {
/* {
"deviceCode": "SYJ00000008",
"deviceCode": "SYJ00000008",
"sensors": "瞬时流量",
"sensors": "瞬时流量",
"deviceType": "水源井"
"deviceType": "水源井"
},
},
*/
{
{
deviceCode
:
'EGJZ00000197'
,
deviceCode
:
'EGJZ00000197'
,
sensors
:
'进水压力,出水压力,出水瞬时流量,出水累计流量'
,
sensors
:
'进水压力,出水压力,出水瞬时流量,出水累计流量'
,
// sensors: '1#变频器运行频率',
// sensors: '1#变频器运行频率',
deviceType
:
'二供机组'
,
deviceType
:
'二供机组'
,
// pointAddressID: 208,
// pointAddressID: 208,
},
*/
},
/* {
/* {
deviceCode: 'EGJZ00000198',
deviceCode: 'EGJZ00000198',
sensors: '进水压力,出水压力,出水瞬时流量,出水累计流量',
sensors: '进水压力,出水压力,出水瞬时流量,出水累计流量',
...
@@ -63,7 +63,7 @@ const deviceParams = [
...
@@ -63,7 +63,7 @@ const deviceParams = [
"sensors": "瞬时流量",
"sensors": "瞬时流量",
"deviceType": "水厂"
"deviceType": "水厂"
}, */
}, */
{
/*
{
"deviceCode": "JFJ00000001",
"deviceCode": "JFJ00000001",
"sensors": "沉淀池投矾量瞬时,",
"sensors": "沉淀池投矾量瞬时,",
"deviceType": "加矾间"
"deviceType": "加矾间"
...
@@ -92,7 +92,7 @@ const deviceParams = [
...
@@ -92,7 +92,7 @@ const deviceParams = [
deviceCode: 'EGJZ00000027',
deviceCode: 'EGJZ00000027',
sensors: '2#变频器运行频率',
sensors: '2#变频器运行频率',
deviceType: '二供机组',
deviceType: '二供机组',
},
},
*/
/*确山*/
/*确山*/
/*泵3状态*/
/*泵3状态*/
/* {
/* {
...
...
packages/extend-components/EC_HistoryView/src/utils.js
View file @
a7f8ce51
This diff is collapsed.
Click to expand it.
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