w-pie-charts.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <!-- 虫害饼状图-->
  3. <view>
  4. <ui-charts ref="ringChart" :loadingType="0" 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: [10, 10, 10, 10],
  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.initData();
  76. }
  77. }
  78. },
  79. mounted() {
  80. this.initData();
  81. },
  82. methods: {
  83. // 初始化数据
  84. initData(){
  85. this.opts.title = this.title;
  86. this.opts.subtitle = this.subtitle;
  87. this.opts.color=this.color;
  88. }
  89. }
  90. };
  91. </script>
  92. <style lang="scss">
  93. </style>