bsChart.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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">单位:mmol/L</view>
  8. <view class="echartbox">
  9. <qiun-data-charts v-show="!isEmpty" type="area" :opts="opts" :chartData="chartData"
  10. tooltipFormat="bsTooltip" />
  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: "bsChart",
  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: [20, 0, 15, 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. // 横坐标最多展示几个
  51. labelCount: 7,
  52. // 自定义横坐标展示(在/u-charts/config-ucharts中有配置)
  53. format: "formatterTime",
  54. },
  55. yAxis: {
  56. gridType: "dash",
  57. dashLength: 2,
  58. // splitNumber: 6,
  59. data: [{
  60. fontColor: '#ccc',
  61. min: 0,
  62. // max: 33,
  63. axisLine: false,
  64. fontSize: 12,
  65. }]
  66. },
  67. extra: {
  68. tooltip: {
  69. gridType: "dash",
  70. showArrow: false,
  71. legendShow: true,
  72. legendShape: "circle"
  73. },
  74. area: {
  75. type: "straight",
  76. opacity: 0.2,
  77. addLine: true,
  78. width: 2,
  79. gradient: true,
  80. activeType: "solid"
  81. }
  82. }
  83. }
  84. }
  85. },
  86. methods: {
  87. setChartData(data) {
  88. if (data && data.length > 0) {
  89. this.isEmpty = false
  90. let chartData = {
  91. categories: data.map(item => item.createTime),
  92. series: [{
  93. name: "血糖",
  94. data: data.map(item => item.bloodGlucose)
  95. }]
  96. }
  97. this.chartData = JSON.parse(JSON.stringify(chartData));
  98. } else {
  99. this.isEmpty = true
  100. }
  101. }
  102. }
  103. }
  104. </script>
  105. <style lang="scss" scoped>
  106. @mixin u-flex($flexD, $alignI, $justifyC) {
  107. display: flex;
  108. flex-direction: $flexD;
  109. align-items: $alignI;
  110. justify-content: $justifyC;
  111. }
  112. .box-title {
  113. font-family: PingFang SC, PingFang SC;
  114. font-weight: 400;
  115. font-size: 24rpx;
  116. color: #757575;
  117. @include u-flex(row, center, space-between);
  118. &-left {
  119. font-weight: 500;
  120. font-size: 36rpx;
  121. color: #222222;
  122. line-height: 42rpx;
  123. }
  124. &-right {
  125. @include u-flex(row, center, flex-start);
  126. image {
  127. height: 48rpx;
  128. width: 48rpx;
  129. }
  130. }
  131. }
  132. .box {
  133. padding: 24rpx;
  134. margin-bottom: 20rpx;
  135. box-sizing: border-box;
  136. background: #FFFFFF;
  137. border-radius: 16rpx 16rpx 16rpx 16rpx;
  138. }
  139. .ytitle {
  140. margin-top: 10rpx;
  141. line-height: 34rpx;
  142. margin-bottom: 24rpx;
  143. font-family: PingFang SC, PingFang SC;
  144. font-weight: 400;
  145. font-size: 24rpx;
  146. color: #999999;
  147. }
  148. .echartbox {
  149. height: 466rpx;
  150. width: 100%;
  151. }
  152. </style>