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

<script>
	export default {
		data() {
			return {
				chartDataPie: {},
				optsPie: {
					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'
				},
				list: {}
			};
		},
		onReady() {

			this.getServerData();
		},
		methods: {
			getServerData() {
				let obj = wx.getStorageSync('fromData')
				this.list = obj
				this.list = {
					series: [{
						data: [{
								"name": "房费",
								"value": this.list.roomAmount,
								"labelText": "房费" + this.list.roomRatio + '%'
							},
							{
								"name": "商品",
								"value": this.list.othersAmount,
								"labelText": "商品" + this.list.othersRatio + '%'
							},
							{
								"name": "其他",
								"value": this.list.breakfastAmount,
								"labelText": "其他" + this.list.breakfastRatio + '%',
							},

						],

					}],
				}
				this.chartDataPie = JSON.parse(JSON.stringify(this.list));
			},
		}
	};
</script>

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