<template>
	<ChartCard margin="30rpx 0 0 0" title="质量验收数据">
		<view class="ys">
			<qiun-data-charts type="mix" :opts="opts" :chartData="chartData" @getIndex="handleTap" />
		</view>
		<view class="ys u-margin-top-30">
			<qiun-data-charts type="mix" :opts="opts" :chartData="chartData" @getIndex="handleTap" />
		</view>
	</ChartCard>
</template>

<script setup>
	import ChartCard from '@/components/chartCard.vue'
	import {
		ref
	} from 'vue';
	import {
		onReady
	} from '@dcloudio/uni-app'

	const opts = ref({
		color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4", "#ea7ccc"],
		padding: [15, 15, 0, 15],
		enableScroll: false,
		legend: {			fontSize: 10},
		xAxis: {
			disableGrid: true,
		},
		yAxis: {
			disabled: false,
			disableGrid: false,
			splitNumber: 5,
			gridType: "dash",
			dashLength: 4,
			gridColor: "#CCCCCC",
			padding: 10,
			showTitle: true,
			data: [{
					position: "right",
					min: 0,
					max: 100,
					title: "百分比"
				},
				{
					position: "left",
					title: "数量",
					textAlign: "left"
				}
			]
		},
		extra: {
			mix: {
				column: {
					width: 20,
					seriesGap: 8
				}
			}
		}
	})

	const chartData = ref({})
	const chartData1 = ref({})
	const handleTap = (e) => {
		console.log(e)
	}


	onReady(() => {
		let res = {
		categories: ["关键工序验收", "特殊工程验收", "隐藏工程验收"],
		series: [{
				name: "合格率",
				type: "line",
				style: "curve",
				color: "#ffe200",
				disableLegend: true,
				data: [70, 50, 85]
			},
			{
				name: "验收数",
				index: 1,
				type: "column",
				data: [40, 55, 110]
			},
			{
				name: "合格数",
				index: 1,
				type: "column",
				data: [50, 20, 75]
			},
		]
		};
		chartData.value = JSON.parse(JSON.stringify(res));
		
		let res1 = {
			categories: ["单位工程", "分部工程", "分项工程"],
			series: [{
					name: "合格率",
					type: "line",
					style: "curve",
					color: "#ffe200",
					disableLegend: true,
					data: [70, 50, 85]
				},
				{
					name: "验收数",
					index: 1,
					type: "column",
					data: [40, 55, 110]
				},
				{
					name: "合格数",
					index: 1,
					type: "column",
					data: [50, 20, 75]
				},
			]
		};
		chartData1.value = JSON.parse(JSON.stringify(res1));
	})
</script>

<style lang="scss">
	.ys {
		height: 300rpx;
	}
</style>