circle_chart.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <view class="charts-box" :style="[{width},{height},]">
  3. <qiun-data-charts
  4. :canvas2d='true'
  5. :canvasId='canvasId'
  6. type="arcbar"
  7. :opts="opts"
  8. :chartData="chartData"
  9. />
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. props:{
  15. width: {
  16. type: String,
  17. default: '140rpx'
  18. },
  19. height: {
  20. type: String,
  21. default: '140rpx'
  22. },
  23. canvasId: {
  24. type: String,
  25. default: ''
  26. },
  27. bgColor: {
  28. type: String,
  29. default: ''
  30. },
  31. },
  32. data() {
  33. return {
  34. chartData: {},
  35. //这里的 opts 是图表类型 type="arcbar" 的全部配置参数,您可以将此配置复制到 config-ucharts.js 文件中下标为 ['arcbar'] 的节点中来覆盖全局默认参数。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式,达到页面简洁的需求。
  36. opts: {
  37. timing: "easeOut",
  38. duration: 1000,
  39. rotate: false,
  40. rotateLock: false,
  41. color: ["#1890FF","#91CB74","#FAC858","#EE6666","#73C0DE","#3CA272","#FC8452","#9A60B4","#ea7ccc"],
  42. padding: undefined,
  43. fontSize: 13,
  44. fontColor: "#666666",
  45. dataLabel: true,
  46. dataPointShape: true,
  47. dataPointShapeType: "solid",
  48. touchMoveLimit: 60,
  49. enableScroll: false,
  50. enableMarkLine: false,
  51. title: {
  52. name: "",
  53. fontSize: 25,
  54. color: "#00FF00",
  55. offsetX: 0,
  56. offsetY: 0
  57. },
  58. subtitle: {
  59. name: "60%",
  60. fontSize: 15,
  61. color: "#666666",
  62. offsetX: 0,
  63. offsetY: 0
  64. },
  65. extra: {
  66. arcbar: {
  67. type: "circle",
  68. width: 10,
  69. backgroundColor: "#E9E9E9",
  70. startAngle: 0.5,
  71. endAngle: 0.25,
  72. gap: 2,
  73. direction: "cw",
  74. lineCap: "round",
  75. centerX: 0,
  76. centerY: 0,
  77. linearType: "none"
  78. }
  79. }
  80. }
  81. };
  82. },
  83. onReady() {
  84. this.getServerData();
  85. },
  86. methods: {
  87. getServerData() {
  88. //模拟从服务器获取数据时的延时
  89. setTimeout(() => {
  90. //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
  91. let res = {
  92. series: [
  93. {
  94. name: "正确率",
  95. color: this.bgColor,
  96. data: 0.8
  97. }
  98. ]
  99. };
  100. this.chartData = JSON.parse(JSON.stringify(res));
  101. }, 500);
  102. },
  103. }
  104. };
  105. </script>
  106. <style scoped>
  107. </style>