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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AnimationEvent is incorrectly typed #9833

Closed
NorthBlue333 opened this issue Nov 10, 2021 · 1 comment · Fixed by #9834 or #9837
Closed

AnimationEvent is incorrectly typed #9833

NorthBlue333 opened this issue Nov 10, 2021 · 1 comment · Fixed by #9834 or #9837
Labels
type: bug type: types Typescript type changes
Milestone

Comments

@NorthBlue333
Copy link
Contributor

NorthBlue333 commented Nov 10, 2021

Expected Behavior

According to the documentation, AnimationEvent should be typed as :

export interface AnimationEvent {
	chart: Chart;
	initial: boolean;
	numSteps: number;
	currentStep: number;
}

Current Behavior

AnimationEvent is currently typed as :

export interface AnimationEvent {
	chart: Chart;
	numSteps: number;
	currentState: number;
}

Possible Solution

Type AnimationEvent as :

export interface AnimationEvent {
	chart: Chart;
	initial: boolean;
	numSteps: number;
	currentStep: number;
}

Steps to Reproduce

Using the callbacks as the documentation shows :

const config = {
  type: 'line',
  data: data,
  options: {
    animation: {
      duration: 2000,
      onProgress: function(context) {
        if (context.initial) {
          initProgress.value = context.currentStep / context.numSteps;
        } else {
          progress.value = context.currentStep / context.numSteps;
        }
      },
      onComplete: function(context) {
        if (context.initial) {
          console.log('Initial animation finished');
        } else {
          console.log('animation finished');
        }
      }
    },
  },
};

Context

It is currently needed to override/cast the event to use the correct properties.

Environment

  • Chart.js version: 3.6.0
@NorthBlue333
Copy link
Contributor Author

NorthBlue333 commented Nov 11, 2021

Hello @kurkle
currentStep: number; instead of currentState: number; is missing from #9834

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug type: types Typescript type changes
Projects
None yet
3 participants