heartChart.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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="area" :opts="opts" :chartData="chartData"
  10. tooltipFormat="heartTooltip" />
  11. <myEmpty v-show="isEmpty" style="padding: 40rpx 0 0 0;"></myEmpty>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import myEmpty from "@/pages_watch/components/myEmpty/myEmpty.vue";
  17. export default {
  18. name: "heartChart",
  19. props: {
  20. loading: {
  21. type: Boolean,
  22. default: false
  23. },
  24. boxstyle: {
  25. type: Object,
  26. default: () => {}
  27. }
  28. },
  29. components: {
  30. myEmpty
  31. },
  32. data() {
  33. return {
  34. isEmpty: true,
  35. chartData: {},
  36. opts: {
  37. color: ["#FF7700"],
  38. padding: [25, 0, 10, 0],
  39. enableScroll: false,
  40. dataLabel: false,
  41. dataPointShapeType: "hollow",
  42. legend: {
  43. show: false,
  44. },
  45. xAxis: {
  46. disableGrid: true,
  47. fontSize: 12,
  48. axisLine: false,
  49. fontColor: '#ccc',
  50. labelCount: 7,
  51. format: "formatterTime",
  52. },
  53. yAxis: {
  54. gridType: "dash",
  55. dashLength: 2,
  56. data: [{
  57. fontColor: '#ccc',
  58. min: 0,
  59. axisLine: false,
  60. fontSize: 12,
  61. }]
  62. },
  63. extra: {
  64. tooltip: {
  65. gridType: "dash",
  66. showArrow: false,
  67. legendShow: true,
  68. legendShape: "circle"
  69. },
  70. area: {
  71. type: "straight",
  72. opacity: 0.2,
  73. addLine: true,
  74. width: 2,
  75. gradient: true,
  76. activeType: "solid"
  77. }
  78. }
  79. }
  80. }
  81. },
  82. methods: {
  83. setChartData(data) {
  84. if (data && data.list.length > 0) {
  85. this.isEmpty = false
  86. let chartData = {
  87. categories: data.list.map(item => item.createTime),
  88. series: [{
  89. name: "心率",
  90. data: data.list.map(item => item.avgBpm)
  91. }]
  92. }
  93. this.chartData = JSON.parse(JSON.stringify(chartData));
  94. } else {
  95. this.isEmpty = true
  96. }
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="scss" scoped>
  102. @mixin u-flex($flexD, $alignI, $justifyC) {
  103. display: flex;
  104. flex-direction: $flexD;
  105. align-items: $alignI;
  106. justify-content: $justifyC;
  107. }
  108. .bobox {
  109. background: #FFFFFF;
  110. }
  111. .box-title {
  112. font-family: PingFang SC, PingFang SC;
  113. font-weight: 400;
  114. font-size: 24rpx;
  115. color: #757575;
  116. @include u-flex(row, center, space-between);
  117. &-left {
  118. font-weight: 500;
  119. font-size: 36rpx;
  120. color: #222222;
  121. line-height: 42rpx;
  122. }
  123. &-right {
  124. @include u-flex(row, center, flex-start);
  125. image {
  126. height: 48rpx;
  127. width: 48rpx;
  128. }
  129. }
  130. }
  131. .ytitle {
  132. margin-top: 10rpx;
  133. line-height: 34rpx;
  134. margin-bottom: 24rpx;
  135. font-family: PingFang SC, PingFang SC;
  136. font-weight: 400;
  137. font-size: 24rpx;
  138. color: #999999;
  139. }
  140. .echartbox {
  141. height: 506rpx;
  142. width: 100%;
  143. }
  144. </style>