<template>
	<view class="charts-box" style="min-height: 580rpx;">
		<qiun-data-charts type="ring" :opts="optsPied" :chartData="chartDataPied" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				chartDataPied: {},
				optsPied: {
					rotate: false,
					rotateLock: false,
					color: ['#1372FF', '#F89F2A', '#02C493'],
					padding: [30, 30, 30, 35],
					dataLabel: true,
					enableScroll: false,
					legend: {
						show: true,
						position: "bottom",
						lineHeight: 25
					},
					title: {
						name: "",
						fontSize: 15,
						color: "#666666"
					},
					subtitle: {
						name: "",
						fontSize: 25,
						color: "#7cb5ec"
					},
					extra: {
						ring: {
							ringWidth: 25,
							activeOpacity: 0.5,
							activeRadius: 10,
							offsetAngle: 0,
							labelWidth: 10,
							border: false,
							borderWidth: 3,
							borderColor: "#FFFFFF"
						}
					},
				},
				fromData: {
					dateDay: '2024-01',
					homestayId: '1744620500506251265'
				},
				PieChartsList: {},
				objList: {}
			};
		},
		onReady() {
			setTimeout(() => {
				this.objList = wx.getStorageSync('fromData')
				this.fromData.dateDay = this.objList.dateDay
				this.fromData.homestayId = this.objList.homestayId
				console.log('环图0000', this.objList);
			}, 2000);
			console.log('789465');
			setTimeout(() => {
				this.getServerData();
			}, 3000);

		},
		methods: {
			getServerData() {
				this.PieChartsList = this.objList
				console.log('环图2222', this.PieChartsList);
				this.PieChartsList = {
					series: [{
						data: [{
								"name": "房费",
								"value": this.PieChartsList.roomAmount,
								"labelText": "房费" + this.PieChartsList.roomRatio + '%'
							},
							{
								"name": "商品",
								"value": this.PieChartsList.othersAmount,
								"labelText": "商品" + this.PieChartsList.othersRatio + '%'
							},
							{
								"name": "其他",
								"value": this.PieChartsList.breakfastAmount,
								"labelText": "其他" + this.PieChartsList.breakfastRatio + '%',
							},

						],

					}],
				}
				this.chartDataPied = JSON.parse(JSON.stringify(this.PieChartsList));
			},

		}
	};
</script>

<style scoped>
	/* 请根据实际需求修改父元素尺寸，组件自动识别宽高 */
	.charts-box {
		width: 600rpx !important;
		height: 560rpx !important;
	}
</style>