p-i-704.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <view>
  3. <!-- top -->
  4. <p-i-704-section-1></p-i-704-section-1>
  5. <!-- 今日产量 -->
  6. <p-i-704-section-2>
  7. <canvas style="width: 720upx; height:500upx;" canvas-id="canvasRing" id="canvasRing" @touchstart="touchRing"></canvas>
  8. </p-i-704-section-2>
  9. <!-- 安全检测 -->
  10. <p-i-704-section-3></p-i-704-section-3>
  11. <!-- 工业电视 -->
  12. <p-i-704-section-4></p-i-704-section-4>
  13. <!-- 机器 -->
  14. <p-i-704-section-5></p-i-704-section-5>
  15. </view>
  16. </template>
  17. <script>
  18. import uCharts from '@/components/u-charts/u-charts.js';
  19. var _self;
  20. var canvaRing = null;
  21. export default {
  22. data() {
  23. return {
  24. cWidth: '',
  25. cHeight: '',
  26. pixelRatio: 1,
  27. // serverData: '',
  28. }
  29. },
  30. onLoad() {
  31. _self = this;
  32. this.cWidth = uni.upx2px(720);
  33. this.cHeight = uni.upx2px(500);
  34. this.getServerData();
  35. },
  36. methods: {
  37. getServerData() {
  38. let Ring = {
  39. series: [{
  40. "name": "晚班",
  41. "data": 10000
  42. }, {
  43. "name": "中班",
  44. "data": 3000
  45. }, {
  46. "name": "早班",
  47. "data": 1000
  48. }, ]
  49. }
  50. _self.showRing("canvasRing", Ring);
  51. },
  52. showRing(canvasId, chartData) {
  53. canvaRing = new uCharts({
  54. $this: _self,
  55. canvasId: canvasId,
  56. type: 'ring',
  57. fontSize: 11,
  58. // 图裂配置
  59. // legend: true,
  60. legend: {
  61. position: "right",
  62. lineHeight: 30,
  63. },
  64. title: {
  65. name: '今日产量',
  66. color: '#666666',
  67. fontSize: 15 * _self.pixelRatio,
  68. offsetY: 0 * _self.pixelRatio,
  69. },
  70. subtitle: {
  71. name: '14000吨',
  72. color: '#666666',
  73. fontSize: 20 * _self.pixelRatio,
  74. offsetY: 0 * _self.pixelRatio,
  75. },
  76. extra: {
  77. pie: {
  78. offsetAngle: -45,
  79. ringWidth: 30 * _self.pixelRatio,
  80. labelWidth: 20
  81. }
  82. },
  83. background: '#FFFFFF',
  84. pixelRatio: _self.pixelRatio,
  85. series: chartData.series,
  86. animation: true,
  87. width: _self.cWidth * _self.pixelRatio,
  88. height: _self.cHeight * _self.pixelRatio,
  89. disablePieStroke: true,
  90. // 百分比指示 关
  91. dataLabel: false,
  92. });
  93. },
  94. touchRing(e) {
  95. canvaRing.showToolTip(e, {
  96. format: function(item) {
  97. return item.name + ':' + item.data + '吨'
  98. }
  99. });
  100. },
  101. }
  102. }
  103. </script>
  104. <style lang="scss">
  105. page{
  106. background-color: #f3f3f3;
  107. box-sizing: border-box;
  108. padding: 18rpx 15rpx;
  109. }
  110. </style>