Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
scrm-micro-custom
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 c89e93cb
authored
Dec 06, 2023
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
等待联调
1 parent
3917b2fc
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
48 deletions
src/views/userPortrait/components/BarChart.vue
src/views/userPortrait/components/LineChart.vue
src/views/userPortrait/components/PieChart.vue
src/views/userPortrait/index.vue
src/views/userPortrait/components/BarChart.vue
View file @
c89e93c
<
template
>
<
template
>
<div
class=
"bar-chart"
>
<div
class=
"bar-chart"
>
<p
class=
"line-color-title"
>
{{
title
}}
</p>
<p
class=
"line-color-title"
>
{{
title
}}
</p>
<div
ref=
"barChart"
style=
"width: 100%; height: 30vh;"
></div>
<div
v-if=
"data"
ref=
"barChart"
style=
"width: 100%; height: 30vh;"
></div>
</div>
</div>
</
template
>
</
template
>
...
@@ -27,6 +27,10 @@ export default {
...
@@ -27,6 +27,10 @@ export default {
[
'#6E77FF'
,
'#A1D9FF'
],
// 渐变色1
[
'#6E77FF'
,
'#A1D9FF'
],
// 渐变色1
[
'#90D55C'
,
'#FDDB93'
],
// 渐变色2
[
'#90D55C'
,
'#FDDB93'
],
// 渐变色2
]
]
},
rotate
:{
type
:
Number
,
default
:
45
}
}
},
},
watch
:
{
watch
:
{
...
@@ -49,14 +53,15 @@ export default {
...
@@ -49,14 +53,15 @@ export default {
axisLine
:
{
show
:
false
},
axisLine
:
{
show
:
false
},
axisLabel
:
{
axisLabel
:
{
interval
:
0
,
interval
:
0
,
rotate
:
45
rotate
:
this
.
rotate
}
}
},
},
yAxis
:
{
yAxis
:
{
type
:
'value'
,
type
:
'value'
,
axisTick
:
{
show
:
false
},
minInterval
:
1
,
// 确保Y轴刻度间隔最小为1,避免数据过小时出现小数点
axisLine
:
{
show
:
false
},
// axisTick: { show: false },
splitLine
:
{
show
:
false
},
// axisLine: { show: false },
// splitLine: { show: false },
// axisLabel: { show: false }
// axisLabel: { show: false }
},
},
series
:
[{
series
:
[{
...
@@ -69,13 +74,15 @@ export default {
...
@@ -69,13 +74,15 @@ export default {
},
},
itemStyle
:
{
itemStyle
:
{
color
:
(
params
)
=>
{
color
:
(
params
)
=>
{
const
dataIndex
=
params
.
dataIndex
const
dataIndex
=
params
.
dataIndex
;
const
gradientIndex
=
Math
.
floor
(
dataIndex
%
2
)
const
gradientIndex
=
dataIndex
%
this
.
colors
.
length
;
// 循环使用渐变色
const
colorPair
=
this
.
colors
[
gradientIndex
];
return
{
return
{
type
:
'linear'
,
type
:
'linear'
,
colorStops
:
[
colorStops
:
[
{
offset
:
0
,
color
:
this
.
colors
[
gradientIndex
]
[
0
]
},
{
offset
:
0
,
color
:
colorPair
[
0
]
},
{
offset
:
1
,
color
:
this
.
colors
[
gradientIndex
]
[
1
]
},
{
offset
:
1
,
color
:
colorPair
[
1
]
},
],
],
globalCoord
:
false
,
globalCoord
:
false
,
x
:
0
,
// 渐变的起始点横坐标
x
:
0
,
// 渐变的起始点横坐标
...
@@ -84,14 +91,9 @@ export default {
...
@@ -84,14 +91,9 @@ export default {
y2
:
1
,
// 渐变的结束点纵坐标(设置为1表示从上到下
y2
:
1
,
// 渐变的结束点纵坐标(设置为1表示从上到下
};
};
},
},
barBorderRadius
:
5
barBorderRadius
:
3
}
}
// itemStyle: {
// color: (params) => {
// return this.colors[params.dataIndex % this.colors.length];
// },
// barBorderRadius: 5
// }
}]
}]
};
};
...
@@ -102,9 +104,9 @@ export default {
...
@@ -102,9 +104,9 @@ export default {
</
script
>
</
script
>
<
style
lang=
"scss"
>
<
style
lang=
"scss"
>
#chart
{
//
#chart
{
width
:
100%
;
//
width
:
100%
;
height
:
400px
;
//
height
:
400px
;
}
//
}
</
style
>
</
style
>
src/views/userPortrait/components/LineChart.vue
View file @
c89e93c
<
template
>
<
template
>
<div
class=
"line-chart"
>
<div
class=
"line-chart"
>
<p
class=
"line-color-title"
>
{{
title
}}
</p>
<p
class=
"line-color-title"
>
{{
title
}}
</p>
<div
ref=
"lineChart"
style=
"width: 100%; height:30vh;"
></div>
<div
v-if=
"data"
ref=
"lineChart"
style=
"width: 100%; height:30vh;"
></div>
</div>
</div>
</
template
>
</
template
>
...
@@ -46,11 +46,12 @@ export default {
...
@@ -46,11 +46,12 @@ export default {
xAxis
:
{
xAxis
:
{
type
:
'category'
,
type
:
'category'
,
boundaryGap
:
false
,
boundaryGap
:
false
,
axisTick
:
{
show
:
false
},
//
axisTick: { show: false },
data
:
this
.
data
.
map
(
item
=>
item
.
name
),
data
:
this
.
data
.
map
(
item
=>
item
.
name
),
},
},
yAxis
:
{
yAxis
:
{
type
:
'value'
,
type
:
'value'
,
minInterval
:
1
,
// 确保Y轴刻度间隔最小为1,避免数据过小时出现小数点
},
},
series
:
[
series
:
[
{
{
...
...
src/views/userPortrait/components/PieChart.vue
View file @
c89e93c
<
template
>
<
template
>
<div>
<div>
<p
class=
"line-color-title"
>
{{
title
}}
</p>
<p
class=
"line-color-title"
>
{{
title
}}
</p>
<div
ref=
"pieChart"
style=
"margin-top:10px;width: 100%; height: 20
vh;"
></div>
<div
v-if=
"data"
ref=
"pieChart"
style=
"margin-top:10px;width: 100%; height:22
vh;"
></div>
</div>
</div>
</
template
>
</
template
>
...
@@ -25,12 +25,32 @@ export default {
...
@@ -25,12 +25,32 @@ export default {
default
:
()
=>
[
'#50CEFB'
,
'#5850FF'
,
'#FBBE50'
,
'#90D55C'
,
'#FDDB93'
,
'#A1EDFF'
,
'#6EA3FF'
,
'#FF5A92'
,
'#BCCAFF'
,
'#9F6EFF'
],
default
:
()
=>
[
'#50CEFB'
,
'#5850FF'
,
'#FBBE50'
,
'#90D55C'
,
'#FDDB93'
,
'#A1EDFF'
,
'#6EA3FF'
,
'#FF5A92'
,
'#BCCAFF'
,
'#9F6EFF'
],
},
},
},
},
data
()
{
return
{
dynamicRichStyles
:
{},
};
},
mounted
()
{
mounted
()
{
this
.
initChart
(
this
.
$refs
.
pieChart
);
this
.
initChart
(
this
.
$refs
.
pieChart
);
this
.
drawChart
();
this
.
drawChart
();
},
},
methods
:
{
methods
:
{
generateRichStyles
()
{
this
.
colors
.
forEach
((
color
,
index
)
=>
{
this
.
dynamicRichStyles
[
'style'
+
index
]
=
{
color
:
color
,
fontWeight
:
'bold'
,
fontSize
:
'17px'
};
});
},
createFormatter
(
params
)
{
const
styleKey
=
'style'
+
(
params
.
dataIndex
%
this
.
colors
.
length
);
return
`{
${
styleKey
}
|
${
params
.
value
}
%}\n\n{b|
${
params
.
name
}
}`
;
},
drawChart
()
{
drawChart
()
{
this
.
generateRichStyles
();
// 生成动态样式
const
chart
=
echarts
.
init
(
this
.
$refs
.
pieChart
);
const
chart
=
echarts
.
init
(
this
.
$refs
.
pieChart
);
const
option
=
{
const
option
=
{
...
@@ -45,25 +65,12 @@ export default {
...
@@ -45,25 +65,12 @@ export default {
type
:
'pie'
,
type
:
'pie'
,
radius
:
[
'40%'
,
'60%'
],
radius
:
[
'40%'
,
'60%'
],
avoidLabelOverlap
:
false
,
avoidLabelOverlap
:
false
,
minAngle
:
50
,
// 设置最小角度为50度,针对传入的数据为0
label
:
{
label
:
{
show
:
true
,
show
:
true
,
position
:
'outside'
,
position
:
'outside'
,
formatter
:
function
(
params
)
{
formatter
:
this
.
createFormatter
,
// 引用 formatter 函数
return
'{a|'
+
params
.
value
+
'%'
+
'}'
rich
:
this
.
dynamicRichStyles
,
// 使用动态生成的样式
+
'\n'
+
'\n'
+
' {b|'
+
params
.
name
+
'}'
},
rich
:
{
a
:
{
color
:
'#50CEFB'
,
fontWeight
:
'bold'
,
fontSize
:
'18px'
},
b
:
{
color
:
'#333'
,
fontSize
:
'14px'
,
}
}
},
},
labelLine
:
{
labelLine
:
{
show
:
true
show
:
true
...
...
src/views/userPortrait/index.vue
View file @
c89e93c
<
template
>
<
template
>
<!-- 该页面图表显示的颜色均可通过传入color参数修改-->
<!-- 该页面图表显示的颜色均可通过传入color参数修改-->
<div
class=
"dashboard"
>
<div
class=
"dashboard"
>
<!-- 用户信息部分 -->
<!-- 用户信息部分 -->
<div
class=
"user-section"
>
<div
class=
"user-section"
>
...
@@ -13,13 +13,20 @@
...
@@ -13,13 +13,20 @@
<!-- 图表部分 -->
<!-- 图表部分 -->
<div
class=
"charts-section"
>
<div
class=
"charts-section"
>
<PieChart
:title=
"'客户来源'"
v-if=
"sourceDistribution"
:data=
"sourceDistribution"
/>
<PieChart
:title=
"'客户来源'"
:data=
"sourceDistribution"
/>
<PieChart
:title=
"'租住比'"
v-if=
"lodgeDistribution"
:data=
"lodgeDistribution"
/>
<PieChart
:title=
"'租住比'"
:data=
"lodgeDistribution"
/>
<PieChart
:title=
"'消费能力'"
v-if=
"consumeDistribution"
:data=
"consumeDistribution"
/>
<PieChart
:title=
"'消费能力'"
:data=
"consumeDistribution"
/>
<PieChart
:title=
"'车辆类型'"
v-if=
"vehicleDistribution"
:data=
"vehicleDistribution"
/>
<PieChart
:title=
"'车辆类型'"
:data=
"vehicleDistribution"
/>
<LineChart
:title=
"'浏览时段偏好'"
v-if=
"browseDistribution"
:data=
"browseDistribution"
/>
<BarChart
:title=
"'甄选商品偏好(top10)'"
:data=
"productDistribution"
></BarChart>
<BarChart
:title=
"'甄选商品偏好(top10)'"
v-if=
"productDistribution"
:data=
"productDistribution"
></BarChart>
<BarChart
:title=
"'攻略偏好(top10)'"
:data=
"productDistribution"
></BarChart>
<BarChart
:title=
"'权益购买偏好(top10)'"
:data=
"productDistribution"
></BarChart>
<LineChart
:title=
"'浏览时段偏好'"
:data=
"browseDistribution"
/>
<PieChart
:title=
"'客户购买转化阶段'"
:data=
"vehicleDistribution"
/>
<BarChart
:title=
"'客户全生命周期价值(LTV)'"
:data=
"productDistribution"
:colors=
"[['#6E77FF', '#A1D9FF']]"
:rotate=
"0"
></BarChart>
</div>
</div>
</div>
</div>
...
@@ -75,13 +82,42 @@ export default {
...
@@ -75,13 +82,42 @@ export default {
methods
:
{
methods
:
{
async
getUserPortraitData
()
{
async
getUserPortraitData
()
{
// 44209572
// 44209572
const
merchantId
=
44209572
// this.$globalState.session.merchantId
// this.$globalState.session.merchantId
await
this
.
$apis
.
userPortrait
.
getPortraitData
({
merchantId
:
this
.
$globalState
.
session
.
merchantId
}).
then
(
res
=>
{
await
this
.
$apis
.
userPortrait
.
getPortraitData
({
merchantId
}).
then
(
res
=>
{
for
(
const
key
in
res
)
{
for
(
const
key
in
res
)
{
if
(
this
.
hasOwnProperty
(
key
))
{
if
(
this
.
hasOwnProperty
(
key
))
{
this
[
key
]
=
res
[
key
]
this
[
key
]
=
res
[
key
]
}
}
}
}
this
.
productDistribution
=
[{
name
:
"配件用品"
,
value
:
0
},
{
name
:
"商品3"
,
value
:
0
},
{
name
:
"化妆用品"
,
value
:
1
},
{
name
:
"划船20232"
,
value
:
1
},
{
name
:
"商品1"
,
value
:
0
},
{
name
:
"休闲零食"
,
value
:
1
},
{
name
:
"划船5"
,
value
:
0
},
{
name
:
"划船"
,
value
:
1
},
{
name
:
"日常用品"
,
value
:
3
}]
})
})
},
},
findSexCount
(
sex
)
{
findSexCount
(
sex
)
{
...
@@ -113,9 +149,10 @@ export default {
...
@@ -113,9 +149,10 @@ export default {
width
:
69vw
;
width
:
69vw
;
grid-template-columns
:
repeat
(
2
,
1
fr
);
grid-template-columns
:
repeat
(
2
,
1
fr
);
gap
:
20px
;
gap
:
20px
;
background-color
:
#fff
;
background-color
:
#fff
;
padding
:
10px
;
padding
:
10px
;
overflow-y
:
auto
;
//
添加这一行来实现滚动
max-height
:
89.5vh
;
//
可以设置一个最大高度,超过这个高度将显示滚动条
}
}
}
}
</
style
>
</
style
>
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