diff --git a/src/chart.ts b/src/chart.ts index dbe4c8a7..36708ae1 100644 --- a/src/chart.ts +++ b/src/chart.ts @@ -53,7 +53,7 @@ export const Chart = defineComponent({ } const update = (chart: ChartJS) => { - chart.update() + chart.update(props.updateMode) } onMounted(renderChart) diff --git a/src/props.ts b/src/props.ts index 90b54121..930ae24e 100644 --- a/src/props.ts +++ b/src/props.ts @@ -1,5 +1,5 @@ import type { PropType } from 'vue' -import type { ChartType, ChartData, Plugin } from 'chart.js' +import type { ChartType, ChartData, Plugin, UpdateMode } from 'chart.js' export const CommonProps = { data: { @@ -17,6 +17,10 @@ export const CommonProps = { datasetIdKey: { type: String, default: 'label' + }, + updateMode: { + type: String as PropType, + default: undefined } } as const diff --git a/src/types.ts b/src/types.ts index 70a68c8b..47accd65 100644 --- a/src/types.ts +++ b/src/types.ts @@ -5,7 +5,8 @@ import type { ChartData, ChartOptions, DefaultDataPoint, - Plugin + Plugin, + UpdateMode } from 'chart.js' export interface ChartProps< @@ -39,6 +40,11 @@ export interface ChartProps< * @default 'label' */ datasetIdKey?: string + /** + * A mode string to indicate transition configuration should be used. + * @see https://www.chartjs.org/docs/latest/developers/api.html#update-mode + */ + updateMode?: UpdateMode } export interface ChartComponentRef<