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
061a1e7d
Commit
061a1e7d
authored
Apr 15, 2019
by
陈帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
type: beter type
parent
278a1ce9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
116 additions
and
97 deletions
+116
-97
Analysis/src/components/Charts/Pie/index.tsx
Analysis/src/components/Charts/Pie/index.tsx
+26
-13
Analysis/src/components/OfflineData.tsx
Analysis/src/components/OfflineData.tsx
+30
-28
Analysis/src/components/ProportionSales.tsx
Analysis/src/components/ProportionSales.tsx
+52
-50
Analysis/src/utils/Yuan.tsx
Analysis/src/utils/Yuan.tsx
+8
-6
No files found.
Analysis/src/components/Charts/Pie/index.tsx
View file @
061a1e7d
...
@@ -34,14 +34,10 @@ export interface IPieProps {
...
@@ -34,14 +34,10 @@ export interface IPieProps {
valueFormat
?:
(
value
:
string
)
=>
string
|
React
.
ReactNode
;
valueFormat
?:
(
value
:
string
)
=>
string
|
React
.
ReactNode
;
subTitle
?:
React
.
ReactNode
;
subTitle
?:
React
.
ReactNode
;
}
}
/* eslint react/no-danger:0 */
interface
IPieState
{
interface
IPieState
{
legendData
:
Array
<
{
checked
:
boolean
;
x
:
string
;
color
:
string
;
percent
:
number
;
y
:
string
}
>
;
legendData
:
Array
<
{
checked
:
boolean
;
x
:
string
;
color
:
string
;
percent
:
number
;
y
:
string
}
>
;
legendBlock
:
boolean
;
legendBlock
:
boolean
;
}
}
class
Pie
extends
Component
<
IPieProps
,
IPieState
>
{
class
Pie
extends
Component
<
IPieProps
,
IPieState
>
{
state
:
IPieState
=
{
state
:
IPieState
=
{
legendData
:
[],
legendData
:
[],
...
@@ -74,7 +70,9 @@ class Pie extends Component<IPieProps, IPieState> {
...
@@ -74,7 +70,9 @@ class Pie extends Component<IPieProps, IPieState> {
window
.
cancelAnimationFrame
(
this
.
requestRef
);
window
.
cancelAnimationFrame
(
this
.
requestRef
);
}
}
window
.
removeEventListener
(
'
resize
'
,
this
.
resize
);
window
.
removeEventListener
(
'
resize
'
,
this
.
resize
);
(
this
.
resize
as
any
).
cancel
();
if
(
this
.
resize
)
{
(
this
.
resize
as
any
).
cancel
();
}
}
}
getG2Instance
=
(
chart
:
G2
.
Chart
)
=>
{
getG2Instance
=
(
chart
:
G2
.
Chart
)
=>
{
...
@@ -85,8 +83,6 @@ class Pie extends Component<IPieProps, IPieState> {
...
@@ -85,8 +83,6 @@ class Pie extends Component<IPieProps, IPieState> {
});
});
};
};
root
!
:
HTMLDivElement
;
chart
:
G2
.
Chart
|
undefined
;
// for custom lengend view
// for custom lengend view
getLegendData
=
()
=>
{
getLegendData
=
()
=>
{
if
(
!
this
.
chart
)
return
;
if
(
!
this
.
chart
)
return
;
...
@@ -94,7 +90,7 @@ class Pie extends Component<IPieProps, IPieState> {
...
@@ -94,7 +90,7 @@ class Pie extends Component<IPieProps, IPieState> {
if
(
!
geom
)
return
;
if
(
!
geom
)
return
;
const
items
=
geom
.
get
(
'
dataArray
'
)
||
[];
// 获取图形对应的
const
items
=
geom
.
get
(
'
dataArray
'
)
||
[];
// 获取图形对应的
const
legendData
=
items
.
map
((
item
:
Array
<
any
>
)
=>
{
const
legendData
=
items
.
map
((
item
:
{
color
:
any
;
_origin
:
any
}[]
)
=>
{
/* eslint no-underscore-dangle:0 */
/* eslint no-underscore-dangle:0 */
const
origin
=
item
[
0
].
_origin
;
const
origin
=
item
[
0
].
_origin
;
origin
.
color
=
item
[
0
].
color
;
origin
.
color
=
item
[
0
].
color
;
...
@@ -106,7 +102,6 @@ class Pie extends Component<IPieProps, IPieState> {
...
@@ -106,7 +102,6 @@ class Pie extends Component<IPieProps, IPieState> {
legendData
,
legendData
,
});
});
};
};
handleRoot
=
(
n
:
HTMLDivElement
)
=>
{
handleRoot
=
(
n
:
HTMLDivElement
)
=>
{
this
.
root
=
n
;
this
.
root
=
n
;
};
};
...
@@ -128,6 +123,8 @@ class Pie extends Component<IPieProps, IPieState> {
...
@@ -128,6 +123,8 @@ class Pie extends Component<IPieProps, IPieState> {
legendData
,
legendData
,
});
});
};
};
root
!
:
HTMLDivElement
;
chart
:
G2
.
Chart
|
undefined
;
// for window resize auto responsive legend
// for window resize auto responsive legend
@
Bind
()
@
Bind
()
...
@@ -139,7 +136,11 @@ class Pie extends Component<IPieProps, IPieState> {
...
@@ -139,7 +136,11 @@ class Pie extends Component<IPieProps, IPieState> {
window
.
removeEventListener
(
'
resize
'
,
this
.
resize
);
window
.
removeEventListener
(
'
resize
'
,
this
.
resize
);
return
;
return
;
}
}
if
((
this
.
root
!
.
parentNode
!
as
HTMLDivElement
).
clientWidth
<=
380
)
{
if
(
this
.
root
&&
this
.
root
.
parentNode
&&
(
this
.
root
.
parentNode
as
HTMLElement
).
clientWidth
<=
380
)
{
if
(
!
legendBlock
)
{
if
(
!
legendBlock
)
{
this
.
setState
({
this
.
setState
({
legendBlock
:
true
,
legendBlock
:
true
,
...
@@ -160,11 +161,13 @@ class Pie extends Component<IPieProps, IPieState> {
...
@@ -160,11 +161,13 @@ class Pie extends Component<IPieProps, IPieState> {
hasLegend
=
false
,
hasLegend
=
false
,
className
,
className
,
style
,
style
,
height
=
1
,
height
=
0
,
forceFit
=
true
,
forceFit
=
true
,
percent
,
percent
,
color
,
inner
=
0.75
,
inner
=
0.75
,
animate
=
true
,
animate
=
true
,
colors
,
lineWidth
=
1
,
lineWidth
=
1
,
}
=
this
.
props
;
}
=
this
.
props
;
...
@@ -183,9 +186,12 @@ class Pie extends Component<IPieProps, IPieState> {
...
@@ -183,9 +186,12 @@ class Pie extends Component<IPieProps, IPieState> {
let
data
=
propsData
||
[];
let
data
=
propsData
||
[];
let
selected
=
propsSelected
;
let
selected
=
propsSelected
;
let
tooltip
=
propsTooltip
;
let
tooltip
=
propsTooltip
;
const
defaultColors
=
colors
;
data
=
data
||
[];
data
=
data
||
[];
selected
=
selected
||
true
;
selected
=
selected
||
true
;
tooltip
=
tooltip
||
true
;
tooltip
=
tooltip
||
true
;
let
formatColor
;
const
scale
=
{
const
scale
=
{
x
:
{
x
:
{
...
@@ -200,6 +206,12 @@ class Pie extends Component<IPieProps, IPieState> {
...
@@ -200,6 +206,12 @@ class Pie extends Component<IPieProps, IPieState> {
if
(
percent
||
percent
===
0
)
{
if
(
percent
||
percent
===
0
)
{
selected
=
false
;
selected
=
false
;
tooltip
=
false
;
tooltip
=
false
;
formatColor
=
(
value
:
string
)
=>
{
if
(
value
===
'
占比
'
)
{
return
color
||
'
rgba(24, 144, 255, 0.85)
'
;
}
return
'
#F0F2F5
'
;
};
data
=
[
data
=
[
{
{
...
@@ -221,7 +233,7 @@ class Pie extends Component<IPieProps, IPieState> {
...
@@ -221,7 +233,7 @@ class Pie extends Component<IPieProps, IPieState> {
}),
}),
];
];
const
padding
:
[
number
,
number
,
number
,
number
]
=
[
12
,
0
,
12
,
0
];
const
padding
=
[
12
,
0
,
12
,
0
]
as
[
number
,
number
,
number
,
number
];
const
dv
=
new
DataView
();
const
dv
=
new
DataView
();
dv
.
source
(
data
).
transform
({
dv
.
source
(
data
).
transform
({
...
@@ -248,9 +260,10 @@ class Pie extends Component<IPieProps, IPieState> {
...
@@ -248,9 +260,10 @@ class Pie extends Component<IPieProps, IPieState> {
<
Coord
type
=
"theta"
innerRadius
=
{
inner
}
/>
<
Coord
type
=
"theta"
innerRadius
=
{
inner
}
/>
<
Geom
<
Geom
style
=
{
{
lineWidth
,
stroke
:
'
#fff
'
}
}
style
=
{
{
lineWidth
,
stroke
:
'
#fff
'
}
}
tooltip
=
{
tooltip
&&
tooltipFormat
}
tooltip
=
{
tooltip
?
tooltipFormat
:
undefined
}
type
=
"intervalStack"
type
=
"intervalStack"
position
=
"percent"
position
=
"percent"
color
=
{
[
'
x
'
,
percent
||
percent
===
0
?
formatColor
:
defaultColors
]
as
any
}
selected
=
{
selected
}
selected
=
{
selected
}
/>
/>
</
Chart
>
</
Chart
>
...
...
Analysis/src/components/OfflineData.tsx
View file @
061a1e7d
...
@@ -13,34 +13,36 @@ const CustomTab = ({
...
@@ -13,34 +13,36 @@ const CustomTab = ({
}:
{
}:
{
data
:
IOfflineData
;
data
:
IOfflineData
;
currentTabKey
:
string
;
currentTabKey
:
string
;
})
=>
(
})
=>
{
<
Row
gutter
=
{
8
}
style
=
{
{
width
:
138
,
margin
:
'
8px 0
'
}
}
>
return
(
<
Col
span
=
{
12
}
>
<
Row
gutter
=
{
8
}
style
=
{
{
width
:
138
,
margin
:
'
8px 0
'
}
}
>
<
NumberInfo
<
Col
span
=
{
12
}
>
title
=
{
data
.
name
}
<
NumberInfo
subTitle
=
{
title
=
{
data
.
name
}
<
FormattedMessage
subTitle
=
{
id
=
"BLOCK_NAME.analysis.conversion-rate"
<
FormattedMessage
defaultMessage
=
"Conversion Rate"
id
=
"BLOCK_NAME.analysis.conversion-rate"
/>
defaultMessage
=
"Conversion Rate"
}
/>
gap
=
{
2
}
}
total
=
{
`
${
data
.
cvr
*
100
}
%`
}
gap
=
{
2
}
theme
=
{
currentKey
!==
data
.
name
?
'
light
'
:
undefined
}
total
=
{
`
${
data
.
cvr
*
100
}
%`
}
/>
theme
=
{
currentKey
!==
data
.
name
?
'
light
'
:
undefined
}
</
Col
>
/>
<
Col
span
=
{
12
}
style
=
{
{
paddingTop
:
36
}
}
>
</
Col
>
<
Pie
<
Col
span
=
{
12
}
style
=
{
{
paddingTop
:
36
}
}
>
animate
=
{
false
}
<
Pie
inner
=
{
0.55
}
animate
=
{
false
}
tooltip
=
{
false
}
inner
=
{
0.55
}
margin
=
{
[
0
,
0
,
0
,
0
]
}
tooltip
=
{
false
}
percent
=
{
data
.
cvr
*
100
}
margin
=
{
[
0
,
0
,
0
,
0
]
}
height
=
{
64
}
percent
=
{
data
.
cvr
*
100
}
/>
height
=
{
64
}
</
Col
>
/>
</
Row
>
</
Col
>
);
</
Row
>
);
};
const
{
TabPane
}
=
Tabs
;
const
{
TabPane
}
=
Tabs
;
...
...
Analysis/src/components/ProportionSales.tsx
View file @
061a1e7d
...
@@ -21,57 +21,59 @@ const ProportionSales = ({
...
@@ -21,57 +21,59 @@ const ProportionSales = ({
salesType
:
'
all
'
|
'
online
'
|
'
stores
'
;
salesType
:
'
all
'
|
'
online
'
|
'
stores
'
;
salesPieData
:
ISalesData
[];
salesPieData
:
ISalesData
[];
handleChangeSalesType
?:
(
e
:
RadioChangeEvent
)
=>
void
;
handleChangeSalesType
?:
(
e
:
RadioChangeEvent
)
=>
void
;
})
=>
(
})
=>
{
<
Card
return
(
loading
=
{
loading
}
<
Card
className
=
{
styles
.
salesCard
}
loading
=
{
loading
}
bordered
=
{
false
}
className
=
{
styles
.
salesCard
}
title
=
{
bordered
=
{
false
}
<
FormattedMessage
title
=
{
id
=
"BLOCK_NAME.analysis.the-proportion-of-sales"
<
FormattedMessage
defaultMessage
=
"The Proportion of Sales"
id
=
"BLOCK_NAME.analysis.the-proportion-of-sales"
/>
defaultMessage
=
"The Proportion of Sales"
}
/>
bodyStyle
=
{
{
padding
:
24
}
}
}
extra
=
{
bodyStyle
=
{
{
padding
:
24
}
}
<
div
className
=
{
styles
.
salesCardExtra
}
>
extra
=
{
{
dropdownGroup
}
<
div
className
=
{
styles
.
salesCardExtra
}
>
<
div
className
=
{
styles
.
salesTypeRadio
}
>
{
dropdownGroup
}
<
Radio
.
Group
value
=
{
salesType
}
onChange
=
{
handleChangeSalesType
}
>
<
div
className
=
{
styles
.
salesTypeRadio
}
>
<
Radio
.
Button
value
=
"all"
>
<
Radio
.
Group
value
=
{
salesType
}
onChange
=
{
handleChangeSalesType
}
>
<
FormattedMessage
id
=
"BLOCK_NAME.channel.all"
defaultMessage
=
"ALL"
/>
<
Radio
.
Button
value
=
"all"
>
</
Radio
.
Button
>
<
FormattedMessage
id
=
"BLOCK_NAME.channel.all"
defaultMessage
=
"ALL"
/>
<
Radio
.
Button
value
=
"online"
>
</
Radio
.
Button
>
<
FormattedMessage
id
=
"BLOCK_NAME.channel.online"
defaultMessage
=
"Online"
/>
<
Radio
.
Button
value
=
"online"
>
</
Radio
.
Button
>
<
FormattedMessage
id
=
"BLOCK_NAME.channel.online"
defaultMessage
=
"Online"
/>
<
Radio
.
Button
value
=
"stores"
>
</
Radio
.
Button
>
<
FormattedMessage
id
=
"BLOCK_NAME.channel.stores"
defaultMessage
=
"Stores"
/>
<
Radio
.
Button
value
=
"stores"
>
</
Radio
.
Button
>
<
FormattedMessage
id
=
"BLOCK_NAME.channel.stores"
defaultMessage
=
"Stores"
/>
</
Radio
.
Group
>
</
Radio
.
Button
>
</
Radio
.
Group
>
</
div
>
</
div
>
</
div
>
</
div
>
}
}
style
=
{
{
marginTop
:
24
}
}
style
=
{
{
marginTop
:
24
}
}
>
<
div
style
=
{
{
minHeight
:
380
,
}
}
>
>
<
h4
style
=
{
{
marginTop
:
8
,
marginBottom
:
32
}
}
>
<
div
<
FormattedMessage
id
=
"BLOCK_NAME.analysis.sales"
defaultMessage
=
"Sales"
/>
style
=
{
{
</
h4
>
minHeight
:
380
,
<
Pie
}
}
hasLegend
>
subTitle
=
{
<
FormattedMessage
id
=
"BLOCK_NAME.analysis.sales"
defaultMessage
=
"Sales"
/>
}
<
h4
style
=
{
{
marginTop
:
8
,
marginBottom
:
32
}
}
>
total
=
{
()
=>
<
Yuan
>
{
salesPieData
.
reduce
((
pre
,
now
)
=>
now
.
y
+
pre
,
0
)
}
</
Yuan
>
}
<
FormattedMessage
id
=
"BLOCK_NAME.analysis.sales"
defaultMessage
=
"Sales"
/>
data
=
{
salesPieData
}
</
h4
>
valueFormat
=
{
value
=>
<
Yuan
>
{
value
}
</
Yuan
>
}
<
Pie
height
=
{
248
}
hasLegend
lineWidth
=
{
4
}
subTitle
=
{
<
FormattedMessage
id
=
"BLOCK_NAME.analysis.sales"
defaultMessage
=
"Sales"
/>
}
/>
total
=
{
()
=>
<
Yuan
>
{
salesPieData
.
reduce
((
pre
,
now
)
=>
now
.
y
+
pre
,
0
)
}
</
Yuan
>
}
</
div
>
data
=
{
salesPieData
}
</
Card
>
valueFormat
=
{
value
=>
<
Yuan
>
{
value
}
</
Yuan
>
}
);
height
=
{
248
}
lineWidth
=
{
4
}
/>
</
div
>
</
Card
>
);
};
export
default
ProportionSales
;
export
default
ProportionSales
;
Analysis/src/utils/Yuan.tsx
View file @
061a1e7d
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
yuan
}
from
'
ant-design-pro/lib
/Charts
'
;
import
{
yuan
}
from
'
../components
/Charts
'
;
/**
/**
* 减少使用 dangerouslySetInnerHTML
* 减少使用 dangerouslySetInnerHTML
*/
*/
export
default
class
Yuan
extends
React
.
PureComponent
{
export
default
class
Yuan
extends
React
.
Component
<
{
children
:
React
.
ReactText
;
}
>
{
componentDidMount
()
{
componentDidMount
()
{
this
.
render
t
oHtml
();
this
.
render
T
oHtml
();
}
}
componentDidUpdate
()
{
componentDidUpdate
()
{
this
.
render
t
oHtml
();
this
.
render
T
oHtml
();
}
}
main
:
HTMLSpanElement
|
undefined
|
null
;
render
t
oHtml
=
()
=>
{
render
T
oHtml
=
()
=>
{
const
{
children
}
=
this
.
props
;
const
{
children
}
=
this
.
props
;
if
(
this
.
main
)
{
if
(
this
.
main
)
{
this
.
main
.
innerHTML
=
yuan
(
children
);
this
.
main
.
innerHTML
=
yuan
(
children
);
...
...
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