SeizedItems.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <Card title="查获物品分布">
  3. <div ref="bar" style="width: 100%; height: 100%;"></div>
  4. </Card>
  5. </template>
  6. <script setup>
  7. import { computed } from 'vue';
  8. import Card from './card.vue';
  9. import { useECharts } from '@/hooks/useEcharts.js';
  10. const bar = ref(null)
  11. const props = defineProps({
  12. chartsData: {
  13. type: Object,
  14. default: () => ([])
  15. }
  16. })
  17. const setChartsOptionsBar = computed(() => {
  18. return {
  19. grid: {
  20. top: 40,
  21. bottom: 40,
  22. left: 60,
  23. right: 20
  24. },
  25. tooltip: {
  26. trigger: 'item',
  27. backgroundColor: 'rgba(13,80,122,1)',
  28. borderColor: '#70CFE7',
  29. textStyle: { color: '#fff' }
  30. },
  31. legend: {
  32. top: 'center',
  33. left: '0%',
  34. orient: 'vertical',
  35. textStyle: { color: '#fff' }
  36. },
  37. series: [{
  38. type: 'pie',
  39. radius: ['40%', '70%'],
  40. data: props.chartsData.map(item => {
  41. return {
  42. value: item.itemNum,
  43. name: item.itemName
  44. }
  45. }),
  46. label: { show: true, color: '#fff', fontSize: 16, lineHeight: 20, formatter: '{b}\n{c}' },
  47. labelLine: { show: true }
  48. }],
  49. }
  50. })
  51. useECharts(bar, setChartsOptionsBar);
  52. </script>
  53. <style lang="scss" scoped></style>