type ChartType = 'bar' | 'line' | 'pie';
interface PropsType {
type: EChartType;
xData: **** ;
seriesData: **** ;
}
const props = defineProps<PropsType>();
how to do
When ChartType = 'bar'
, xData
has type string[]
and seriesData
has type number[]
.
When ChartType = 'line'
, xData
has type Array<string|number>
and seriesData
has type string[]
.
When ChartType = 'pie'
, xData
has type number[]
and seriesData
has type {value:string,name:string}[]
.