55 lines
1.1 KiB
Vue
55 lines
1.1 KiB
Vue
<script setup lang="ts">
|
|||
|
|
import { use } from 'echarts/core';
|
||
|
|
import { CanvasRenderer } from 'echarts/renderers';
|
||
|
|
import { LineChart, PieChart } from 'echarts/charts';
|
||
|
|
import {
|
||
|
|
GridComponent,
|
||
|
|
LegendComponent,
|
||
|
|
TooltipComponent,
|
||
|
|
} from 'echarts/components';
|
||
|
|
import VChart from 'vue-echarts';
|
||
|
|
import type { ComposeOption } from 'echarts/core';
|
||
|
|
import type { LineSeriesOption, PieSeriesOption } from 'echarts/charts';
|
||
|
|
import type {
|
||
|
|
GridComponentOption,
|
||
|
|
LegendComponentOption,
|
||
|
|
TooltipComponentOption,
|
||
|
|
} from 'echarts/components';
|
||
|
|
|
||
|
|
use([
|
||
|
|
CanvasRenderer,
|
||
|
|
LineChart,
|
||
|
|
PieChart,
|
||
|
|
GridComponent,
|
||
|
|
TooltipComponent,
|
||
|
|
LegendComponent,
|
||
|
|
]);
|
||
|
|
|
||
|
|
export type UiChartOption = ComposeOption<
|
||
|
|
| LineSeriesOption
|
||
|
|
| PieSeriesOption
|
||
|
|
| GridComponentOption
|
||
|
|
| TooltipComponentOption
|
||
|
|
| LegendComponentOption
|
||
|
|
>;
|
||
|
|
|
||
|
|
withDefaults(
|
||
|
|
defineProps<{
|
||
|
|
option: UiChartOption;
|
||
|
|
height?: string;
|
||
|
|
}>(),
|
||
|
|
{ height: '220px' },
|
||
|
|
);
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<template>
|
||
|
|
<VChart class="ui-chart" :option="option" :style="{ height }" autoresize />
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<style scoped>
|
||
|
|
.ui-chart {
|
||
|
|
width: 100%;
|
||
|
|
min-width: 0;
|
||
|
|
}
|
||
|
|
</style>
|