Skip to content

Commit

Permalink
feat: updateMode prop (#962)
Browse files Browse the repository at this point in the history
  • Loading branch information
dangreen committed Dec 5, 2022
1 parent c3f8fc9 commit 5bd9805
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/chart.ts
Expand Up @@ -53,7 +53,7 @@ export const Chart = defineComponent({
}

const update = (chart: ChartJS) => {
chart.update()
chart.update(props.updateMode)
}

onMounted(renderChart)
Expand Down
6 changes: 5 additions & 1 deletion 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: {
Expand All @@ -17,6 +17,10 @@ export const CommonProps = {
datasetIdKey: {
type: String,
default: 'label'
},
updateMode: {
type: String as PropType<UpdateMode>,
default: undefined
}
} as const

Expand Down
8 changes: 7 additions & 1 deletion src/types.ts
Expand Up @@ -5,7 +5,8 @@ import type {
ChartData,
ChartOptions,
DefaultDataPoint,
Plugin
Plugin,
UpdateMode
} from 'chart.js'

export interface ChartProps<
Expand Down Expand Up @@ -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<
Expand Down

0 comments on commit 5bd9805

Please sign in to comment.