weightLine.vue 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view class="chartwarp">
  3. <qiun-title-bar title="基本曲线图(自定义图表类型)" />
  4. <view class="charts-box">
  5. <!-- 这里的type="demotype"演示了自定义图表类型的demo,您可以根据需求自己定义一种额外的图表类型 -->
  6. <!-- <qiun-data-charts type="demotype" :opts="{xAxis:{boundaryGap:'justify'}}" :chartData="chartsDataLine2" /> -->
  7. <!-- 如果不定义"demotype"这个图表类型,可以通过传递opts来覆盖line下的默认配置,如下 -->
  8. <qiun-data-charts
  9. type="line"
  10. :opts="opts"
  11. :chartData="chartData"
  12. />
  13. <!-- <qiun-data-charts type="line" :opts="{extra:{line:{type:'curve'}}}" :chartData="chartsData.Line2"/> -->
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. //下面是演示数据,您的项目不需要引用,数据需要您从服务器自行获取
  19. import demodata from '@/mockdata/demodata.json';
  20. import mapdata from '@/mockdata/mapdata.json';
  21. export default {
  22. props: {
  23. record: Array
  24. },
  25. data() {
  26. return {
  27. chartData:{},
  28. chartsDataLine2: {},
  29. searchVal: '',
  30. tableData: [],
  31. // 每页数据量
  32. pageSize: 10,
  33. // 当前页
  34. pageCurrent: 1,
  35. // 数据总量
  36. total: 0,
  37. loading: false,
  38. opts: {
  39. color: ["#1890FF","#91CB74","#FAC858","#EE6666","#73C0DE","#3CA272","#FC8452","#9A60B4","#ea7ccc"],
  40. padding: [15,10,0,15],
  41. enableScroll: false,
  42. legend: {},
  43. xAxis: {
  44. disableGrid: true
  45. },
  46. yAxis: {
  47. disabled:false,
  48. gridType: "dash",
  49. dashLength: 10,
  50. gridColor:'#ff0000',
  51. data:[{
  52. min:40,
  53. max:100,
  54. }]
  55. },
  56. extra: {
  57. line: {
  58. type: "curve",
  59. width: 2,
  60. activeType: "hollow"
  61. }
  62. }
  63. }
  64. }
  65. },
  66. onReady() {
  67. //模拟从服务器获取数据
  68. this.getServerData()
  69. // console.log('mmmmmm',this.record);
  70. },
  71. methods: {
  72. getServerData (){
  73. var x_xAis = []
  74. var dry_weight=[]
  75. var weight_after = []
  76. var weight_before = []
  77. for(let i=0;i<this.record.length;i++){
  78. x_xAis.push(this.record[i].assessment_date)
  79. dry_weight.push(this.record[i].dry_weight)
  80. weight_after.push(this.record[i].weight_after)
  81. weight_before.push(this.record[i].weight_before)
  82. }
  83. // console.log('vvvvv',x_xAis);
  84. setTimeout (()=>{
  85. let res = {
  86. // categories: ["2018","2019","2020","2021","2022","2023"],
  87. categories: x_xAis,
  88. series: [
  89. {
  90. name: "干体重",
  91. // lineType: "dash",
  92. // data: [35,8,25,37,4,20],
  93. data:dry_weight,
  94. },
  95. {
  96. name: "透后体重",
  97. // data: [70,40,65,100,44,68],
  98. data: weight_after,
  99. },
  100. {
  101. name: "透前体重",
  102. // data: [70,40,65,0,44,68],
  103. data: weight_before
  104. }
  105. ]
  106. };
  107. this.chartData = JSON.parse(JSON.stringify(res));
  108. },1500)
  109. }
  110. }
  111. }
  112. </script>
  113. <style>
  114. page {
  115. height: 100%;
  116. background-color: #f3f3f9;
  117. }
  118. .chartwarp {
  119. margin-top: 30rpx;
  120. }
  121. .uni-group {
  122. display: flex;
  123. align-items: center;
  124. }
  125. .content {
  126. display: flex;
  127. flex-direction: column;
  128. flex: 1;
  129. }
  130. .charts-box {
  131. width: 100%;
  132. height: 300px;
  133. }
  134. </style>