Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
gh
/
data-view
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 2a9b6e7d
authored
Jun 28, 2022
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'dev_v1.0.0' of
http://192.168.3.233:8090/gh/data-view
into dev_v1.0.0
2 parents
dfb551a6
f40939c2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
180 additions
and
76 deletions
src/components/PieChart.vue
src/components/RanKing.vue
src/mixins/clientMixin.js
src/views/afterSales/file.vue
src/views/customer/age.vue
src/views/customer/buyCar.vue
src/views/customer/sex.vue
src/components/PieChart.vue
View file @
2a9b6e7
<
template
>
<div
class=
"pie-box"
>
<div
class=
"pie-box"
>
<div
:id=
"id"
:style=
"
{ width: width, height: height }" class="pie-chart">
</div>
<div
class=
"center-content"
>
<div
:class=
"[id, 'center-content-num']"
></div>
<div
class=
"center-content-desc"
>
{{
numDesc
}}
</div>
</div>
</div>
</
template
>
...
...
@@ -16,7 +20,7 @@ export default {
},
keys
:
{
type
:
Array
,
default
:
()
=>
[
'name'
,
'
number
'
]
default
:
()
=>
[
'name'
,
'
value
'
]
},
height
:
{
type
:
String
,
...
...
@@ -28,13 +32,7 @@ export default {
},
list
:
{
type
:
Array
,
default
:
()
=>
[
{
number
:
1048
,
name
:
'Search Engine'
},
{
number
:
735
,
name
:
'Direct'
},
{
number
:
580
,
name
:
'Email'
},
{
number
:
484
,
name
:
'Union Ads'
},
{
number
:
300
,
name
:
'Video Ads'
}
]
default
:
()
=>
[]
},
radius
:
{
type
:
Array
,
...
...
@@ -53,20 +51,23 @@ export default {
mTime
:
''
,
viewData
:
[],
text
:
''
,
subtext
:
''
subtext
:
''
,
currentIndex
:
-
1
,
mainValue
:
0
,
numDesc
:
''
}
},
created
()
{
this
.
initData
()
watch
:
{
list
:
{
handler
(
newVal
)
{
this
.
initData
()
this
.
draw
()
}
}
},
mounted
()
{
let
id
=
this
.
id
this
.
echartsPie
=
echarts
.
init
(
document
.
getElementById
(
id
))
window
.
addEventListener
(
'resize'
,
()
=>
{
this
.
echartsPie
.
resize
()
})
this
.
initData
()
this
.
draw
()
},
...
...
@@ -82,6 +83,10 @@ export default {
})
},
draw
()
{
this
.
echartsPie
=
echarts
.
init
(
document
.
getElementById
(
this
.
id
))
window
.
addEventListener
(
'resize'
,
()
=>
{
this
.
echartsPie
.
resize
()
})
// 指定图表的配置项和数据
this
.
option
=
{
// tooltip: {
...
...
@@ -147,10 +152,22 @@ export default {
]
}
this
.
echartsPie
.
setOption
(
this
.
option
)
this
.
pieActive
(
)
this
.
mTime
=
setInterval
(
this
.
pieActive
,
3000
)
// 鼠标划出
this
.
echartsPie
.
on
(
'mouseout'
,
()
=>
{
this
.
pieActive
()
if
(
this
.
mTime
)
clearInterval
(
this
.
mTime
)
this
.
mTime
=
setInterval
(
this
.
pieActive
,
3000
)
})
this
.
echartsPie
.
on
(
'mouseover'
,
data
=>
{
this
.
mainValue
=
data
.
data
.
value
this
.
numDesc
=
data
.
data
.
name
this
.
setAnamiteText
()
// 停止定时器,清除之前的高亮
clearInterval
(
this
.
mTime
)
console
.
log
(
'mouseover'
)
this
.
currentIndex
=
data
.
dataIndex
this
.
highlightPie
()
this
.
emitEvent
(
data
.
data
)
})
},
// 事件触发
...
...
@@ -160,44 +177,35 @@ export default {
this
.
echartsPie
.
setOption
(
this
.
option
)
this
.
$emit
(
'pieAction'
,
data
)
},
//高亮
pieActive
()
{
let
index
=
-
1
//高亮所在下标
let
dataLength
=
this
.
viewData
.
length
// 当前饼图有多少个扇形
// 用定时器控制饼图高亮
this
.
mTime
=
setInterval
(()
=>
{
// 清除之前的高亮
this
.
echartsPie
.
dispatchAction
({
type
:
'downplay'
,
seriesIndex
:
0
,
dataIndex
:
index
})
index
=
(
index
+
1
)
%
dataLength
// 当前下标高亮
this
.
echartsPie
.
dispatchAction
({
type
:
'highlight'
,
seriesIndex
:
0
,
dataIndex
:
index
})
if
(
index
>
dataLength
)
{
index
=
0
}
this
.
emitEvent
(
this
.
viewData
[
index
])
},
2000
)
// 鼠标划入
this
.
echartsPie
.
on
(
'mouseover'
,
data
=>
{
// 停止定时器,清除之前的高亮
clearInterval
(
this
.
mTime
)
highlightPie
()
{
// 取消所有高亮并高亮当前图形
// 遍历饼图数据,取消所有图形的高亮效果
for
(
var
idx
in
this
.
option
.
series
[
0
].
data
)
this
.
echartsPie
.
dispatchAction
({
type
:
'downplay'
,
seriesIndex
:
0
,
dataIndex
:
i
nde
x
dataIndex
:
i
d
x
})
console
.
log
(
'mouseover'
)
console
.
log
(
data
)
this
.
emitEvent
(
data
.
data
)
// 高亮当前图形
this
.
echartsPie
.
dispatchAction
({
type
:
'highlight'
,
seriesIndex
:
0
,
dataIndex
:
this
.
currentIndex
})
//高亮项this.currentIndex
this
.
mainValue
=
this
.
option
.
series
[
0
].
data
[
this
.
currentIndex
].
value
this
.
numDesc
=
this
.
option
.
series
[
0
].
data
[
this
.
currentIndex
].
name
this
.
setAnamiteText
()
},
setAnamiteText
()
{
document
.
querySelector
(
`.
${
this
.
id
}
`
).
style
=
`--step:
${
this
.
mainValue
}
`
},
//高亮
pieActive
()
{
const
dataLen
=
this
.
option
.
series
[
0
].
data
.
length
this
.
currentIndex
=
(
this
.
currentIndex
+
1
)
%
dataLen
this
.
highlightPie
()
this
.
emitEvent
(
this
.
viewData
[
this
.
currentIndex
])
}
}
}
...
...
@@ -206,7 +214,53 @@ export default {
<
style
lang=
"scss"
scoped
>
.pie-box
{
background
:
#262525
;
position
:
relative
;
.center-content
{
position
:
absolute
;
top
:
50%
;
left
:
50%
;
transform
:
translate
(
-50%
,
-50%
);
text-align
:
center
;
&-num
{
font-size
:
0.24vw
;
color
:
#fff
;
--step
:
0
;
counter-reset
:
count
var
(
--step
);
z-index
:
var
(
--step
);
transition
:
--step
1s
;
&::before
{
content
:
counter
(
count
);
}
}
&
-desc
{
font-size
:
0.2vw
;
color
:
#606266
;
white-space
:
nowrap
;
animation
:
rotateIn
2s
infinite
;
}
}
.pie-chart
{
}
}
@property
--step
{
syntax
:
'<integer>'
;
inherits
:
false
;
initial-value
:
15
;
}
@keyframes
rotateIn
{
from
{
transform
:
rotateY
(
0turn
);
}
to
{
transform
:
rotateY
(
-1turn
);
}
}
//
@keyframes
rotateIn
{
//
from
{
//
transform
:
rotateZ
(
0deg
);
//
}
//
to
{
//
transform
:
rotateZ
(
3600deg
);
//
}
//
}
</
style
>
src/components/RanKing.vue
View file @
2a9b6e7
...
...
@@ -2,9 +2,9 @@
<div
class=
"ranking-container"
>
<div
class=
"title"
>
品牌排名
</div>
<div
class=
"ranking"
>
<div
class=
"brand flex"
v-for=
"(item, index) in
5
"
:key=
"index"
>
<div
class=
"brand flex"
v-for=
"(item, index) in
brandList
"
:key=
"index"
>
<span
class=
"brand-num"
>
{{
index
+
1
}}
</span>
<marquee
class=
"marquee"
:direction=
"directionTimer"
:delay=
"delayTimer"
:text=
"
text
"
/>
<marquee
class=
"marquee"
:direction=
"directionTimer"
:delay=
"delayTimer"
:text=
"
item
"
/>
</div>
</div>
</div>
...
...
@@ -12,11 +12,24 @@
<
script
>
export
default
{
name
:
'RanKing'
,
props
:
{
list
:
{
type
:
Array
,
default
:
()
=>
[]
}
},
watch
:
{
list
:
{
handler
(
newVal
)
{
this
.
brandList
=
newVal
}
}
},
data
()
{
return
{
delayTimer
:
3000
,
directionTimer
:
3000
,
text
:
'丰田丰田丰田丰田丰田'
brandList
:
this
.
list
}
}
}
...
...
src/mixins/clientMixin.js
View file @
2a9b6e7
export
default
{
data
()
{
return
{
now
:
new
Date
().
format
(
'yyyy-MM-dd'
)
now
:
new
Date
().
format
(
'yyyy-MM-dd'
),
clientData
:
[],
distributionRank
:
''
}
},
created
()
{
...
...
@@ -9,16 +11,27 @@ export default {
},
methods
:
{
getClientData
()
{
const
params
=
{
req
:
{
corporateGroupName
:
'广汇'
,
queryItem
:
'age'
,
queryTime
:
this
.
now
,
queryType
:
0
}
}
const
params
=
{
req
:
{
corporateGroupName
:
'集团1'
,
queryItem
:
this
.
type
,
// queryTime: this.now,
queryTime
:
'2022-06-23'
,
queryType
:
0
}
}
this
.
api
.
customer
.
overalldistribution
(
params
).
then
(
res
=>
{
console
.
log
(
res
)
let
distribution
=
JSON
.
parse
(
res
.
data
.
dataList
[
0
].
distribution
)
const
keys
=
Object
.
keys
(
distribution
)
keys
.
forEach
((
item
,
index
)
=>
{
this
.
clientData
.
push
({
name
:
item
,
value
:
distribution
[
item
]
})
})
console
.
log
(
res
.
data
.
dataList
[
0
].
distributionRank
)
this
.
distributionRank
=
JSON
.
parse
(
res
.
data
.
dataList
[
0
].
distributionRank
)
// console.log(this.distributionRank,'this.distributionRank')
})
}
}
...
...
src/views/afterSales/file.vue
View file @
2a9b6e7
...
...
@@ -54,7 +54,7 @@ export default {
},
methods
:
{
init
(
val
)
{
//
console.log(val)
console
.
log
(
val
)
var
params
=
{
req
:
{
corporateGroupName
:
'广汇'
,
...
...
src/views/customer/age.vue
View file @
2a9b6e7
...
...
@@ -12,8 +12,8 @@
<span>
客户年龄分布
</span>
</div>
<div
class=
"container flex"
>
<pie-chart
:id=
"chart.id"
></pie-chart>
<ran-king></ran-king>
<pie-chart
:id=
"chart.id"
:list=
"clientData"
@
pieAction=
"pieAction"
></pie-chart>
<ran-king
:list=
"brandList"
></ran-king>
</div>
</div>
</
template
>
...
...
@@ -25,10 +25,17 @@ export default {
mixins
:
[
clientMixin
],
data
()
{
return
{
type
:
'age'
,
brandList
:[],
chart
:
{
id
:
'age-pie'
}
}
},
methods
:{
pieAction
(
data
){
this
.
brandList
=
Object
.
keys
(
this
.
distributionRank
[
data
.
name
])
}
}
}
</
script
>
src/views/customer/buyCar.vue
View file @
2a9b6e7
...
...
@@ -11,22 +11,31 @@
<span
class=
"icon"
></span>
<span>
客户购车年限
</span>
</div>
<div
class=
"container flex"
>
<pie-chart
:id=
"chart.id"
></pie-chart>
<ran-king></ran-king>
<div
class=
"container flex"
>
<pie-chart
:id=
"chart.id"
:list=
"clientData"
@
pieAction=
"pieAction"
></pie-chart>
<ran-king
:list=
"brandList"
></ran-king>
</div>
</div>
</
template
>
<
script
>
import
{
clientMixin
}
from
'../../mixins/index'
export
default
{
name
:
'BuyCar'
,
data
(){
mixins
:
[
clientMixin
],
data
()
{
return
{
chart
:
{
type
:
'buycarRange'
,
brandList
:
[],
chart
:
{
id
:
'car-pie'
}
}
},
methods
:
{
pieAction
(
data
)
{
this
.
brandList
=
Object
.
keys
(
this
.
distributionRank
[
data
.
name
])
}
}
}
</
script
>
src/views/customer/sex.vue
View file @
2a9b6e7
...
...
@@ -12,20 +12,28 @@
<span>
客户性别
</span>
</div>
<div
class=
"container flex"
>
<pie-chart
:id=
"chart.id"
></pie-chart>
<ran-king></ran-king>
<pie-chart
:id=
"chart.id"
:list=
"clientData"
@
pieAction=
"pieAction"
></pie-chart>
<ran-king
:list=
"brandList"
></ran-king>
</div>
</div>
</
template
>
<
script
>
import
{
clientMixin
}
from
'../../mixins/index'
export
default
{
name
:
'Sex'
,
mixins
:
[
clientMixin
],
data
()
{
return
{
type
:
'gender'
,
chart
:
{
id
:
'sex-pie'
}
}
},
methods
:{
pieAction
(
data
){
this
.
brandList
=
Object
.
keys
(
this
.
distributionRank
[
data
.
name
])
}
}
}
</
script
>
Write
Preview
Markdown
is supported
Attach a file
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 post a comment