VisitAnalysisBar.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <div ref="chartRef" :style="{ height, width }"></div>
  3. </template>
  4. <script lang="ts">
  5. import { defineComponent, onMounted, ref, Ref } from 'vue';
  6. import { useECharts } from '/@/hooks/web/useECharts';
  7. import { basicProps } from './props';
  8. export default defineComponent({
  9. props: basicProps,
  10. setup() {
  11. const chartRef = ref<HTMLDivElement | null>(null);
  12. const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
  13. onMounted(() => {
  14. setOptions({
  15. tooltip: {
  16. trigger: 'axis',
  17. axisPointer: {
  18. lineStyle: {
  19. width: 1,
  20. color: '#019680',
  21. },
  22. },
  23. },
  24. grid: { left: '1%', right: '1%', top: '2 %', bottom: 0, containLabel: true },
  25. xAxis: {
  26. type: 'category',
  27. data: [
  28. '1月',
  29. '2月',
  30. '3月',
  31. '4月',
  32. '5月',
  33. '6月',
  34. '7月',
  35. '8月',
  36. '9月',
  37. '10月',
  38. '11月',
  39. '12月',
  40. ],
  41. },
  42. yAxis: {
  43. type: 'value',
  44. max: 8000,
  45. splitNumber: 4,
  46. },
  47. series: [
  48. {
  49. data: [3000, 2000, 3333, 5000, 3200, 4200, 3200, 2100, 3000, 5100, 6000, 3200, 4800],
  50. type: 'bar',
  51. barMaxWidth: 80,
  52. },
  53. ],
  54. });
  55. });
  56. return { chartRef };
  57. },
  58. });
  59. </script>