Commit 35c4e046 by 前端

Merge branch 'v3.23.0' into 'master'

V3.23.0

See merge request !183
2 parents 3917b2fc d5a450f8
<template>
<div class="bar-chart">
<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>
</template>
......@@ -27,6 +27,10 @@ export default {
['#6E77FF', '#A1D9FF'], // 渐变色1
['#90D55C', '#FDDB93'], // 渐变色2
]
},
rotate:{
type:Number,
default:45
}
},
watch: {
......@@ -41,26 +45,38 @@ export default {
drawChart() {
const chart = echarts.init(this.$refs.barChart);
let xAxisData, seriesData;
if (this.data && this.data.length > 0) {
xAxisData = this.data.map(item => item.name);
seriesData = this.data.map(item => item.value);
} else {
// 当data为空时,设置默认的X轴和Y轴,但不包含数据点
xAxisData = [''];
seriesData = [0];
}
const option = {
xAxis: {
type: 'category',
data: this.data.map(item => item.name),
axisTick: { show: false },
axisLine: { show: false },
axisLine: { show: true },
axisLabel: {
interval: 0,
rotate: 45
rotate: this.rotate
}
},
yAxis: {
type: 'value',
axisTick: { show: false },
axisLine: { show: false },
splitLine: { show: false },
minInterval: 1, // 确保Y轴刻度间隔最小为1,避免数据过小时出现小数点
// axisTick: { show: false },
// axisLine: { show: false },
// splitLine: { show: false },
// axisLabel: { show: false }
},
series: [{
data: this.data.map(item => item.value),
data: seriesData,
type: 'bar',
barWidth: '20%',
label: {
......@@ -69,13 +85,15 @@ export default {
},
itemStyle: {
color: (params) => {
const dataIndex = params.dataIndex
const gradientIndex = Math.floor(dataIndex%2)
const dataIndex = params.dataIndex;
const gradientIndex = dataIndex % this.colors.length; // 循环使用渐变色
const colorPair = this.colors[gradientIndex];
return {
type: 'linear',
colorStops: [
{ offset: 0, color: this.colors[gradientIndex][0] },
{ offset: 1, color: this.colors[gradientIndex][1] },
{ offset: 0, color: colorPair[0] },
{ offset: 1, color: colorPair[1] },
],
globalCoord: false,
x: 0, // 渐变的起始点横坐标
......@@ -84,14 +102,9 @@ export default {
y2: 1, // 渐变的结束点纵坐标(设置为1表示从上到下
};
},
barBorderRadius: 5
barBorderRadius: 3
}
// itemStyle: {
// color: (params) => {
// return this.colors[params.dataIndex % this.colors.length];
// },
// barBorderRadius: 5
// }
}]
};
......@@ -102,9 +115,9 @@ export default {
</script>
<style lang="scss">
#chart {
width: 100%;
height: 400px;
}
//#chart {
// width: 100%;
// height: 400px;
//}
</style>
<template>
<div class="line-chart">
<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>
</template>
......@@ -46,11 +46,12 @@ export default {
xAxis: {
type: 'category',
boundaryGap: false,
axisTick: { show: false },
// axisTick: { show: false },
data: this.data.map(item => item.name),
},
yAxis: {
type: 'value',
minInterval: 1, // 确保Y轴刻度间隔最小为1,避免数据过小时出现小数点
},
series: [
{
......
<template>
<div>
<p class="line-color-title">{{title}}</p>
<div ref="pieChart" style="margin-top:10px;width: 100%; height: 20vh;"></div>
<div v-if="data" ref="pieChart" style="margin-top:10px;width: 100%; height:24.5vh;"></div>
</div>
</template>
......@@ -25,12 +25,43 @@ export default {
default: () => ['#50CEFB', '#5850FF','#FBBE50','#90D55C','#FDDB93','#A1EDFF','#6EA3FF','#FF5A92','#BCCAFF','#9F6EFF'],
},
},
data() {
return {
dynamicRichStyles: {},
};
},
mounted() {
this.initChart(this.$refs.pieChart);
this.drawChart();
this.dynamicResizeChart();
},
methods: {
generateRichStyles() {
this.colors.forEach((color, index) => {
this.dynamicRichStyles['style' + index] = {
color: color,
fontWeight: 'bold',
fontSize: '17px'
};
});
},
createFormatter(params) {
const dataIndex = params.dataIndex;
const dataItem = this.data[dataIndex]; // 获取当前索引下的数据项
const styleKey = 'style' + (dataIndex % this.colors.length);
// 确保dataItem存在,并且displayQuantity已定义
const displayQuantityText = dataItem && dataItem.displayQuantity !== undefined && dataItem.displayQuantity !== null
? '('+dataItem.displayQuantity + '人' + ')'
: '';
return `{${styleKey}|${params.value}%}\n\n{b|${params.name}${displayQuantityText}}`;
},
drawChart() {
this.generateRichStyles(); // 生成动态样式
const chart = echarts.init(this.$refs.pieChart);
const option = {
......@@ -45,25 +76,12 @@ export default {
type: 'pie',
radius: ['40%', '60%'],
avoidLabelOverlap: false,
minAngle: 50, // 设置最小角度为50度,针对传入的数据为0
label: {
show: true,
position: 'outside',
formatter: function(params) {
return '{a|' + params.value + '%'+ '}'
+'\n'+'\n'+
' {b|' + params.name + '}'
},
rich: {
a: {
color: '#50CEFB',
fontWeight: 'bold',
fontSize:'18px'
},
b: {
color: '#333',
fontSize:'14px',
}
}
formatter: this.createFormatter, // 引用 formatter 函数
rich: this.dynamicRichStyles, // 使用动态生成的样式
},
labelLine: {
show: true
......@@ -84,6 +102,12 @@ export default {
};
</script>
<style lang="scss">
<style lang="scss" scoped>
/* 您可以根据需要添加自定义样式 */
@media screen and (min-resolution: 2dppx) {
/* 针对高分辨率显示屏的样式调整 */
.pieChart {
height: 28vh; /* 可能需要更大的高度 */
}
}
</style>
......@@ -4,10 +4,7 @@
<div class="avatar male"></div>
<span>男</span>
<div class="progress">
<div class="fill male" :style="{ width: malePercentage==0? 50: malePercentage+ '%','min-width':'40%',
'max-width':'50%',
'margin-left':(30 <malePercentage && malePercentage < 50 ? malePercentage:0 <malePercentage && malePercentage <30?
malePercentage*2 : malePercentage/4) + '%' }">{{
<div class="fill male" :style="styleObject">{{
malePercentage || 0
}}%
</div>
......@@ -42,6 +39,28 @@ export default {
}
},
computed: {
styleObject() {
// 基本的宽度样式
let widthStyle = this.malePercentage === 0 ? '50%' : `${this.malePercentage}%`;
// 计算marginLeft
let marginLeftStyle;
if (this.malePercentage > 30 && this.malePercentage < 50) {
marginLeftStyle = `${this.malePercentage}%`;
} else if (this.malePercentage > 0 && this.malePercentage < 30) {
marginLeftStyle = `${this.malePercentage * 2}%`;
} else {
marginLeftStyle = `${this.malePercentage / 4}%`;
}
// 返回样式对象
return {
width: widthStyle,
'min-width': '40%',
'max-width': '50%',
'margin-left': marginLeftStyle,
};
},
malePercentage() {
let percentage = (this.maleCount / (this.maleCount + this.femaleCount)) * 100;
......
<template>
<!-- 该页面图表显示的颜色均可通过传入color参数修改-->
<!-- 该页面图表显示的颜色均可通过传入color参数修改-->
<div class="dashboard">
<!-- 用户信息部分 -->
<div class="user-section">
......@@ -13,13 +13,20 @@
<!-- 图表部分 -->
<div class="charts-section">
<PieChart :title="'客户来源'" v-if="sourceDistribution" :data="sourceDistribution"/>
<PieChart :title="'租住比'" v-if="lodgeDistribution" :data="lodgeDistribution"/>
<PieChart :title="'消费能力'" v-if="consumeDistribution" :data="consumeDistribution"/>
<PieChart :title="'车辆类型'" v-if="vehicleDistribution" :data="vehicleDistribution"/>
<PieChart :title="'客户来源'" :data="sourceDistribution"/>
<PieChart :title="'租住比'" :data="lodgeDistribution"/>
<PieChart :title="'消费能力'" :data="consumeDistribution"/>
<PieChart :title="'车辆类型'" :data="vehicleDistribution"/>
<LineChart :title="'浏览时段偏好'" v-if="browseDistribution" :data="browseDistribution"/>
<BarChart :title="'甄选商品偏好(top10)'" v-if="productDistribution" :data="productDistribution"></BarChart>
<BarChart :title="'甄选商品偏好(top10)'" :data="productDistribution"></BarChart>
<BarChart :title="'攻略偏好(top10)'" :data="strategyDistribution"></BarChart>
<BarChart :title="'权益购买偏好(top10)'" :data="equityDistribution"></BarChart>
<LineChart :title="'浏览时段偏好'" :data="browseDistribution"/>
<PieChart :title="'客户购买转化阶段'" :data="transformDistribution"/>
<BarChart :title="'客户全生命周期价值(LTV)'" :data="ltvDistribution"
:colors="[['#6E77FF', '#A1D9FF']]" :rotate="0"></BarChart>
</div>
</div>
......@@ -58,6 +65,11 @@ export default {
browseDistribution: null,
productDistribution: null,
strategyDistribution: null,
equityDistribution: null,
transformDistribution: null,
ltvDistribution: null,
mockAgeColors: [
{offset: 0.02, color: '#BCCAFF'},
{offset: 1, color: '#9F6EFF'}],
......@@ -75,8 +87,9 @@ export default {
methods: {
async getUserPortraitData() {
// 44209572
const merchantId = 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) {
if (this.hasOwnProperty(key)) {
this[key] = res[key]
......@@ -113,9 +126,10 @@ export default {
width: 69vw;
grid-template-columns: repeat(2, 1fr);
gap: 20px;
background-color: #fff;
padding: 10px;
overflow-y: auto; // 添加这一行来实现滚动
max-height: 89.5vh; // 可以设置一个最大高度,超过这个高度将显示滚动条
}
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!