You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Chart.js plugin to defer initial chart updates until the user scrolls and the canvas appears inside the viewport, and thus trigger the initial chart animations when the user is likely to see them.
newChart(ctx,{// ... data ...options: {// ... other options ...plugins: {deferred: {xOffset: 150,// defer until 150px of the canvas width are inside the viewportyOffset: '50%',// defer until 50% of the canvas height are inside the viewportdelay: 500// delay of 500 ms after the canvas is considered inside the viewport}}}});
Development
You first need to install node dependencies (requires Node.js):
> npm install
The following commands will then be available from the repository root:
> npm run build // build dist files
> npm run build:dev // build and watch for changes
> npm run lint // perform code linting
> npm run lint -- --fix // automatically fix linting problems
> npm run docs // generate documentation (`dist/docs`)
> npm run docs:dev // generate documentation and watch for changes
> npm run package // create tgz and zip archives with dist files
License
chartjs-plugin-deferred is available under the MIT license.