You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

175 lines
4.8 KiB

1 week ago
  1. <template>
  2. <view class="charts-box">
  3. <qiun-data-charts
  4. type="line"
  5. :opts="opts"
  6. :chartData="chartData"
  7. :ontouch="true"
  8. />
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. props: ['chartData'],
  14. data() {
  15. return {
  16. // chartData: {},
  17. //这里的 opts 是图表类型 type="column" 的全部配置参数,您可以将此配置复制到 config-ucharts.js 文件中下标为 ['column'] 的节点中来覆盖全局默认参数。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式,达到页面简洁的需求。
  18. opts: {
  19. timing: "easeOut",
  20. duration: 1000,
  21. rotate: false,
  22. rotateLock: false,
  23. color: ["#1890FF","#91CB74","#FAC858","#EE6666","#73C0DE","#3CA272","#FC8452","#9A60B4","#ea7ccc"],
  24. padding: [15,15,0,5],
  25. fontSize: 13,
  26. fontColor: "#1989FA",
  27. dataLabel: true,
  28. dataPointShape: true,
  29. dataPointShapeType: "solid",
  30. touchMoveLimit: 60,
  31. enableScroll: true,
  32. enableMarkLine: false,
  33. legend: {
  34. show: false,
  35. position: "bottom",
  36. float: "center",
  37. padding: 5,
  38. margin: 5,
  39. backgroundColor: "rgba(0,0,0,0)",
  40. borderColor: "rgba(0,0,0,0)",
  41. borderWidth: 0,
  42. fontSize: 13,
  43. fontColor: "#666666",
  44. lineHeight: 11,
  45. hiddenColor: "#CECECE",
  46. itemGap: 10
  47. },
  48. xAxis: {
  49. disableGrid: true,
  50. disabled: false,
  51. axisLine: true,
  52. axisLineColor: "#E8E9EC",
  53. calibration: false,
  54. fontColor: "#686B73",
  55. fontSize: 12,
  56. lineHeight: 20,
  57. marginTop: 0,
  58. rotateLabel: false,
  59. rotateAngle: 45,
  60. itemCount: 6,
  61. boundaryGap: "center",
  62. splitNumber: 5,
  63. gridColor: "#CCCCCC",
  64. gridType: "solid",
  65. dashLength: 4,
  66. gridEval: 1,
  67. scrollShow: true,
  68. scrollAlign: "left",
  69. scrollColor: "#A6A6A6",
  70. scrollBackgroundColor: "#EFEBEF",
  71. title: "",
  72. titleFontSize: 13,
  73. titleOffsetY: 0,
  74. titleOffsetX: 0,
  75. titleFontColor: "#666666",
  76. format: ""
  77. },
  78. yAxis: {
  79. data: [
  80. {
  81. min: 0
  82. }
  83. ],
  84. disabled: true,
  85. disableGrid: false,
  86. splitNumber: 5,
  87. gridType: "dash",
  88. dashLength: 8,
  89. gridColor: "#E8E9EC",
  90. padding: 10,
  91. showTitle: false
  92. },
  93. extra: {
  94. column: {
  95. type: "group",
  96. width: 9,
  97. activeBgColor: "#000000",
  98. activeBgOpacity: 0.08,
  99. seriesGap: 2,
  100. categoryGap: 3,
  101. barBorderCircle: false,
  102. linearType: "none",
  103. linearOpacity: 1,
  104. colorStop: 0,
  105. meterBorder: 1,
  106. meterFillColor: "#FFFFFF",
  107. labelPosition: "outside"
  108. },
  109. tooltip: {
  110. showBox: false,
  111. showArrow: true,
  112. showCategory: false,
  113. borderWidth: 0,
  114. borderRadius: 0,
  115. borderColor: "#000000",
  116. borderOpacity: 0.7,
  117. bgColor: "#000000",
  118. bgOpacity: 0.7,
  119. gridType: "solid",
  120. dashLength: 4,
  121. gridColor: "#CCCCCC",
  122. boxPadding: 3,
  123. fontSize: 12,
  124. lineHeight: 20,
  125. fontColor: "#FFFFFF",
  126. legendShow: true,
  127. legendShape: "auto",
  128. splitLine: true,
  129. horizentalLine: false,
  130. xAxisLabel: false,
  131. yAxisLabel: false,
  132. labelBgColor: "#FFFFFF",
  133. labelBgOpacity: 0.7,
  134. labelFontColor: "#666666"
  135. },
  136. markLine: {
  137. type: "solid",
  138. dashLength: 4,
  139. data: []
  140. }
  141. }
  142. }
  143. };
  144. },
  145. mounted() {
  146. // this.getServerData();
  147. },
  148. methods: {
  149. getServerData() {
  150. //模拟从服务器获取数据时的延时
  151. setTimeout(() => {
  152. //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
  153. let res = {
  154. categories: ["08/01","08/02","08/03","08/04","08/05","08/06"],
  155. series: [
  156. {
  157. name: "目标值",
  158. data: [35,16,31,33,35,36,]
  159. }
  160. ]
  161. };
  162. this.chartData = JSON.parse(JSON.stringify(res));
  163. }, 500);
  164. },
  165. }
  166. };
  167. </script>
  168. <style scoped>
  169. /* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */
  170. .charts-box {
  171. width: 100%;
  172. height: 100%;
  173. }
  174. </style>