| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 | <template>	<view>		<canvas canvas-id="canvasRing" id="canvasRing" @touchstart="touchRing"			style="width: 700upx; height:500upx;"></canvas>	</view></template><script>	import uCharts from '@/components/u-charts/u-charts.js';	var _self;	var canvaRing = null;	export default {		data() {			return {				cWidth: '',				cHeight: '',				pixelRatio: 1,				serverData: '',			}		},		mounted() {			_self = this;			this.cWidth = uni.upx2px(700);			this.cHeight = uni.upx2px(500);			this.getServerData();		},		methods: {			getServerData() {				this.$p_api.coalmine_output({				}).then((res) => {					let Ring = {						"series": [{							"name": "早班 000000 吨",							"data": 0						}, {							"name": "中班 000000 吨",							"data": 0						}, {							"name": "晚班 000000 吨",							"data": 0						}],						"total": 0					};					// console.log(res.data.data)					Ring.total = res.data.data.total					// console.log(Ring.total)					Ring.series[0].name = '早班 ' + res.data.data.n1 + ' 吨'					Ring.series[0].data = res.data.data.n1					Ring.series[1].name = '中班 ' + res.data.data.n2 + ' 吨'					Ring.series[1].data = res.data.data.n2					Ring.series[2].name = '晚班 ' + res.data.data.n3 + ' 吨'					Ring.series[2].data = res.data.data.n3					// console.log(Ring)					_self.showRing("canvasRing", Ring);				})			},			showRing(canvasId, chartData) {				canvaRing = new uCharts({					$this: _self,					canvasId: canvasId,					type: 'ring',					fontSize: 11,					legend: {						position: 'left',						lineHeight: 50,					},					title: {						name: chartData.total + ' 吨',						color: '#000000',						fontSize: 20 * _self.pixelRatio,						offsetY: 20 * _self.pixelRatio,					},					subtitle: {						name: '总产量',						color: '#666666',						fontSize: 14 * _self.pixelRatio,						offsetY: -30 * _self.pixelRatio,					},					extra: {						pie: {							offsetAngle: -90,							ringWidth: 20 * _self.pixelRatio,							labelWidth: 15						}					},					background: '#FFFFFF',					pixelRatio: _self.pixelRatio,					series: chartData.series,					animation: true,					width: _self.cWidth * _self.pixelRatio,					height: _self.cHeight * _self.pixelRatio,					disablePieStroke: true,					dataLabel: false,				});			},			touchRing(e) {				canvaRing.showToolTip(e, {					format: function(item) {						// return item.name + ' : ' + item.data + ' 吨'						return item.name					}				});			},		}	}</script><style></style>
 |