peak_chart.vue 5.2 KB

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