circle_chart.vue 2.5 KB

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