EventWorkArea.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. const labels = props.chartsData.map(item => item.positionName)
  19. return {
  20. grid: {
  21. top: 50,
  22. bottom: 40,
  23. left: 60,
  24. right: 20
  25. },
  26. legend: {
  27. top: '10',
  28. left: '30',
  29. // orient: 'vertical',
  30. textStyle: { color: '#fff' }
  31. },
  32. xAxis: {
  33. type: 'category',
  34. data: labels,
  35. axisLabel: { color: '#fff', fontSize: 14 },
  36. axisLine: { lineStyle: { color: '#344067' } }
  37. },
  38. yAxis: [
  39. {
  40. type: 'value',
  41. position: 'left',
  42. axisLabel: { color: '#fff', fontSize: 14 },
  43. axisLine: { lineStyle: { color: '#fff' } },
  44. splitLine: { lineStyle: { color: '#344067' } }
  45. },
  46. ],
  47. series: [
  48. {
  49. name: '查获数量',
  50. type: 'bar',
  51. data: props.chartsData.map(item => item.positionNum),
  52. itemStyle: {
  53. borderRadius: [5, 5, 0, 0],
  54. color: '#6DA6FE',
  55. },
  56. label: {
  57. show: true,
  58. position: 'top',
  59. color: '#6DA6FE',
  60. fontSize: 14,
  61. fontWeight: 500
  62. },
  63. barWidth: '40%'
  64. },
  65. ],
  66. tooltip: {
  67. trigger: 'axis',
  68. backgroundColor: 'rgba(13,80,122,1)',
  69. borderColor: '#70CFE7',
  70. textStyle: { color: '#fff' }
  71. }
  72. }
  73. })
  74. useECharts(bar, setChartsOptionsBar);
  75. </script>
  76. <style lang="scss" scoped></style>