Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
钟摆人-Puppet゜
ant-design-pro
提交
782b8035
A
ant-design-pro
项目概览
钟摆人-Puppet゜
/
ant-design-pro
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ant-design-pro
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
782b8035
编写于
6月 15, 2018
作者:
陈
陈帅
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimize performance
上级
e9799a33
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
137 addition
and
94 deletion
+137
-94
.webpackrc.js
.webpackrc.js
+19
-0
src/components/Charts/Bar/index.js
src/components/Charts/Bar/index.js
+15
-17
src/components/Charts/ChartCard/index.js
src/components/Charts/ChartCard/index.js
+69
-51
src/components/Charts/Pie/index.js
src/components/Charts/Pie/index.js
+20
-16
src/components/Charts/WaterWave/index.js
src/components/Charts/WaterWave/index.js
+14
-10
未找到文件。
.webpackrc.js
浏览文件 @
782b8035
...
@@ -28,4 +28,23 @@ export default {
...
@@ -28,4 +28,23 @@ export default {
publicPath
:
'
/
'
,
publicPath
:
'
/
'
,
disableDynamicImport
:
true
,
disableDynamicImport
:
true
,
hash
:
true
,
hash
:
true
,
cssLoaderOptions
:
{
modules
:
true
,
getLocalIdent
:
(
context
,
localIdentName
,
localName
)
=>
{
if
(
context
.
resourcePath
.
includes
(
'
node_modules
'
))
{
return
localName
;
}
let
antdProPath
=
context
.
resourcePath
.
match
(
/src
(
.*
)
/
)[
1
];
if
(
context
.
resourcePath
.
includes
(
'
components
'
))
{
antdProPath
=
antdProPath
.
replace
(
'
components/
'
,
''
);
}
const
arr
=
antdProPath
.
split
(
'
/
'
)
.
map
(
a
=>
a
.
replace
(
/
([
A-Z
])
/g
,
'
-$1
'
))
.
map
(
a
=>
a
.
toLowerCase
());
arr
.
pop
();
return
`antd-pro
${
arr
.
join
(
'
-
'
)}
-
${
localName
}
`
.
replace
(
'
--
'
,
'
-
'
);
},
},
};
};
src/components/Charts/Bar/index.js
浏览文件 @
782b8035
...
@@ -25,27 +25,25 @@ class Bar extends Component {
...
@@ -25,27 +25,25 @@ class Bar extends Component {
if
(
!
this
.
node
)
{
if
(
!
this
.
node
)
{
return
;
return
;
}
}
requestAnimationFrame
(()
=>
{
const
canvasWidth
=
this
.
node
.
parentNode
.
clientWidth
;
const
canvasWidth
=
this
.
node
.
parentNode
.
clientWidth
;
const
{
data
=
[],
autoLabel
=
true
}
=
this
.
props
;
const
{
data
=
[],
autoLabel
=
true
}
=
this
.
props
;
if
(
!
autoLabel
)
{
if
(
!
autoLabel
)
{
return
;
return
;
}
}
const
minWidth
=
data
.
length
*
30
;
const
minWidth
=
data
.
length
*
30
;
const
{
autoHideXLabels
}
=
this
.
state
;
const
{
autoHideXLabels
}
=
this
.
state
;
if
(
canvasWidth
<=
minWidth
)
{
if
(
canvasWidth
<=
minWidth
)
{
if
(
!
autoHideXLabels
)
{
if
(
!
autoHideXLabels
)
{
this
.
setState
({
autoHideXLabels
:
true
,
});
}
}
else
if
(
autoHideXLabels
)
{
this
.
setState
({
this
.
setState
({
autoHideXLabels
:
fals
e
,
autoHideXLabels
:
tru
e
,
});
});
}
}
});
}
else
if
(
autoHideXLabels
)
{
this
.
setState
({
autoHideXLabels
:
false
,
});
}
}
}
handleRoot
=
n
=>
{
handleRoot
=
n
=>
{
...
...
src/components/Charts/ChartCard/index.js
浏览文件 @
782b8035
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
Card
,
Spin
}
from
'
antd
'
;
import
{
Card
}
from
'
antd
'
;
import
classNames
from
'
classnames
'
;
import
classNames
from
'
classnames
'
;
import
styles
from
'
./index.less
'
;
import
styles
from
'
./index.less
'
;
...
@@ -19,59 +19,77 @@ const renderTotal = total => {
...
@@ -19,59 +19,77 @@ const renderTotal = total => {
return
totalDom
;
return
totalDom
;
};
};
const
ChartCard
=
({
class
ChartCard
extends
React
.
PureComponent
{
loading
=
false
,
state
=
{
contentHeight
,
loading
:
true
,
title
,
};
avatar
,
componentDidMount
()
{
action
,
requestAnimationFrame
(()
=>
{
total
,
this
.
setState
({
footer
,
loading
:
false
,
children
,
});
...
rest
});
})
=>
{
}
const
content
=
(
renderConnet
=
()
=>
{
<
div
className
=
{
styles
.
chartCard
}
>
const
{
contentHeight
,
title
,
avatar
,
action
,
total
,
footer
,
children
,
loading
}
=
this
.
props
;
<
div
if
(
loading
||
this
.
state
.
loading
)
{
className
=
{
classNames
(
styles
.
chartTop
,
{
return
false
;
[
styles
.
chartTopMargin
]:
!
children
&&
!
footer
,
}
})}
return
(
>
<
div
className
=
{
styles
.
chartCard
}
>
<
div
className
=
{
styles
.
avatar
}
>
{
avatar
}
<
/div
>
<
div
className
=
{
styles
.
metaWrap
}
>
<
div
className
=
{
styles
.
meta
}
>
<
span
className
=
{
styles
.
title
}
>
{
title
}
<
/span
>
<
span
className
=
{
styles
.
action
}
>
{
action
}
<
/span
>
<
/div
>
{
renderTotal
(
total
)}
<
/div
>
<
/div
>
{
children
&&
(
<
div
className
=
{
styles
.
content
}
style
=
{{
height
:
contentHeight
||
'
auto
'
}}
>
<
div
className
=
{
contentHeight
&&
styles
.
contentFixed
}
>
{
children
}
<
/div
>
<
/div
>
)}
{
footer
&&
(
<
div
<
div
className
=
{
classNames
(
styles
.
footer
,
{
className
=
{
classNames
(
styles
.
chartTop
,
{
[
styles
.
footerMargin
]:
!
children
,
[
styles
.
chartTopMargin
]:
!
children
&&
!
footer
,
})}
})}
>
>
{
footer
}
<
div
className
=
{
styles
.
avatar
}
>
{
avatar
}
<
/div
>
<
div
className
=
{
styles
.
metaWrap
}
>
<
div
className
=
{
styles
.
meta
}
>
<
span
className
=
{
styles
.
title
}
>
{
title
}
<
/span
>
<
span
className
=
{
styles
.
action
}
>
{
action
}
<
/span
>
<
/div
>
{
renderTotal
(
total
)}
<
/div
>
<
/div
>
<
/div
>
)}
{
children
&&
(
<
/div
>
<
div
className
=
{
styles
.
content
}
style
=
{{
height
:
contentHeight
||
'
auto
'
}}
>
);
<
div
className
=
{
contentHeight
&&
styles
.
contentFixed
}
>
{
children
}
<
/div
>
<
/div
>
return
(
)}
<
Card
bodyStyle
=
{{
padding
:
'
20px 24px 8px 24px
'
}}
{...
rest
}
>
{
footer
&&
(
{
<
div
<
Spin
spinning
=
{
loading
}
wrapperClassName
=
{
styles
.
spin
}
>
className
=
{
classNames
(
styles
.
footer
,
{
{
content
}
[
styles
.
footerMargin
]:
!
children
,
<
/Spin
>
})}
}
>
<
/Card
>
{
footer
}
);
<
/div
>
};
)}
<
/div
>
);
};
render
()
{
const
{
loading
=
false
,
contentHeight
,
title
,
avatar
,
action
,
total
,
footer
,
children
,
...
rest
}
=
this
.
props
;
return
(
<
Card
loading
=
{
loading
||
this
.
state
.
loading
}
bodyStyle
=
{{
padding
:
'
20px 24px 8px 24px
'
}}
{...
rest
}
>
{
this
.
renderConnet
()}
<
/Card
>
);
}
}
export
default
ChartCard
;
export
default
ChartCard
;
src/components/Charts/Pie/index.js
浏览文件 @
782b8035
...
@@ -19,7 +19,13 @@ export default class Pie extends Component {
...
@@ -19,7 +19,13 @@ export default class Pie extends Component {
};
};
componentDidMount
()
{
componentDidMount
()
{
window
.
addEventListener
(
'
resize
'
,
this
.
resize
,
{
passive
:
true
});
window
.
addEventListener
(
'
resize
'
,
()
=>
{
requestAnimationFrame
(()
=>
this
.
resize
());
},
{
passive
:
true
}
);
}
}
componentDidUpdate
(
preProps
)
{
componentDidUpdate
(
preProps
)
{
...
@@ -66,24 +72,22 @@ export default class Pie extends Component {
...
@@ -66,24 +72,22 @@ export default class Pie extends Component {
@
Bind
()
@
Bind
()
@
Debounce
(
300
)
@
Debounce
(
300
)
resize
()
{
resize
()
{
requestAnimationFrame
(()
=>
{
const
{
hasLegend
}
=
this
.
props
;
const
{
hasLegend
}
=
this
.
props
;
if
(
!
hasLegend
||
!
this
.
root
)
{
if
(
!
hasLegend
||
!
this
.
root
)
{
window
.
removeEventListener
(
'
resize
'
,
this
.
resize
);
window
.
removeEventListener
(
'
resize
'
,
this
.
resize
);
return
;
return
;
}
}
if
(
this
.
root
.
parentNode
.
clientWidth
<=
380
)
{
if
(
this
.
root
.
parentNode
.
clientWidth
<=
380
)
{
if
(
!
this
.
state
.
legendBlock
)
{
if
(
!
this
.
state
.
legendBlock
)
{
this
.
setState
({
legendBlock
:
true
,
});
}
}
else
if
(
this
.
state
.
legendBlock
)
{
this
.
setState
({
this
.
setState
({
legendBlock
:
fals
e
,
legendBlock
:
tru
e
,
});
});
}
}
});
}
else
if
(
this
.
state
.
legendBlock
)
{
this
.
setState
({
legendBlock
:
false
,
});
}
}
}
handleRoot
=
n
=>
{
handleRoot
=
n
=>
{
...
...
src/components/Charts/WaterWave/index.js
浏览文件 @
782b8035
...
@@ -17,7 +17,13 @@ export default class WaterWave extends PureComponent {
...
@@ -17,7 +17,13 @@ export default class WaterWave extends PureComponent {
this
.
renderChart
();
this
.
renderChart
();
this
.
resize
();
this
.
resize
();
});
});
window
.
addEventListener
(
'
resize
'
,
this
.
resize
,
{
passive
:
true
});
window
.
addEventListener
(
'
resize
'
,
()
=>
{
requestAnimationFrame
(()
=>
this
.
resize
());
},
{
passive
:
true
}
);
}
}
componentWillUnmount
()
{
componentWillUnmount
()
{
...
@@ -29,15 +35,13 @@ export default class WaterWave extends PureComponent {
...
@@ -29,15 +35,13 @@ export default class WaterWave extends PureComponent {
}
}
resize
=
()
=>
{
resize
=
()
=>
{
requestAnimationFrame
(()
=>
{
if
(
this
.
root
)
{
if
(
this
.
root
)
{
const
{
height
}
=
this
.
props
;
const
{
height
}
=
this
.
props
;
const
{
offsetWidth
}
=
this
.
root
.
parentNode
;
const
{
offsetWidth
}
=
this
.
root
.
parentNode
;
this
.
setState
({
this
.
setState
({
radio
:
offsetWidth
<
height
?
offsetWidth
/
height
:
1
,
radio
:
offsetWidth
<
height
?
offsetWidth
/
height
:
1
,
});
});
}
}
});
};
};
renderChart
()
{
renderChart
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录