Skip to content

Commit 5bd9805

Browse files
authored
feat: updateMode prop (#962)
1 parent c3f8fc9 commit 5bd9805

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/chart.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const Chart = defineComponent({
5353
}
5454

5555
const update = (chart: ChartJS) => {
56-
chart.update()
56+
chart.update(props.updateMode)
5757
}
5858

5959
onMounted(renderChart)

src/props.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { PropType } from 'vue'
2-
import type { ChartType, ChartData, Plugin } from 'chart.js'
2+
import type { ChartType, ChartData, Plugin, UpdateMode } from 'chart.js'
33

44
export const CommonProps = {
55
data: {
@@ -17,6 +17,10 @@ export const CommonProps = {
1717
datasetIdKey: {
1818
type: String,
1919
default: 'label'
20+
},
21+
updateMode: {
22+
type: String as PropType<UpdateMode>,
23+
default: undefined
2024
}
2125
} as const
2226

src/types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import type {
55
ChartData,
66
ChartOptions,
77
DefaultDataPoint,
8-
Plugin
8+
Plugin,
9+
UpdateMode
910
} from 'chart.js'
1011

1112
export interface ChartProps<
@@ -39,6 +40,11 @@ export interface ChartProps<
3940
* @default 'label'
4041
*/
4142
datasetIdKey?: string
43+
/**
44+
* A mode string to indicate transition configuration should be used.
45+
* @see https://www.chartjs.org/docs/latest/developers/api.html#update-mode
46+
*/
47+
updateMode?: UpdateMode
4248
}
4349

4450
export interface ChartComponentRef<

0 commit comments

Comments
 (0)