Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pro-blocks
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
pro-blocks
Commits
03e0ca45
Unverified
Commit
03e0ca45
authored
Oct 29, 2017
by
niko
Committed by
GitHub
Oct 29, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed:
https://github.com/ant-design/ant-design-pro/issues/33
(#42)
parent
d25b1121
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
99 additions
and
18 deletions
+99
-18
src/components/Charts/Bar/index.js
src/components/Charts/Bar/index.js
+55
-4
src/components/Charts/ChartCard/index.js
src/components/Charts/ChartCard/index.js
+18
-8
src/components/Charts/MiniArea/index.js
src/components/Charts/MiniArea/index.js
+1
-1
src/components/Charts/MiniBar/index.js
src/components/Charts/MiniBar/index.js
+1
-1
src/components/Charts/index.less
src/components/Charts/index.less
+7
-1
src/components/Charts/index.md
src/components/Charts/index.md
+1
-0
src/routes/Dashboard/Analysis.js
src/routes/Dashboard/Analysis.js
+16
-3
No files found.
src/components/Charts/Bar/index.js
View file @
03e0ca45
import
React
,
{
PureComponent
}
from
'
react
'
;
import
React
,
{
PureComponent
}
from
'
react
'
;
import
G2
from
'
g2
'
;
import
G2
from
'
g2
'
;
import
Debounce
from
'
lodash-decorators/debounce
'
;
import
equal
from
'
../equal
'
;
import
equal
from
'
../equal
'
;
import
styles
from
'
../index.less
'
;
import
styles
from
'
../index.less
'
;
class
Bar
extends
PureComponent
{
class
Bar
extends
PureComponent
{
state
=
{
autoHideXLabels
:
false
,
}
componentDidMount
()
{
componentDidMount
()
{
this
.
renderChart
(
this
.
props
.
data
);
this
.
renderChart
(
this
.
props
.
data
);
window
.
addEventListener
(
'
resize
'
,
this
.
resize
);
}
}
componentWillReceiveProps
(
nextProps
)
{
componentWillReceiveProps
(
nextProps
)
{
...
@@ -15,17 +22,53 @@ class Bar extends PureComponent {
...
@@ -15,17 +22,53 @@ class Bar extends PureComponent {
}
}
componentWillUnmount
()
{
componentWillUnmount
()
{
window
.
removeEventListener
(
'
resize
'
,
this
.
resize
);
if
(
this
.
chart
)
{
if
(
this
.
chart
)
{
this
.
chart
.
destroy
();
this
.
chart
.
destroy
();
}
}
}
}
@
Debounce
(
200
)
resize
=
()
=>
{
if
(
!
this
.
node
)
{
return
;
}
const
canvasWidth
=
this
.
node
.
parentNode
.
clientWidth
;
const
{
data
=
[],
autoLabel
=
true
}
=
this
.
props
;
if
(
!
autoLabel
)
{
return
;
}
const
minWidth
=
data
.
length
*
30
;
const
{
autoHideXLabels
}
=
this
.
state
;
if
(
canvasWidth
<=
minWidth
)
{
if
(
!
autoHideXLabels
)
{
this
.
setState
({
autoHideXLabels
:
true
,
});
this
.
renderChart
(
data
);
}
}
else
if
(
autoHideXLabels
)
{
this
.
setState
({
autoHideXLabels
:
false
,
});
this
.
renderChart
(
data
);
}
}
handleRef
=
(
n
)
=>
{
handleRef
=
(
n
)
=>
{
this
.
node
=
n
;
this
.
node
=
n
;
}
}
renderChart
(
data
)
{
renderChart
(
data
)
{
const
{
height
=
0
,
fit
=
true
,
color
=
'
rgba(24, 144, 255, 0.85)
'
,
margin
=
[
32
,
0
,
32
,
40
]
}
=
this
.
props
;
const
{
autoHideXLabels
}
=
this
.
state
;
const
{
height
=
0
,
fit
=
true
,
color
=
'
rgba(24, 144, 255, 0.85)
'
,
margin
=
[
32
,
0
,
(
autoHideXLabels
?
8
:
32
),
40
],
}
=
this
.
props
;
if
(
!
data
||
(
data
&&
data
.
length
<
1
))
{
if
(
!
data
||
(
data
&&
data
.
length
<
1
))
{
return
;
return
;
...
@@ -47,9 +90,17 @@ class Bar extends PureComponent {
...
@@ -47,9 +90,17 @@ class Bar extends PureComponent {
},
},
});
});
chart
.
axis
(
'
x
'
,
{
if
(
autoHideXLabels
)
{
title
:
false
,
chart
.
axis
(
'
x
'
,
{
});
title
:
false
,
tickLine
:
false
,
labels
:
false
,
});
}
else
{
chart
.
axis
(
'
x
'
,
{
title
:
false
,
});
}
chart
.
axis
(
'
y
'
,
{
chart
.
axis
(
'
y
'
,
{
title
:
false
,
title
:
false
,
line
:
false
,
line
:
false
,
...
...
src/components/Charts/ChartCard/index.js
View file @
03e0ca45
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
Card
}
from
'
antd
'
;
import
{
Card
,
Spin
}
from
'
antd
'
;
import
styles
from
'
./index.less
'
;
import
styles
from
'
./index.less
'
;
const
ChartCard
=
({
contentHeight
,
title
,
action
,
total
,
footer
,
children
,
...
rest
})
=>
(
const
ChartCard
=
({
loading
,
contentHeight
,
title
,
action
,
total
,
footer
,
children
,
...
rest
})
=>
{
<
Card
const
content
=
(
bodyStyle
=
{{
padding
:
'
20px 24px 8px 24px
'
}}
{...
rest
}
>
<
div
className
=
{
styles
.
chartCard
}
>
<
div
className
=
{
styles
.
chartCard
}
>
<
div
className
=
{
styles
.
meta
}
>
<
div
className
=
{
styles
.
meta
}
>
<
span
className
=
{
styles
.
title
}
>
{
title
}
<
/span
>
<
span
className
=
{
styles
.
title
}
>
{
title
}
<
/span
>
...
@@ -30,7 +27,20 @@ const ChartCard = ({ contentHeight, title, action, total, footer, children, ...r
...
@@ -30,7 +27,20 @@ const ChartCard = ({ contentHeight, title, action, total, footer, children, ...r
)
)
}
}
<
/div
>
<
/div
>
<
/Card
>
);
);
return
(
<
Card
bodyStyle
=
{{
padding
:
'
20px 24px 8px 24px
'
}}
{...
rest
}
>
{
loading
?
(
<
Spin
size
=
"
large
"
>
{
content
}
<
/Spin
>
)
:
content
}
<
/Card
>
);
};
export
default
ChartCard
;
export
default
ChartCard
;
src/components/Charts/MiniArea/index.js
View file @
03e0ca45
...
@@ -114,7 +114,7 @@ class MiniArea extends PureComponent {
...
@@ -114,7 +114,7 @@ class MiniArea extends PureComponent {
return
(
return
(
<
div
className
=
{
styles
.
miniChart
}
style
=
{{
height
}}
>
<
div
className
=
{
styles
.
miniChart
}
style
=
{{
height
}}
>
<
div
>
<
div
className
=
{
styles
.
chartContent
}
>
<
div
ref
=
{
this
.
handleRef
}
/
>
<
div
ref
=
{
this
.
handleRef
}
/
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
...
...
src/components/Charts/MiniBar/index.js
View file @
03e0ca45
...
@@ -76,7 +76,7 @@ class MiniBar extends PureComponent {
...
@@ -76,7 +76,7 @@ class MiniBar extends PureComponent {
return
(
return
(
<
div
className
=
{
styles
.
miniChart
}
style
=
{{
height
}}
>
<
div
className
=
{
styles
.
miniChart
}
style
=
{{
height
}}
>
<
div
>
<
div
className
=
{
styles
.
chartContent
}
>
<
div
ref
=
{
this
.
handleRef
}
/
>
<
div
ref
=
{
this
.
handleRef
}
/
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
...
...
src/components/Charts/index.less
View file @
03e0ca45
.miniChart {
.miniChart {
position: relative;
position: relative;
width: 100%;
width: 100%;
& > div
{
.chartContent
{
position: absolute;
position: absolute;
bottom: -34px;
bottom: -34px;
width: 100%;
width: 100%;
...
@@ -10,4 +10,10 @@
...
@@ -10,4 +10,10 @@
overflow: hidden;
overflow: hidden;
}
}
}
}
.chartLoading {
position: absolute;
top: 16px;
left: 50%;
margin-left: -7px;
}
}
}
src/components/Charts/index.md
View file @
03e0ca45
...
@@ -60,6 +60,7 @@ Ant Design Pro 提供的业务中常用的图表类型,都是基于 [G2](https
...
@@ -60,6 +60,7 @@ Ant Design Pro 提供的业务中常用的图表类型,都是基于 [G2](https
| margin | 图表内部间距 | array |
\[
32, 0, 32, 40
\]
|
| margin | 图表内部间距 | array |
\[
32, 0, 32, 40
\]
|
| height | 图表高度 | number | - |
| height | 图表高度 | number | - |
| data | 数据 | array
<
{
x
,
y
}
>
| - |
| data | 数据 | array
<
{
x
,
y
}
>
| - |
| autoLabel | 在宽度不足时,自动隐藏 x 轴的 label | boolean |
`true`
|
### Pie
### Pie
...
...
src/routes/Dashboard/Analysis.js
View file @
03e0ca45
...
@@ -27,6 +27,7 @@ for (let i = 0; i < 7; i += 1) {
...
@@ -27,6 +27,7 @@ for (let i = 0; i < 7; i += 1) {
}))
}))
export
default
class
Analysis
extends
Component
{
export
default
class
Analysis
extends
Component
{
state
=
{
state
=
{
loading
:
true
,
salesType
:
'
all
'
,
salesType
:
'
all
'
,
currentTabKey
:
''
,
currentTabKey
:
''
,
rangePickerValue
:
[],
rangePickerValue
:
[],
...
@@ -35,6 +36,10 @@ export default class Analysis extends Component {
...
@@ -35,6 +36,10 @@ export default class Analysis extends Component {
componentDidMount
()
{
componentDidMount
()
{
this
.
props
.
dispatch
({
this
.
props
.
dispatch
({
type
:
'
chart/fetch
'
,
type
:
'
chart/fetch
'
,
}).
then
(()
=>
{
this
.
setState
({
loading
:
false
,
});
});
});
}
}
...
@@ -89,7 +94,7 @@ export default class Analysis extends Component {
...
@@ -89,7 +94,7 @@ export default class Analysis extends Component {
}
}
render
()
{
render
()
{
const
{
rangePickerValue
,
salesType
,
currentTabKey
}
=
this
.
state
;
const
{
rangePickerValue
,
salesType
,
currentTabKey
,
loading
}
=
this
.
state
;
const
{
chart
}
=
this
.
props
;
const
{
chart
}
=
this
.
props
;
const
{
const
{
visitData
,
visitData
,
...
@@ -221,6 +226,7 @@ export default class Analysis extends Component {
...
@@ -221,6 +226,7 @@ export default class Analysis extends Component {
<
Row
gutter
=
{
24
}
>
<
Row
gutter
=
{
24
}
>
<
Col
{...
topColResponsiveProps
}
>
<
Col
{...
topColResponsiveProps
}
>
<
ChartCard
<
ChartCard
loading
=
{
loading
}
bordered
=
{
false
}
bordered
=
{
false
}
title
=
"
总销售额
"
title
=
"
总销售额
"
action
=
{
<
Tooltip
title
=
"
指标说明
"
><
Icon
type
=
"
info-circle-o
"
/><
/Tooltip>
}
action
=
{
<
Tooltip
title
=
"
指标说明
"
><
Icon
type
=
"
info-circle-o
"
/><
/Tooltip>
}
...
@@ -238,6 +244,7 @@ export default class Analysis extends Component {
...
@@ -238,6 +244,7 @@ export default class Analysis extends Component {
<
/Col
>
<
/Col
>
<
Col
{...
topColResponsiveProps
}
>
<
Col
{...
topColResponsiveProps
}
>
<
ChartCard
<
ChartCard
loading
=
{
loading
}
bordered
=
{
false
}
bordered
=
{
false
}
title
=
"
访问量
"
title
=
"
访问量
"
action
=
{
<
Tooltip
title
=
"
指标说明
"
><
Icon
type
=
"
info-circle-o
"
/><
/Tooltip>
}
action
=
{
<
Tooltip
title
=
"
指标说明
"
><
Icon
type
=
"
info-circle-o
"
/><
/Tooltip>
}
...
@@ -254,6 +261,7 @@ export default class Analysis extends Component {
...
@@ -254,6 +261,7 @@ export default class Analysis extends Component {
<
/Col
>
<
/Col
>
<
Col
{...
topColResponsiveProps
}
>
<
Col
{...
topColResponsiveProps
}
>
<
ChartCard
<
ChartCard
loading
=
{
loading
}
bordered
=
{
false
}
bordered
=
{
false
}
title
=
"
支付笔数
"
title
=
"
支付笔数
"
action
=
{
<
Tooltip
title
=
"
指标说明
"
><
Icon
type
=
"
info-circle-o
"
/><
/Tooltip>
}
action
=
{
<
Tooltip
title
=
"
指标说明
"
><
Icon
type
=
"
info-circle-o
"
/><
/Tooltip>
}
...
@@ -269,6 +277,7 @@ export default class Analysis extends Component {
...
@@ -269,6 +277,7 @@ export default class Analysis extends Component {
<
/Col
>
<
/Col
>
<
Col
{...
topColResponsiveProps
}
>
<
Col
{...
topColResponsiveProps
}
>
<
ChartCard
<
ChartCard
loading
=
{
loading
}
bordered
=
{
false
}
bordered
=
{
false
}
title
=
"
运营活动效果
"
title
=
"
运营活动效果
"
action
=
{
<
Tooltip
title
=
"
指标说明
"
><
Icon
type
=
"
info-circle-o
"
/><
/Tooltip>
}
action
=
{
<
Tooltip
title
=
"
指标说明
"
><
Icon
type
=
"
info-circle-o
"
/><
/Tooltip>
}
...
@@ -291,6 +300,7 @@ export default class Analysis extends Component {
...
@@ -291,6 +300,7 @@ export default class Analysis extends Component {
<
/Row
>
<
/Row
>
<
Card
<
Card
loading
=
{
loading
}
bordered
=
{
false
}
bordered
=
{
false
}
bodyStyle
=
{{
padding
:
0
}}
bodyStyle
=
{{
padding
:
0
}}
>
>
...
@@ -359,8 +369,9 @@ export default class Analysis extends Component {
...
@@ -359,8 +369,9 @@ export default class Analysis extends Component {
<
/Card
>
<
/Card
>
<
Row
gutter
=
{
24
}
>
<
Row
gutter
=
{
24
}
>
<
Col
lg
=
{
12
}
sm
=
{
24
}
xs
=
{
24
}
>
<
Col
xl
=
{
12
}
lg
=
{
24
}
md
=
{
24
}
sm
=
{
24
}
xs
=
{
24
}
>
<
Card
<
Card
loading
=
{
loading
}
bordered
=
{
false
}
bordered
=
{
false
}
title
=
"
线上热门搜索
"
title
=
"
线上热门搜索
"
extra
=
{
iconGroup
}
extra
=
{
iconGroup
}
...
@@ -417,8 +428,9 @@ export default class Analysis extends Component {
...
@@ -417,8 +428,9 @@ export default class Analysis extends Component {
/
>
/
>
<
/Card
>
<
/Card
>
<
/Col
>
<
/Col
>
<
Col
lg
=
{
12
}
sm
=
{
24
}
xs
=
{
24
}
>
<
Col
xl
=
{
12
}
lg
=
{
24
}
md
=
{
24
}
sm
=
{
24
}
xs
=
{
24
}
>
<
Card
<
Card
loading
=
{
loading
}
className
=
{
styles
.
salesCard
}
className
=
{
styles
.
salesCard
}
bordered
=
{
false
}
bordered
=
{
false
}
title
=
"
销售额类别占比
"
title
=
"
销售额类别占比
"
...
@@ -452,6 +464,7 @@ export default class Analysis extends Component {
...
@@ -452,6 +464,7 @@ export default class Analysis extends Component {
<
/Row
>
<
/Row
>
<
Card
<
Card
loading
=
{
loading
}
className
=
{
styles
.
offlineCard
}
className
=
{
styles
.
offlineCard
}
bordered
=
{
false
}
bordered
=
{
false
}
bodyStyle
=
{{
padding
:
'
0 0 32px 0
'
}}
bodyStyle
=
{{
padding
:
'
0 0 32px 0
'
}}
...
...
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