mixture_chart.vue 5.3 KB

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