<template>
	<view class="p20">
		<view class="content f28 gray6 d-e-c">{{ $t('N_I_116') }}</view>
		<view style="width: 710rpx;"><qiun-data-charts type="bar" :opts="opts" :chartData="chartData" /></view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			chartData: {},
			//这里的 opts 是图表类型 type="bar" 的全部配置参数，您可以将此配置复制到 config-ucharts.js 文件中下标为 ['bar'] 的节点中来覆盖全局默认参数。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式，达到页面简洁的需求。
			opts: {
				timing: 'easeOut',
				duration: 1000,
				rotate: false,
				rotateLock: false,
				color: ['#ffae36', '#ff5a5a', '#2982ff', '#01c291', '#73C0DE', '#3CA272', '#FC8452', '#9A60B4', '#ea7ccc'],
				padding: [15, 30, 0, 5],
				fontSize: 11,
				fontColor: '#666666',
				dataLabel: true,
				dataPointShape: true,
				dataPointShapeType: 'solid',
				touchMoveLimit: 60,
				enableScroll: false,
				enableMarkLine: false,
				legend: {
					show: true,
					position: 'bottom',
					float: 'center',
					padding: 5,
					margin: 5,
					backgroundColor: 'rgba(0,0,0,0)',
					borderColor: 'rgba(0,0,0,0)',
					borderWidth: 0,
					fontSize: 11,
					fontColor: '#666666',
					lineHeight: 11,
					hiddenColor: '#CECECE',
					itemGap: 10
				},
				xAxis: {
					boundaryGap: 'justify',
					disableGrid: false,
					min: 0,
					axisLine: false,
					disabled: false,
					axisLineColor: '#CCCCCC',
					calibration: false,
					fontColor: '#666666',
					fontSize: 11,
					lineHeight: 20,
					marginTop: 0,
					rotateLabel: false,
					rotateAngle: 45,
					itemCount: 5,
					splitNumber: 5,
					gridColor: '#CCCCCC',
					gridType: 'solid',
					dashLength: 4,
					gridEval: 1,
					scrollShow: false,
					scrollAlign: 'left',
					scrollColor: '#A6A6A6',
					scrollBackgroundColor: '#EFEBEF',
					title: '',
					titleFontSize: 11,
					titleOffsetY: 0,
					titleOffsetX: 0,
					titleFontColor: '#666666',
					format: 'days'
				},
				yAxis: {
					disabled: true,
					disableGrid: false,
					splitNumber: 5,
					gridType: 'solid',
					dashLength: 8,
					gridColor: '#CCCCCC',
					padding: 80,
					showTitle: false,
					data: []
				},
				extra: {
					bar: {
						type: 'group',
						width: 20,
						meterBorde: 1,
						meterFillColor: '#FFFFFF',
						activeBgColor: '#000000',
						activeBgOpacity: 0.08,
						seriesGap: 8,
						categoryGap: 18,
						barBorderCircle: true,
						linearType: 'none',
						linearOpacity: 1,
						colorStop: 0
					},
					tooltip: {
						showBox: true,
						showArrow: true,
						showCategory: false,
						borderWidth: 0,
						borderRadius: 0,
						borderColor: '#000000',
						borderOpacity: 0.7,
						bgColor: '#000000',
						bgOpacity: 0.7,
						gridType: 'solid',
						dashLength: 4,
						gridColor: '#CCCCCC',
						boxPadding: 3,
						fontSize: 11,
						lineHeight: 20,
						fontColor: '#FFFFFF',
						legendShow: true,
						legendShape: 'auto',
						splitLine: true,
						horizentalLine: false,
						xAxisLabel: false,
						yAxisLabel: false,
						labelBgColor: '#FFFFFF',
						labelBgOpacity: 0.7,
						labelFontColor: '#666666'
					},
					markLine: {
						type: 'solid',
						dashLength: 4,
						data: []
					}
				}
			}
		};
	},
	onReady() {
		this.getServerData();
	},
	methods: {
		getayFunc(seconds) {
			let d = Math.floor(seconds / (3600 * 24));
			if (d < 1) {
				d = seconds / (3600 * 24);
			}
			d = d < 10 && d >= 1 ? d : d;
			// console.log(d)
			return d;
		},
		getServerData() {
			let self = this;
			self._get('member/api/census/get-member-recommend-time', {}, res => {
				let list = [res.data];
				let obj = {
					categories: [],
					series: [
						{
							data: [],
							name: self.$t('N_I_119'),
							className: self.$t('S_L_6')
						},
						{
							data: [],
							name: self.$t('N_I_118'),
							className: self.$t('S_L_6')
						},
						{
							data: [],
							name: self.$t('N_I_120'),
							className: self.$t('S_L_6')
						},
						{
							data: [],
							name: self.$t('N_I_117'),
							className: self.$t('S_L_6')
						}
					]
				};
				if (list && list.length > 0) {
					list.forEach((item, index) => {
						obj.categories.push(item.date);
						obj.series[0].data.push(self.getayFunc(item.starTime * 1));
						obj.series[1].data.push(self.getayFunc(item.teamTime * 1));
						obj.series[2].data.push(self.getayFunc(item.companyTime * 1));
						obj.series[3].data.push(self.getayFunc(item.thisTime * 1));
					});
				}
				this.chartData = JSON.parse(JSON.stringify(obj));
			});
		}
	}
};
</script>

<style scoped>
page {
	background-color: #fff;
}

.content {
	padding: 26rpx 22rpx 26rpx 23rpx;
}

.picker-small {
	width: 232rpx;
	height: 72rpx;
	border: 1rpx solid #eeeeee;
	border-radius: 15rpx;
	font-size: 28rpx;
	padding: 0 28rpx 0 20rpx;
	display: flex;
	justify-content: space-between;
	align-items: center;
	box-sizing: border-box;
}

.charts {
	width: 750rpx;
	height: 500rpx;
}
</style>
