Skip to content

Commit

Permalink
Require at least chartjs v3.7 (chartjs#723)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeLenaleee authored Apr 11, 2022
1 parent bb60ffb commit 8275501
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
4 changes: 4 additions & 0 deletions docs/guide/migrationV2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

`chartjs-plugin-annotation` plugin version 2 introduces a number of breaking changes. In order to improve performance, offer new features, and improve maintainability, it was necessary to break backwards compatibility, but we aimed to do so only when worth the benefit.

## Chart.js version

The annotation plugin requires at least version 3.7.0 to work because of some bug fixes that happend within chart.js itself.

## Options

A number of changes were made to the configuration options passed to the plugin configuration. Those changes are documented below.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@simonbrunel/vuepress-plugin-versions": "^0.2.0",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"chart.js": "^3.1.0",
"chart.js": "^3.7.0",
"chartjs-plugin-autocolors": "^0.0.5",
"chartjs-test-utils": "^0.4.0",
"concurrently": "^7.0.0",
Expand Down Expand Up @@ -68,6 +68,6 @@
"vuepress-theme-chartjs": "^0.2.0"
},
"peerDependencies": {
"chart.js": "^3.1.0"
"chart.js": "^3.7.0"
}
}
16 changes: 1 addition & 15 deletions src/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {adjustScaleRange, verifyScaleOptions} from './scale';
import {updateElements, resolveType} from './elements';
import {annotationTypes} from './types';
import {requireVersion} from './helpers';
import {name, version} from '../package.json';
import {version} from '../package.json';

const chartStates = new Map();

Expand All @@ -14,26 +14,12 @@ export default {

version,

/* TODO: enable in v2
beforeRegister() {
requireVersion('chart.js', '3.7', Chart.version);
},
*/

afterRegister() {
Chart.register(annotationTypes);

// TODO: Remove this check, warning and workaround in v2
if (!requireVersion('chart.js', '3.7', Chart.version, false)) {
console.warn(`${name} has known issues with chart.js versions prior to 3.7, please consider upgrading.`);

// Workaround for https://github.com/chartjs/chartjs-plugin-annotation/issues/572
Chart.defaults.set('elements.lineAnnotation', {
callout: {},
font: {},
padding: 6
});
}
},

afterUnregister() {
Expand Down

0 comments on commit 8275501

Please sign in to comment.