You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
2.9 KiB

2 weeks ago
  1. <template>
  2. <view class="charts-box">
  3. <qiun-data-charts type="line" :opts="opts" :chartData="chartData" />
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. // props: ['chartData'],
  9. data() {
  10. return {
  11. chartData: {},
  12. //这里的 opts 是图表类型 type="column" 的全部配置参数,您可以将此配置复制到 config-ucharts.js 文件中下标为 ['column'] 的节点中来覆盖全局默认参数。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式,达到页面简洁的需求。
  13. opts: {
  14. "type": "gauge",
  15. "canvasId": "",
  16. "canvas2d": false,
  17. "background": "none",
  18. "animation": true,
  19. "timing": "easeOut",
  20. "duration": 1000,
  21. "color": [
  22. "#1890FF",
  23. "#91CB74",
  24. "#FAC858",
  25. "#EE6666",
  26. "#73C0DE",
  27. "#3CA272",
  28. "#FC8452",
  29. "#9A60B4",
  30. "#ea7ccc"
  31. ],
  32. "rotate": false,
  33. "errorReload": true,
  34. "fontSize": 10, //刻度字体大小
  35. "fontColor": "#666666",
  36. "enableScroll": false,
  37. "touchMoveLimit": 60,
  38. "enableMarkLine": false,
  39. "dataLabel": true,
  40. "dataPointShape": true,
  41. "dataPointShapeType": "solid",
  42. "tapLegend": true,
  43. "title": {
  44. "name": "40%",
  45. "fontSize": 40,
  46. "color": "rgba(0, 0, 0, 0.8)",
  47. "offsetX": 0,
  48. "offsetY": 0
  49. },
  50. "subtitle": {
  51. "name": "通过率",
  52. "fontSize": 14,
  53. "color": "#333",
  54. "offsetX": 0,
  55. "offsetY": 8, //调整纵向距离
  56. },
  57. "extra": {
  58. "gauge": {
  59. "type": "default",
  60. "width": 10, //环形宽度
  61. "labelColor": "#91B1EC",
  62. "labelOffset": 8, //label标注与环形的距离
  63. "startAngle": 0.75,
  64. "endAngle": 0.25,
  65. "startNumber": 0,
  66. "endNumber": 100,
  67. "format": "",
  68. "splitLine": {
  69. "fixRadius": 0,
  70. "splitNumber": 4, //分割段数
  71. "width": 30,
  72. "color": "transparent", //去掉分割线
  73. "childNumber": 5,
  74. "childWidth": 12
  75. },
  76. "pointer": {
  77. "width": 0,
  78. "color": "rgba(134, 153, 187, 1)"
  79. },
  80. "labelFormat": ""
  81. }
  82. }
  83. }
  84. };
  85. },
  86. mounted() {
  87. this.getServerData();
  88. },
  89. methods: {
  90. getServerData() {
  91. //模拟从服务器获取数据时的延时
  92. setTimeout(() => {
  93. //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
  94. this.chartData = {
  95. categories: [{
  96. "value": 0.2,
  97. "color": "#3776FF"
  98. },
  99. {
  100. "value": 1,
  101. "color": "#D7E4FF"
  102. }
  103. ],
  104. series: [{
  105. "name": "测试通过率",
  106. "data": '80%'
  107. }]
  108. }
  109. }, 500);
  110. },
  111. }
  112. };
  113. </script>
  114. <style scoped>
  115. /* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */
  116. .charts-box {
  117. width: 370rpx;
  118. height: 368rpx;
  119. }
  120. </style>