Skip to content

Conversation

@veggiesaurus
Copy link
Contributor

Chart.js has a render function in addition to update. Unlike update, calling render does not recalculate the layout and update datasets, so it is far more performant in cases where only config or plugins have to be updated. However, render does not invoke the afterScaleUpdate hook, so calling render with an updated annotation config will not update the annotation, since element.configure() takes place in the afterScaleUpdate hook.

To remedy this, I've moved the element.configure() call to within the draw function, so that it still gets called when render is called. This means that, in scenarios when only annotations need to be updated, we can now call render instead of update for a significant speedup in situations where layout or dataset updates are expensive.

@benmccann benmccann closed this Dec 14, 2018
@benmccann benmccann reopened this Dec 14, 2018
@benmccann benmccann merged commit 0cd1388 into chartjs:master Dec 14, 2018
osro added a commit to osro/chartjs-plugin-annotation that referenced this pull request Jan 28, 2020
* commit '7037eea71314613a8af83d2298241841cbc34c4f':
  Fix undefined reference
  "preserveComments" not longer available on gulp-uglify (chartjs#177)
  Added PLUGIN ID because missing (chartjs#173)
  allow multiple lines of text in the line label (chartjs#129)
  Chart.js should be a peerDependency
  Fix getting chart borders for box size setting (chartjs#152)
  Fix a number of lint errors in the samples
  Add missing .htmllintrc
  Lint sample html (chartjs#150)
  Pass the index of value datapoint to getPixelValue (chartjs#109)
  move configure step to draw time, to support render call (chartjs#116)
  Read plugin options from plugins.annotation (chartjs#130)
  Add Travis config
  Add gulp lint task (chartjs#144)
  Fix Dropbox url

# Conflicts:
#	README.md
#	package.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants