Skip to content
New issue

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

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

TypeError: easingFunction is not a function #7180

Closed
aldipower opened this issue Mar 7, 2020 · 2 comments · Fixed by #8781
Closed

TypeError: easingFunction is not a function #7180

aldipower opened this issue Mar 7, 2020 · 2 comments · Fixed by #8781

Comments

@aldipower
Copy link

aldipower commented Mar 7, 2020

Sometimes, when I reload or resize the window with a chart included, Chart.js throws the following error:
TypeError: easingFunction is not a function

I could track it down to this line in the current 2.9.3 release render-function:

var easingFunction = helpers.easing.effects[animationObject.easing];
...
chart.draw(easingFunction(stepDecimal), stepDecimal, currentStep);

https://github.com/chartjs/Chart.js/blob/release/src/core/core.controller.js#L650

I notices that the upcoming version 3.0.0 has a completely rewritten animation handling.
But this will be a breaking changes release and I hope 2.9. will still receive some bugfixes.

Expected Behavior

Chart.js should not throw and break the complete application,
instead it should catch the error and write an console.error-message.

Possible Solution

Implement a null-check and do not try to execute the easingFunction.

Steps to Reproduce (for bugs)

Render a chart (Pie, Bar, Line) and resize the window wildly.

    this.chartOptions = {
      responsive: true,
      maintainAspectRatio: false,
      legend: false,
    };

I turned off animations globally:

  global.animation = {
    duration: 0,
  };

  global.hover = {
    animationDuration: 0,
  };

  global.responsiveAnimationDuration = 0;

Environment

  • Chart.js version: 2.9.3
  • Browser name and version: Firefox Nightly (Mar 2020)
@benmccann
Copy link
Contributor

Hmm. Maybe this is related to the way you disabled animations? What if you disable animations like this? https://www.chartjs.org/docs/latest/general/performance.html#disable-animations

@aldipower
Copy link
Author

aldipower commented Mar 20, 2020

Hey, same thing when disabling animation directly in the chart options, like in the link, you've posted.
Chart.js crashes hard with an unhandled exception when I resize then window, but not every time, only sometimes. Looks like a timing thing dunno.
But still it is not good practice to call a function that could possibly went 'null'. There is a null-check missing anyway..
Too bad you closed the PR, because I am not sure, if everybody wants to update to a new major version with a lot of rewrites and potential new bugs.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants