You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

299 lines
6.5 KiB

1 year ago
<template>
<div class="center-left">
<div class="bs-card business-buy">
<div class="bs-card__title jc-between">
<p class="bs-card__title--text">
1 year ago
康养服务
1 year ago
</p>
<p>
<span class="color-word">658</span>
1 year ago
<span class="color-white">人次/</span>
1 year ago
</p>
</div>
<div class="business-buy__body">
1 year ago
<div>
<div id="property-line-chart"></div>
1 year ago
</div>
</div>
</div>
<div class="bs-card property">
1 year ago
<div id="property-pie-chart"></div>
1 year ago
</div>
</div>
</template>
<script>
1 year ago
import { getList } from "@/api/bigScreen";
1 year ago
import echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme
export default {
data() {
return {}
},
methods: {
1 year ago
async getChartData () {
try {
const res = (await getList({
type: 'kangyangfuwu'
},false))?.data
this.pieChartData = JSON.parse(res?.find(i => i.key === 'piechart')?.value)
this.initPieChart()
this.chartData = JSON.parse(res?.find(i => i.key === 'barchart')?.value)
this.initChart();
} catch (err) {
console.error(err)
}
},
1 year ago
initChart() {
this.chart = echarts.init(document.querySelector('#property-line-chart'), 'macarons');
this.setOptions(this.chartData);
},
1 year ago
initPieChart () {
this.chartPie = echarts.init(document.querySelector('#property-pie-chart'));
1 year ago
this.setPieOptions(this.pieChartData);
1 year ago
},
1 year ago
setOptions(chartdata) {
1 year ago
let color = ['#c95038','#e1884a','#ebb34c','#316922','#71dc7a','#6bb7be','#2050e0','#9952f6']
1 year ago
this.chart.setOption({
1 year ago
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
1 year ago
grid: {
top: 10,
left: '2%',
right: '3%',
bottom: '3%',
containLabel: true
},
1 year ago
xAxis: {
1 year ago
type: 'value',
1 year ago
splitLine: {
1 year ago
show: true,
1 year ago
lineStyle: {
color: '#384b8f', // 设置 X 轴间隔线颜色为红色
}
}
},
yAxis: {
type: 'category',
1 year ago
data: this.chartData.map(i => i.label),
1 year ago
axisLabel: {
textStyle: {
color: "#fff"
}
}
},
series: [
{
name: '人数',
type: 'bar',
1 year ago
data: this.chartData.map(i => i.value),
1 year ago
label: {
show: true,
position: 'insideRight',
color: '#fff',
fontWeight: 'bold',
formatter: '{c}'
},
itemStyle: {
color: (params) => {
1 year ago
return color[params.dataIndex]
1 year ago
},
1 year ago
barBorderRadius: [0,4,4,0],
},
}
]
})
},
setPieOptions () {
1 year ago
let color = [new echarts.graphic.LinearGradient(0.5, 0, 0.5, 1, [
{
offset: 0,
color: '#202aed'
},
{
offset: 1,
color: '#3b82f0'
}
]),new echarts.graphic.LinearGradient(0.5, 0, 0.5, 1, [
{
offset: 0,
color: '#84d7ee'
},
{
offset: 1,
color: '#6fe7fa'
}
])]
1 year ago
this.chartPie.setOption({
title: {
show: false,
},
tooltip: {
trigger: 'item'
},
series: [
{
type: 'pie',
radius: '64%',
center: ['50%', '50%'],
1 year ago
data: this.pieChartData.map((i, index) => ({
value: isNaN(Number(i.value)) ? 0 : Number(i.value),
name: i.label,
1 year ago
itemStyle: {
1 year ago
color: color[index],
1 year ago
shadowBlur: 10,
}
1 year ago
})),
1 year ago
roseType: 'radius',
label: {
color: '#fff',
formatter: '{b} \n {d}%'
},
labelLine: {
lineStyle: {
color: '#71e8fc'
},
smooth: 0.2,
length: 10,
length2: 20
},
1 year ago
1 year ago
animationType: 'scale',
animationEasing: 'elasticOut',
animationDelay: function (idx) {
return Math.random() * 200;
}
}
]
})
1 year ago
}
},
computed: {},
mounted() {
1 year ago
this.getChartData()
1 year ago
}
}
</script>
<style scoped lang="scss">
.center-left {
display: flex;
flex-direction: column;
justify-content: space-between;
.business-buy {
height: 382px;
&__body {
.digital {
width: 205px;
height: 188px;
margin: auto;
position: relative;
& > img {
width: 205px;
height: 188px;
display: block;
}
&-item {
font-size: 20px;
color: #31abe3;
font-weight: bold;
z-index: 2;
position: absolute;
}
&-item:nth-child(1) {
top: 46%;
right: -36%;
}
&-item:nth-child(2) {
left: 50%;
bottom: 10%;
}
&-item:nth-child(3) {
left: -20%;
bottom: 0;
}
}
.progress {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 20px;
padding: 0 15px;
&-item {
width: 91px;
position: relative;
}
&-name {
color: #fff;
text-align: center;
width: 52px;
height: 20px;
border-radius: 10px;
background-color: #0052e9;
position: absolute;
bottom: 6px;
left: calc(50% - 26px);
}
&-rate {
color: #00deff;
font-size: 20px;
transform: translate(-50%, -50%);
position: absolute;
top: 50%;
left: 50%;
}
}
}
}
.property {
height: 243px;
.chart-legend {
display: flex;
&__item {
display: flex;
align-items: center;
margin-left: 18px;
& > div {
width: 18px;
height: 18px;
border-radius: 4px;
margin-right: 15px;
}
& > p {
font-size: 16px;
}
}
}
}
}
#property-line-chart {
1 year ago
height: 335px;
width: 100%;
}
#property-pie-chart {
width: 100%;
height: 100%;
1 year ago
}
</style>