洛阳学员端
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.

134 lines
3.7 KiB

10 months ago
  1. <template>
  2. <view class="charts-box">
  3. <qiun-data-charts
  4. type="ring"
  5. :opts="opts"
  6. :chartData="chartData"
  7. :onmouse="false"
  8. />
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. data() {
  14. return {
  15. chartData: {},
  16. //这里的 opts 是图表类型 type="ring" 的全部配置参数,您可以将此配置复制到 config-ucharts.js 文件中下标为 ['ring'] 的节点中来覆盖全局默认参数。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式,达到页面简洁的需求。
  17. opts: {
  18. timing: "easeOut",
  19. duration: 1000,
  20. rotate: false,
  21. rotateLock: false,
  22. color: ["#F2D39B","#9BF2D6","#9BB5F2","#AAD993","#73C0DE","#3CA272","#FC8452","#9A60B4","#ea7ccc"],
  23. padding: [5,5,5,5],
  24. fontSize: 13,
  25. fontColor: "#666666",
  26. dataLabel: false,
  27. dataPointShape: true,
  28. dataPointShapeType: "solid",
  29. touchMoveLimit: 60,
  30. enableScroll: false,
  31. enableMarkLine: false,
  32. legend: {
  33. show: true,
  34. position: "right",
  35. lineHeight: 25,
  36. float: "center",
  37. padding: 5,
  38. margin: 5,
  39. backgroundColor: "rgba(0,0,0,0)",
  40. borderColor: "rgba(0,0,0,0)",
  41. borderWidth: 0,
  42. fontSize: 13,
  43. fontColor: "#666666",
  44. hiddenColor: "#CECECE",
  45. itemGap: 10
  46. },
  47. title: {
  48. name: "",
  49. fontSize: 15,
  50. color: "#666666",
  51. offsetX: 0,
  52. offsetY: 0
  53. },
  54. subtitle: {
  55. name: "",
  56. fontSize: 25,
  57. color: "#7cb5ec",
  58. offsetX: 0,
  59. offsetY: 0
  60. },
  61. extra: {
  62. ring: {
  63. ringWidth: 15,
  64. activeOpacity: 0.5,
  65. activeRadius: 10,
  66. offsetAngle: 0,
  67. labelWidth: 15,
  68. border: false,
  69. borderWidth: 3,
  70. borderColor: "#FFFFFF",
  71. centerColor: "#FFFFFF",
  72. customRadius: 0,
  73. linearType: "none"
  74. },
  75. tooltip: {
  76. showBox: true,
  77. showArrow: true,
  78. showCategory: false,
  79. borderWidth: 0,
  80. borderRadius: 0,
  81. borderColor: "#000000",
  82. borderOpacity: 0.7,
  83. bgColor: "#000000",
  84. bgOpacity: 0.7,
  85. gridType: "solid",
  86. dashLength: 4,
  87. gridColor: "#CCCCCC",
  88. boxPadding: 3,
  89. fontSize: 13,
  90. lineHeight: 20,
  91. fontColor: "#FFFFFF",
  92. legendShow: true,
  93. legendShape: "auto",
  94. splitLine: true,
  95. horizentalLine: false,
  96. xAxisLabel: false,
  97. yAxisLabel: false,
  98. labelBgColor: "#FFFFFF",
  99. labelBgOpacity: 0.7,
  100. labelFontColor: "#666666"
  101. }
  102. }
  103. }
  104. };
  105. },
  106. mounted() {
  107. this.getServerData();
  108. },
  109. methods: {
  110. getServerData() {
  111. //模拟从服务器获取数据时的延时
  112. setTimeout(() => {
  113. //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
  114. let res = {
  115. series: [
  116. {
  117. data: [{"name":"科目一","value":50},{"name":"模拟器","value":30},{"name":"科目二","value":20},{"name":"科目三","value":18}]
  118. }
  119. ]
  120. };
  121. this.chartData = JSON.parse(JSON.stringify(res));
  122. }, 500);
  123. },
  124. }
  125. };
  126. </script>
  127. <style scoped>
  128. /* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */
  129. .charts-box {
  130. width: 100%;
  131. height: 100%;
  132. }
  133. </style>