old.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <view>
  3. <!-- 搜索井下人员 -->
  4. <p-i-o-navbar></p-i-o-navbar>
  5. <view class="content">
  6. <!-- 当前井下人员 -->
  7. <p-i-o-section-1>
  8. <!-- 圆环图 -->
  9. <canvas style="width: 720upx; height:500upx;" canvas-id="canvasRing" id="canvasRing" @touchstart="touchRing"></canvas>
  10. </p-i-o-section-1>
  11. <!-- 井下人员(区域分布) -->
  12. <p-i-o-section-2></p-i-o-section-2>
  13. <!-- 井下人员(部门分布) -->
  14. <p-i-o-section-3></p-i-o-section-3>
  15. <!-- 各科室下井人数 -->
  16. <p-i-o-section-4></p-i-o-section-4>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import uCharts from '@/components/u-charts/u-charts.js';
  22. var _self;
  23. var canvaRing = null;
  24. export default {
  25. data() {
  26. return {
  27. cWidth: '',
  28. cHeight: '',
  29. pixelRatio: 1,
  30. serverData: '',
  31. }
  32. },
  33. onLoad() {
  34. _self = this;
  35. this.cWidth = uni.upx2px(720);
  36. this.cHeight = uni.upx2px(500);
  37. this.getServerData();
  38. },
  39. methods: {
  40. getServerData() {
  41. let Ring = {
  42. series: [
  43. {
  44. "name": "一班",
  45. "data": 50
  46. }, {
  47. "name": "二班",
  48. "data": 30
  49. }, {
  50. "name": "三班",
  51. "data": 20
  52. }, {
  53. "name": "四班",
  54. "data": 18
  55. }, {
  56. "name": "五班",
  57. "data": 8
  58. },
  59. ]
  60. }
  61. _self.showRing("canvasRing", Ring);
  62. },
  63. showRing(canvasId, chartData) {
  64. canvaRing = new uCharts({
  65. $this: _self,
  66. canvasId: canvasId,
  67. type: 'ring',
  68. fontSize: 11,
  69. legend: true,
  70. title: {
  71. name: '70%',
  72. color: '#7cb5ec',
  73. fontSize: 25 * _self.pixelRatio,
  74. offsetY: 0 * _self.pixelRatio,
  75. },
  76. subtitle: {
  77. name: '收益率',
  78. color: '#666666',
  79. fontSize: 15 * _self.pixelRatio,
  80. offsetY: 0 * _self.pixelRatio,
  81. },
  82. extra: {
  83. pie: {
  84. offsetAngle: -45,
  85. ringWidth: 40 * _self.pixelRatio,
  86. labelWidth: 15
  87. }
  88. },
  89. background: '#FFFFFF',
  90. pixelRatio: _self.pixelRatio,
  91. series: chartData.series,
  92. animation: true,
  93. width: _self.cWidth * _self.pixelRatio,
  94. height: _self.cHeight * _self.pixelRatio,
  95. disablePieStroke: true,
  96. dataLabel: true,
  97. });
  98. },
  99. touchRing(e) {
  100. canvaRing.showToolTip(e, {
  101. format: function(item) {
  102. return item.name + ':' + item.data
  103. }
  104. });
  105. },
  106. }
  107. }
  108. </script>
  109. <style lang="scss">
  110. page{
  111. background-color: #f3f3f3;
  112. }
  113. .content{
  114. box-sizing: border-box;
  115. padding: 0 15rpx;
  116. background-color: #f3f3f3;
  117. }
  118. </style>