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.

174 lines
4.8 KiB

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