bpChart.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <!-- 血压趋势 -->
  3. <view class="box" :style="boxstyle">
  4. <view class="box-title">
  5. <view class="box-title-left">血压趋势</view>
  6. </view>
  7. <view class="ytitle" v-show="!loading && !isEmpty">单位:mmhg</view>
  8. <view class="echartbox">
  9. <qiun-data-charts v-show="!isEmpty" type="area" :opts="opts" :chartData="chartData" tooltipFormat="bpTooltip" />
  10. <myEmpty v-show="isEmpty" style="padding: 40rpx 0 0 0;"></myEmpty>
  11. </view>
  12. <view class="legend" v-if="!loading && !isEmpty">
  13. <view class="legend-item">
  14. <view class="legend-dot" style="background-color: #FF7700;"></view><text>收缩压90-140mmHg</text>
  15. </view>
  16. <view class="legend-item">
  17. <view class="legend-dot" style="background-color: #0065F7;"></view><text>舒张压60-90mmHg</text>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import myEmpty from "@/pages_watch/components/myEmpty/myEmpty.vue";
  24. export default {
  25. name: "bpChart",
  26. props: {
  27. loading: {
  28. type: Boolean,
  29. default: false
  30. },
  31. boxstyle: {
  32. type: Object,
  33. default: ()=>{}
  34. }
  35. },
  36. components: {
  37. myEmpty
  38. },
  39. data() {
  40. return {
  41. isEmpty: true,
  42. chartData: {},
  43. opts: {
  44. padding: [25, 0, 0, 0],
  45. enableScroll: false,
  46. dataLabel: false,
  47. dataPointShapeType: "hollow",
  48. legend: {
  49. show: false
  50. },
  51. xAxis: {
  52. disableGrid: true,
  53. fontSize: 12,
  54. axisLine: false,
  55. fontColor: '#ccc',
  56. labelCount: 7,
  57. format: "formatterTime",
  58. },
  59. yAxis: {
  60. gridType: "dash",
  61. dashLength: 2,
  62. data: [{
  63. fontColor: '#ccc',
  64. min: 0,
  65. axisLine: false,
  66. fontSize: 12,
  67. }]
  68. },
  69. extra: {
  70. tooltip: {
  71. gridType: "dash",
  72. showArrow: false,
  73. legendShow: true,
  74. legendShape: "circle"
  75. },
  76. area: {
  77. type: "straight",
  78. opacity: 0.2,
  79. addLine: true,
  80. width: 2,
  81. gradient: true,
  82. activeType: "solid"
  83. }
  84. }
  85. }
  86. }
  87. },
  88. methods: {
  89. setChartData(data) {
  90. if (data && data.length>0) {
  91. this.isEmpty = false
  92. let chartData = {
  93. categories: data.map(item => item.createTime),
  94. series: [{
  95. name: "收缩压",
  96. color: "#FF7700",
  97. data: data.map(item => item.sbp)
  98. }, {
  99. name: "舒张压",
  100. color: "#0065F7",
  101. data: data.map(item => item.dbp)
  102. }]
  103. }
  104. this.chartData = JSON.parse(JSON.stringify(chartData));
  105. } else {
  106. this.isEmpty = true
  107. }
  108. }
  109. }
  110. }
  111. </script>
  112. <style lang="scss" scoped>
  113. @mixin u-flex($flexD, $alignI, $justifyC) {
  114. display: flex;
  115. flex-direction: $flexD;
  116. align-items: $alignI;
  117. justify-content: $justifyC;
  118. }
  119. .box {
  120. padding: 24rpx;
  121. margin-bottom: 20rpx;
  122. box-sizing: border-box;
  123. background: #FFFFFF;
  124. border-radius: 16rpx 16rpx 16rpx 16rpx;
  125. &-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. .echartbox {
  155. height: 466rpx;
  156. width: 100%;
  157. }
  158. .legend {
  159. height: 34rpx;
  160. margin-top: 44rpx;
  161. @include u-flex(row, center, space-between);
  162. font-family: PingFang SC, PingFang SC;
  163. font-weight: 400;
  164. font-size: 24rpx;
  165. color: #757575;
  166. &-item {
  167. flex: 1;
  168. text-align: center;
  169. @include u-flex(row, center, center);
  170. }
  171. &-dot {
  172. width: 16rpx;
  173. height: 16rpx;
  174. border-radius: 50%;
  175. margin: 16rpx;
  176. }
  177. }
  178. }
  179. </style>