layout02UserWidgetM.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <ul>
  3. <li
  4. v-for="(item, index) in props.items"
  5. :key="`user-widget-${index}`"
  6. :class="item.level"
  7. >
  8. <div class="headers">
  9. <div class="title">
  10. {{ item.tenantName }}
  11. </div>
  12. </div>
  13. <div class="chart--box">
  14. <Doughnut
  15. :data="item.chartData"
  16. :options="chartOptions"
  17. />
  18. <div class="current--value">
  19. {{ toRoundFix(item.curSubscriber, 0) }} / {{ item.maxSubscriber }}
  20. </div>
  21. </div>
  22. <div class="current--value--ps">
  23. {{ item.perSubscriber }}<i class="unit">%</i>
  24. </div>
  25. </li>
  26. </ul>
  27. </template>
  28. <script setup>
  29. /***********************
  30. * import
  31. ************************/
  32. import { useI18n } from "vue-i18n"
  33. import apiUrl from '@/composables/useApi';
  34. import useAxios from '@/composables/useAxios';
  35. import useUtil from '@/composables/useUtil';
  36. import { Doughnut } from 'vue-chartjs';
  37. import { Chart as ChartJS, Title, Tooltip, Legend, BarElement, LineController, LineElement, PointElement, ArcElement, CategoryScale, LinearScale } from 'chart.js';
  38. /***********************
  39. * plugins inject
  40. ************************/
  41. const { $toast, $log, $dayjs, $eventBus } = useNuxtApp()
  42. // props
  43. const props = defineProps({
  44. items: {
  45. type: Array,
  46. default: () => []
  47. },
  48. })
  49. // 참조가능 데이터 설정
  50. defineExpose({})
  51. // 발신 이벤트 선언
  52. const emit = defineEmits([]);
  53. const i18n = useI18n();
  54. ChartJS.register(Title,
  55. Tooltip,
  56. Legend,
  57. BarElement,
  58. LineController,
  59. LineElement,
  60. PointElement,
  61. CategoryScale,
  62. ArcElement,
  63. LinearScale)
  64. /***********************
  65. * data & created
  66. ************************/
  67. const chartOptions = {
  68. responsive: true,
  69. maintainAspectRatio: false,
  70. cutout:"75%",
  71. rotation: 270,
  72. circumference: 180,
  73. plugins: {
  74. legend: {
  75. position:'top',
  76. display: false
  77. },
  78. tooltip: {
  79. enabled:false
  80. }
  81. }
  82. }
  83. /***********************
  84. * Methods
  85. ************************/
  86. const toRoundFix = (data, digit) => parseFloat(data).toFixed(digit);
  87. </script>