Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: updateMode prop #962

Merged
merged 1 commit into from Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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