peak_chart.vue 4.7 KB

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