boChart.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <!-- 血氧趋势 -->
  3. <view class="bobox" :style="boxstyle" v-if="!isEmpty">
  4. <view class="box-title">
  5. <view class="box-title-left">血氧趋势</view>
  6. </view>
  7. <view class="ytitle" v-show="!loading && !isEmpty">百分比</view>
  8. <view class="echartbox">
  9. <qiun-data-charts v-if="!isEmpty" type="column" :opts="opts" :chartData="chartData"
  10. tooltipFormat="spTooltip" />
  11. <myEmpty v-show="isEmpty" style="padding: 40rpx 0 0 0;"></myEmpty>
  12. </view>
  13. <view class="legend" v-if="!loading && !isEmpty">
  14. <view class="legend-item">
  15. <view class="legend-dot" style="background-color: #FF5558;"></view><text>{{'<'}}70%</text>
  16. </view>
  17. <view class="legend-item">
  18. <view class="legend-dot" style="background-color: #FDBD27;"></view><text>70 - 89%</text>
  19. </view>
  20. <view class="legend-item">
  21. <view class="legend-dot" style="background-color: #52D087;"></view><text>90 - 100%</text>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import myEmpty from "@/pages_watch/components/myEmpty/myEmpty.vue";
  28. export default {
  29. name: "boChart",
  30. props: {
  31. loading: {
  32. type: Boolean,
  33. default: false
  34. },
  35. boxstyle: {
  36. type: Object,
  37. default: () => {}
  38. }
  39. },
  40. components: {
  41. myEmpty
  42. },
  43. data() {
  44. return {
  45. isEmpty: false,
  46. chartData: {},
  47. opts: {
  48. padding: [15, 0, 15, 0],
  49. enableScroll: false,
  50. dataLabel: false,
  51. legend: {
  52. show: false
  53. },
  54. xAxis: {
  55. disableGrid: true,
  56. fontSize: 12,
  57. axisLine: false,
  58. fontColor: '#ccc',
  59. labelCount: 7,
  60. format: "formatterDate",
  61. },
  62. yAxis: {
  63. gridType: "dash",
  64. dashLength: 2,
  65. data: [{
  66. fontColor: '#ccc',
  67. // min: 95,
  68. max: 100,
  69. axisLine: false,
  70. fontSize: 12,
  71. tofix: 0
  72. }]
  73. },
  74. extra: {
  75. tooltip: {
  76. gridType: "dash",
  77. showArrow: false,
  78. legendShow: true,
  79. legendShape: "circle"
  80. },
  81. column: {
  82. type: "group",
  83. width: 12,
  84. barBorderRadius: [4, 4, 0, 0]
  85. }
  86. }
  87. }
  88. }
  89. },
  90. methods: {
  91. setChartData(data) {
  92. if (data && data.list.length > 0) {
  93. // this.opts.yAxis.data[0].min = Math.min(...data.list.map(item => item.minBoxy)) - 1;
  94. this.isEmpty = false
  95. let chartData = {
  96. categories: data.list.map(item => item.createTime),
  97. series: [{
  98. name: "血氧",
  99. data: data.list.map(item => ({
  100. value: item.minBoxy,
  101. color: item.status === 1 ? "#FDBD27" : item.status === 2 ? "#FF5558" : "#52D087"
  102. }))
  103. }]
  104. }
  105. this.chartData = JSON.parse(JSON.stringify(chartData));
  106. } else {
  107. this.isEmpty = true
  108. }
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. @mixin u-flex($flexD, $alignI, $justifyC) {
  115. display: flex;
  116. flex-direction: $flexD;
  117. align-items: $alignI;
  118. justify-content: $justifyC;
  119. }
  120. .bobox {
  121. background: #fff;
  122. }
  123. .echartbox {
  124. height: 520rpx;
  125. width: 100%;
  126. }
  127. .box-title {
  128. font-family: PingFang SC, PingFang SC;
  129. font-weight: 400;
  130. font-size: 24rpx;
  131. color: #757575;
  132. @include u-flex(row, center, space-between);
  133. &-left {
  134. font-weight: 500;
  135. font-size: 36rpx;
  136. color: #222222;
  137. line-height: 42rpx;
  138. }
  139. &-right {
  140. @include u-flex(row, center, flex-start);
  141. image {
  142. height: 48rpx;
  143. width: 48rpx;
  144. }
  145. }
  146. }
  147. .ytitle {
  148. margin-top: 10rpx;
  149. line-height: 34rpx;
  150. margin-bottom: 24rpx;
  151. font-family: PingFang SC, PingFang SC;
  152. font-weight: 400;
  153. font-size: 24rpx;
  154. color: #999999;
  155. }
  156. .legend {
  157. height: 48rpx;
  158. margin-top: 44rpx;
  159. margin-bottom: 24rpx;
  160. @include u-flex(row, center, space-between);
  161. font-family: PingFang SC, PingFang SC;
  162. font-weight: 400;
  163. font-size: 24rpx;
  164. color: #757575;
  165. &-item {
  166. flex: 1;
  167. text-align: center;
  168. @include u-flex(row, center, center);
  169. }
  170. &-dot {
  171. width: 12rpx;
  172. height: 12rpx;
  173. border-radius: 50%;
  174. margin: 12rpx;
  175. }
  176. }
  177. </style>