12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <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() {
- let Ring = {
- "series": [{
- "name": "早班 63950.8 吨",
- "data": 63950.8
- }, {
- "name": "中班 5860.8 吨",
- "data": 5860.8
- }, {
- "name": "晚班 0 吨",
- "data": 0
- }]
- };
- _self.showRing("canvasRing", Ring);
- },
- showRing(canvasId, chartData) {
- canvaRing = new uCharts({
- $this: _self,
- canvasId: canvasId,
- type: 'ring',
- fontSize: 11,
- legend: {
- show: true,
- position: 'left',
- lineHeight: 40,
- },
- title: {
- name: '69811.6吨',
- 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>
|