peak_chart.vue 4.8 KB

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