boChart.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <!-- 血氧趋势 -->
  3. <view class="bobox" :style="boxstyle">
  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-show="!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: true,
  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: "formatterTime",
  61. },
  62. yAxis: {
  63. gridType: "dash",
  64. dashLength: 2,
  65. data: [{
  66. fontColor: '#ccc',
  67. min: 0,
  68. // max: 100,
  69. axisLine: false,
  70. fontSize: 12,
  71. }]
  72. },
  73. extra: {
  74. tooltip: {
  75. gridType: "dash",
  76. showArrow: false,
  77. legendShow: true,
  78. legendShape: "circle"
  79. },
  80. column: {
  81. type: "group",
  82. width: 12,
  83. barBorderRadius: [4, 4, 0, 0],
  84. }
  85. }
  86. }
  87. }
  88. },
  89. methods: {
  90. setChartData(data) {
  91. if (data && data.list.length > 0) {
  92. this.isEmpty = false
  93. let chartData = {
  94. categories: data.list.map(item => item.createTime),
  95. series: [{
  96. name: "血氧",
  97. data: data.list.map(item => ({
  98. value: item.minBoxy,
  99. color: item.status === 1 ? "#FDBD27" : item.status === 2 ? "#FF5558" : "#52D087"
  100. }))
  101. }]
  102. }
  103. this.chartData = JSON.parse(JSON.stringify(chartData));
  104. } else {
  105. this.isEmpty = true
  106. }
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. @mixin u-flex($flexD, $alignI, $justifyC) {
  113. display: flex;
  114. flex-direction: $flexD;
  115. align-items: $alignI;
  116. justify-content: $justifyC;
  117. }
  118. .bobox {
  119. background: #fff;
  120. }
  121. .echartbox {
  122. height: 520rpx;
  123. width: 100%;
  124. }
  125. .box-title {
  126. font-family: PingFang SC, PingFang SC;
  127. font-weight: 400;
  128. font-size: 24rpx;
  129. color: #757575;
  130. @include u-flex(row, center, space-between);
  131. &-left {
  132. font-weight: 500;
  133. font-size: 36rpx;
  134. color: #222222;
  135. line-height: 42rpx;
  136. }
  137. &-right {
  138. @include u-flex(row, center, flex-start);
  139. image {
  140. height: 48rpx;
  141. width: 48rpx;
  142. }
  143. }
  144. }
  145. .ytitle {
  146. margin-top: 10rpx;
  147. line-height: 34rpx;
  148. margin-bottom: 24rpx;
  149. font-family: PingFang SC, PingFang SC;
  150. font-weight: 400;
  151. font-size: 24rpx;
  152. color: #999999;
  153. }
  154. .legend {
  155. height: 48rpx;
  156. margin-top: 44rpx;
  157. margin-bottom: 24rpx;
  158. @include u-flex(row, center, space-between);
  159. font-family: PingFang SC, PingFang SC;
  160. font-weight: 400;
  161. font-size: 24rpx;
  162. color: #757575;
  163. &-item {
  164. flex: 1;
  165. text-align: center;
  166. @include u-flex(row, center, center);
  167. }
  168. &-dot {
  169. width: 12rpx;
  170. height: 12rpx;
  171. border-radius: 50%;
  172. margin: 12rpx;
  173. }
  174. }
  175. </style>