w-pie-charts.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <!-- 虫害饼状图-->
  3. <view>
  4. <ui-charts ref="ringChart" type="ring" :opts="opts" :chartData="chartData"></ui-charts>
  5. </view>
  6. </template>
  7. <script>
  8. /**
  9. * 虫害饼状图
  10. * @example <w-ring-charts :chartData="chartData"></w-ring-charts>
  11. * @description 统计图官方说明文档 https://www.ucharts.cn
  12. */
  13. export default {
  14. name: 'w-ring-charts',
  15. data() {
  16. return {
  17. opts: {
  18. rotate: false,
  19. rotateLock: false,
  20. color: ["#43B693", "#317AFD", "#8543E0"],
  21. padding: [5, 5, 5, 5],
  22. dataLabel: true,
  23. legend: {
  24. show: false,
  25. position: "right",
  26. lineHeight: 25
  27. },
  28. title: {
  29. name: "收益率",
  30. fontSize: 14,
  31. color: "#4E5969"
  32. },
  33. subtitle: {
  34. name: "70%",
  35. fontSize: 16,
  36. color: "#4E5969"
  37. },
  38. extra: {
  39. ring: {
  40. ringWidth: 36,
  41. activeOpacity: 0.5,
  42. activeRadius: 10,
  43. offsetAngle: 0,
  44. labelWidth: 15,
  45. border: true,
  46. borderWidth: 3,
  47. borderColor: "#FFFFFF"
  48. }
  49. }
  50. }
  51. }
  52. },
  53. props: {
  54. chartData: {
  55. type: [Array, Object],
  56. default () {
  57. return []
  58. }
  59. },
  60. // 标题
  61. title: String,
  62. // 副标题
  63. subtitle: String,
  64. color:{
  65. type:[Array],
  66. default () {
  67. return ["#43B693", "#317AFD", "#8543E0"]
  68. }
  69. }
  70. },
  71. watch: {
  72. chartData: {
  73. deep: true, // 深度监听
  74. handler(val) {
  75. this.ringChart.updataUChart();
  76. this.initData();
  77. }
  78. }
  79. },
  80. mounted() {
  81. this.initData();
  82. },
  83. methods: {
  84. // 初始化数据
  85. initData(){
  86. this.opts.title = this.title;
  87. this.opts.subtitle = this.subtitle;
  88. this.opts.color=this.color;
  89. }
  90. }
  91. };
  92. </script>
  93. <style lang="scss">
  94. </style>