PieCharts.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view class="charts-box" style="min-height: 580rpx;">
  3. <qiun-data-charts type="ring" :opts="optsPie" :chartData="chartDataPie" />
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {
  10. chartDataPie: {},
  11. optsPie: {
  12. rotate: false,
  13. rotateLock: false,
  14. color: ['#1372FF', '#F89F2A', '#02C493'],
  15. padding: [30, 30, 30, 35],
  16. dataLabel: true,
  17. enableScroll: false,
  18. legend: {
  19. show: true,
  20. position: "bottom",
  21. lineHeight: 25
  22. },
  23. title: {
  24. name: "",
  25. fontSize: 15,
  26. color: "#666666"
  27. },
  28. subtitle: {
  29. name: "",
  30. fontSize: 25,
  31. color: "#7cb5ec"
  32. },
  33. extra: {
  34. ring: {
  35. ringWidth: 25,
  36. activeOpacity: 0.5,
  37. activeRadius: 10,
  38. offsetAngle: 0,
  39. labelWidth: 10,
  40. border: false,
  41. borderWidth: 3,
  42. borderColor: "#FFFFFF"
  43. }
  44. },
  45. },
  46. fromData: {
  47. dateDay: '2024-01',
  48. homestayId: '1744620500506251265'
  49. },
  50. list: {}
  51. };
  52. },
  53. onReady() {
  54. this.getServerData();
  55. },
  56. methods: {
  57. getServerData() {
  58. let obj = wx.getStorageSync('fromData')
  59. this.list = obj
  60. this.list = {
  61. series: [{
  62. data: [{
  63. "name": "房费",
  64. "value": this.list.roomAmount,
  65. "labelText": "房费" + this.list.roomRatio + '%'
  66. },
  67. {
  68. "name": "商品",
  69. "value": this.list.othersAmount,
  70. "labelText": "商品" + this.list.othersRatio + '%'
  71. },
  72. {
  73. "name": "其他",
  74. "value": this.list.breakfastAmount,
  75. "labelText": "其他" + this.list.breakfastRatio + '%',
  76. },
  77. ],
  78. }],
  79. }
  80. this.chartDataPie = JSON.parse(JSON.stringify(this.list));
  81. },
  82. }
  83. };
  84. </script>
  85. <style scoped>
  86. /* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */
  87. .charts-box {
  88. width: 600rpx !important;
  89. height: 560rpx !important;
  90. }
  91. </style>