mixture_chart.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <view class="charts-box">
  3. <qiun-data-charts type="mix" :opts="opts" :canvas2d='isCanvas2d' :ontouch="true" :canvasId='canvasId'
  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. chartData: {},
  18. //这里的 opts 是图表类型 type="mix" 的全部配置参数,您可以将此配置复制到 config-ucharts.js 文件中下标为 ['mix'] 的节点中来覆盖全局默认参数。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式,达到页面简洁的需求。
  19. opts: {
  20. timing: "easeOut",
  21. duration: 1000,
  22. rotate: false,
  23. rotateLock: false,
  24. color: ["#EEF2FA"],
  25. padding: [15, 15, 0, 15],
  26. fontSize: 13,
  27. fontColor: "#666666",
  28. dataLabel: false,
  29. dataPointShape: false,
  30. dataPointShapeType: "solid",
  31. touchMoveLimit: 60,
  32. enableScroll: true,
  33. enableMarkLine: false,
  34. legend: {
  35. show: false,
  36. position: "bottom",
  37. float: "center",
  38. padding: 5,
  39. margin: 5,
  40. backgroundColor: "rgba(0,0,0,0)",
  41. borderColor: "rgba(0,0,0,0)",
  42. borderWidth: 0,
  43. fontSize: 13,
  44. fontColor: "#666666",
  45. lineHeight: 11,
  46. hiddenColor: "#CECECE",
  47. itemGap: 10
  48. },
  49. xAxis: {
  50. disableGrid: true,
  51. disabled: false,
  52. axisLine: false,
  53. axisLineColor: "#CCCCCC",
  54. calibration: false,
  55. fontColor: "#666666",
  56. fontSize: 13,
  57. lineHeight: 20,
  58. marginTop: 20,
  59. rotateLabel: false,
  60. rotateAngle: 45,
  61. itemCount: 3,
  62. boundaryGap: "center",
  63. splitNumber: 5,
  64. gridColor: "#CCCCCC",
  65. gridType: "solid",
  66. dashLength: 4,
  67. gridEval: 1,
  68. scrollShow: false,
  69. scrollAlign: "left",
  70. scrollColor: "#A6A6A6",
  71. scrollBackgroundColor: "#EFEBEF",
  72. title: "",
  73. titleFontSize: 13,
  74. titleOffsetY: 0,
  75. titleOffsetX: 0,
  76. titleFontColor: "#666666",
  77. format: ""
  78. },
  79. yAxis: {
  80. disabled: false,
  81. disableGrid: true,
  82. splitNumber: 4,
  83. gridType: "dash",
  84. dashLength: 4,
  85. gridColor: "#CCCCCC",
  86. padding: 10,
  87. showTitle: false,
  88. data: [{
  89. position: "left",
  90. title: "折线",
  91. calibration: false,
  92. type: "value",
  93. axisLineColor: "#ffffff"
  94. },
  95. {
  96. position: "right",
  97. min: 0,
  98. // max: 99999,
  99. title: "柱状图",
  100. textAlign: "left",
  101. disabled: false,
  102. axisLineColor: "#FFFFFF"
  103. },
  104. {
  105. position: "right",
  106. min: 0,
  107. // max: 99999,
  108. title: "点",
  109. textAlign: "left",
  110. calibration: false,
  111. disabled: true,
  112. axisLineColor: "#FFFFFF"
  113. }
  114. ]
  115. },
  116. extra: {
  117. mix: {
  118. column: {
  119. width: 30,
  120. seriesGap: 2,
  121. barBorderCircle: false,
  122. barBorderRadius: [
  123. 5,
  124. 5,
  125. 0,
  126. 0
  127. ],
  128. linearOpacity: 0.5,
  129. colorStop: 0
  130. },
  131. area: {
  132. opacity: 0.2,
  133. gradient: false
  134. },
  135. line: {
  136. width: 2
  137. }
  138. },
  139. tooltip: {
  140. showBox: true,
  141. showArrow: true,
  142. showCategory: false,
  143. borderWidth: 0,
  144. borderRadius: 0,
  145. borderColor: "#000000",
  146. borderOpacity: 0.7,
  147. bgColor: "#000000",
  148. bgOpacity: 0.7,
  149. gridType: "solid",
  150. dashLength: 4,
  151. gridColor: "#CCCCCC",
  152. boxPadding: 3,
  153. fontSize: 13,
  154. lineHeight: 20,
  155. fontColor: "#FFFFFF",
  156. legendShow: true,
  157. legendShape: "auto",
  158. splitLine: true,
  159. horizentalLine: false,
  160. xAxisLabel: false,
  161. yAxisLabel: false,
  162. labelBgColor: "#FFFFFF",
  163. labelBgOpacity: 0.7,
  164. labelFontColor: "#666666"
  165. },
  166. markLine: {
  167. type: "solid",
  168. dashLength: 4,
  169. data: []
  170. }
  171. }
  172. }
  173. };
  174. },
  175. onReady() {
  176. // this.getServerData();
  177. },
  178. methods: {
  179. getServerData() {
  180. },
  181. setServerData(data) {
  182. setTimeout(() => {
  183. //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
  184. let res = {
  185. categories: data.titles,
  186. series: [{
  187. name: "金额(男)",
  188. index: 1,
  189. type: "column",
  190. color: "#FFD023",
  191. data: data.oneMoney
  192. },
  193. {
  194. name: "金额(女)",
  195. index: 2,
  196. type: "column",
  197. color: "#0CAF60",
  198. data: data.twoMoney
  199. },
  200. {
  201. name: "数量(男)",
  202. type: "line",
  203. style: "curve",
  204. color: "#FFD023",
  205. disableLegend: true,
  206. data: data.oneNum
  207. },
  208. {
  209. name: "数量(女)",
  210. type: "line",
  211. style: "curve",
  212. color: "#0CAF60",
  213. disableLegend: true,
  214. data: data.twoNum
  215. }
  216. ]
  217. };
  218. this.chartData = JSON.parse(JSON.stringify(res));
  219. }, 50);
  220. }
  221. }
  222. };
  223. </script>
  224. <style scoped>
  225. /* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */
  226. .charts-box {
  227. width: 100%;
  228. height: 300px;
  229. }
  230. </style>