ChartPool.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <ul class="chart-pool">
  3. <li class="chart-item" v-for="(chart, index) in chartList" :key="index">
  4. <div class="chart-content" @click="selectChart(chart)">
  5. <IconChartLine size="24" v-if="chart === 'line'" />
  6. <IconChartHistogram size="24" v-else-if="chart === 'bar'" />
  7. <IconChartProportion size="24" v-else-if="chart === 'pie'" />
  8. </div>
  9. </li>
  10. </ul>
  11. </template>
  12. <script lang="ts">
  13. import { defineComponent } from 'vue'
  14. export default defineComponent({
  15. name: 'chart-pool',
  16. setup(props, { emit }) {
  17. const chartList = ['bar', 'line', 'pie']
  18. const selectChart = (chart: string) => {
  19. emit('select', chart)
  20. }
  21. return {
  22. chartList,
  23. selectChart,
  24. }
  25. },
  26. })
  27. </script>
  28. <style lang="scss" scoped>
  29. .chart-pool {
  30. width: 120px;
  31. margin-bottom: -5px;
  32. @include flex-grid-layout();
  33. }
  34. .chart-item {
  35. @include flex-grid-layout-children(3, 32%);
  36. height: 0;
  37. padding-bottom: 32%;
  38. flex-shrink: 0;
  39. position: relative;
  40. cursor: pointer;
  41. }
  42. .chart-content {
  43. position: absolute;
  44. top: 0;
  45. bottom: 0;
  46. left: 0;
  47. right: 0;
  48. display: flex;
  49. justify-content: center;
  50. align-items: center;
  51. color: #999;
  52. &:hover {
  53. color: $themeColor;
  54. }
  55. }
  56. </style>