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
4be9d1c4
Commit
4be9d1c4
authored
Dec 14, 2022
by
崔佳豪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: 优化基础图表默认配置
parent
f4b77868
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
10 deletions
+20
-10
ECharts.js
packages/base-components/BasicChart/src/ECharts.js
+7
-3
default.js
packages/base-components/BasicChart/src/utils/default.js
+6
-3
tooltip.js
packages/base-components/BasicChart/src/utils/tooltip.js
+7
-4
No files found.
packages/base-components/BasicChart/src/ECharts.js
View file @
4be9d1c4
import
React
,
{
useMemo
}
from
'react'
;
import
React
,
{
memo
,
useMemo
}
from
'react'
;
import
{
ConfigProvider
}
from
'antd'
;
import
classNames
from
'classnames'
;
import
ReactEcharts
from
'echarts-for-react'
;
import
{
omit
}
from
'lodash'
;
import
buildOption
from
'./utils'
;
const
ECharts
=
React
.
forwardRef
((
props
,
ref
)
=>
{
const
ECharts
=
memo
(
React
.
forwardRef
((
props
,
ref
)
=>
{
const
{
getPrefixCls
}
=
React
.
useContext
(
ConfigProvider
.
ConfigContext
);
const
prefixCls
=
getPrefixCls
(
'basic-chart'
);
...
...
@@ -16,6 +17,8 @@ const ECharts = React.forwardRef((props, ref) => {
// const chartProps = pick(props, ['option', 'notMerge', 'lazyUpdate', 'style', 'className', 'theme', 'onChartReady', 'loadingOption', 'showLoading', 'onEvents', 'opts']);
console
.
log
(
'update '
);
return
(
<
ReactEcharts
ref
=
{
ref
}
...
...
@@ -24,6 +27,7 @@ const ECharts = React.forwardRef((props, ref) => {
{...
chartProps
}
/
>
);
});
}),
);
export
default
ECharts
;
packages/base-components/BasicChart/src/utils/default.js
View file @
4be9d1c4
...
...
@@ -13,6 +13,8 @@ export const buildDefaultTitle = (option) => {
const
{
show
,
text
}
=
title
??
{};
if
(
show
&&
text
)
{
return
{
left
:
12
,
top
:
12
,
textStyle
:
{
rich
:
{
prefix
:
{
...
...
@@ -25,7 +27,6 @@ export const buildDefaultTitle = (option) => {
fontFamily
:
'Microsoft YaHei'
,
fontWeight
:
'bold'
,
color
:
'#333333'
,
lineHeight
:
28
,
padding
:
[
0
,
0
,
0
,
10
],
},
suffix
:
{
...
...
@@ -53,16 +54,18 @@ export const buildDefaultGrid = (option) => {
const
hasName
=
axisArr
.
some
((
d
)
=>
!!
d
.
name
)
||
seriesArr
.
some
((
d
)
=>
!!
d
.
unit
);
const
hasTitle
=
!!
title
&&
title
.
show
;
const
top
=
hasTitle
&&
hasName
?
70
:
50
;
return
{
right
:
40
,
left
:
60
,
top
};
return
{
right
:
40
,
left
:
60
,
top
,
bottom
:
40
};
};
export
const
defaultLegend
=
{
show
:
true
,
right
:
40
,
right
:
20
,
top
:
20
,
icon
:
'react'
,
itemWidth
:
14
,
itemHeight
:
8
,
itemGap
:
20
,
padding
:
[
0
,
0
,
0
,
80
],
// 给标题留够空间
textStyle
:
{
padding
:
[
0
,
0
,
0
,
4
],
color
:
'#2d2d2d'
,
...
...
packages/base-components/BasicChart/src/utils/tooltip.js
View file @
4be9d1c4
import
_
from
'lodash'
;
import
moment
from
'moment'
;
const
isArray
=
(
arr
)
=>
Array
.
isArray
(
arr
);
...
...
@@ -130,10 +131,12 @@ const colorAccessor = (param) => {
*/
const
headTemplate
=
(
option
,
param
)
=>
{
if
(
!
param
)
return
''
;
const
{
name
,
axisValueLabel
}
=
param
;
return
`<div style="border-bottom: 1px solid #F0F0F0; color: #808080; margin-bottom: 5px; padding-bottom: 5px;">
${
name
||
axisValueLabel
}
</div>`
;
const
{
name
,
axisValueLabel
,
axisType
,
axisValue
}
=
param
;
const
{
tooltip
}
=
option
;
const
{
timeFormat
=
'YYYY-MM-DD HH:mm:ss'
}
=
tooltip
??
{};
const
text
=
axisType
===
'xAxis.time'
?
moment
(
axisValue
).
format
(
timeFormat
)
:
name
||
axisValueLabel
;
return
`<div style="border-bottom: 1px solid #F0F0F0; color: #808080; margin-bottom: 5px; padding-bottom: 5px;">
${
text
}
</div>`
;
};
/**
...
...
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