bar.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <script setup lang="ts">
  2. import * as echarts from 'echarts'
  3. const props = defineProps<{
  4. echartsData: object
  5. }>()
  6. const chartRef = ref()
  7. onMounted(() => {
  8. echarts.init(chartRef.value).setOption({
  9. tooltip: {
  10. trigger: 'item',
  11. },
  12. legend: {
  13. top: '1%',
  14. right: '5%',
  15. textStyle: {
  16. color: '#ccc',
  17. },
  18. },
  19. grid: {
  20. top: '8%',
  21. bottom: '80px',
  22. },
  23. color: ['#7D7CFC', '#0293FD'],
  24. dataset: {
  25. source: props.echartsData.dataset_source,
  26. },
  27. xAxis: {
  28. type: 'category',
  29. axisLine: {
  30. show: true,
  31. lineStyle: {
  32. type: 'dashed',
  33. color: '#ccc',
  34. },
  35. },
  36. },
  37. yAxis: {
  38. axisLine: {
  39. show: true,
  40. lineStyle: {
  41. type: 'dashed',
  42. color: '#ccc',
  43. },
  44. },
  45. splitLine: {
  46. show: true,
  47. lineStyle: {
  48. type: 'dashed',
  49. color: '#ccc',
  50. },
  51. },
  52. },
  53. // Declare several bar series, each will be mapped
  54. // to a column of dataset.source by default.
  55. series: [{ type: 'bar' }, { type: 'bar' }],
  56. })
  57. })
  58. </script>
  59. <template>
  60. <div ref="chartRef" class="w-full h-full " />
  61. </template>