diff --git a/package.json b/package.json index b6b3aa9..871c8f6 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "import": "./dist/chartjs-chart-matrix.esm.js", "require": "./dist/chartjs-chart-matrix.min.js" }, + "sideEffects": ["dist/chartjs-chart-matrix.js", "dist/chartjs-chart-matrix-min.js"], "scripts": { "autobuild": "rollup -c -w", "build": "rollup -c", diff --git a/src/controller.js b/src/controller.js index 82d8613..32a4d42 100644 --- a/src/controller.js +++ b/src/controller.js @@ -2,6 +2,38 @@ import {DatasetController} from 'chart.js'; import {version} from '../package.json'; export default class MatrixController extends DatasetController { + + static id = 'matrix'; + static version = version; + + static defaults = { + dataElementType: 'matrix', + + animations: { + numbers: { + type: 'number', + properties: ['x', 'y', 'width', 'height'] + } + }, + }; + + static overrides = { + interaction: { + mode: 'nearest', + intersect: true + }, + scales: { + x: { + type: 'linear', + offset: true + }, + y: { + type: 'linear', + reverse: true + } + }, + }; + initialize() { this.enableOptionSharing = true; super.initialize(); @@ -70,36 +102,3 @@ function resolveY(anchorY, y, height) { } return y - height / 2; } - -MatrixController.id = 'matrix'; - -MatrixController.version = version; - -MatrixController.defaults = { - dataElementType: 'matrix', - - animations: { - numbers: { - type: 'number', - properties: ['x', 'y', 'width', 'height'] - } - }, -}; - -MatrixController.overrides = { - interaction: { - mode: 'nearest', - intersect: true - }, - - scales: { - x: { - type: 'linear', - offset: true - }, - y: { - type: 'linear', - reverse: true - } - }, -}; diff --git a/src/element.js b/src/element.js index a89d6e8..8a77178 100644 --- a/src/element.js +++ b/src/element.js @@ -71,6 +71,20 @@ function inRange(rect, x, y, useFinalPosition) { } export default class MatrixElement extends Element { + + static id = 'matrix'; + + static defaults = { + backgroundColor: undefined, + borderColor: undefined, + borderWidth: undefined, + borderRadius: 0, + anchorX: 'center', + anchorY: 'center', + width: 20, + height: 20 + }; + constructor(cfg) { super(); @@ -136,15 +150,3 @@ export default class MatrixElement extends Element { return axis === 'x' ? this.width / 2 : this.height / 2; } } - -MatrixElement.id = 'matrix'; -MatrixElement.defaults = { - backgroundColor: undefined, - borderColor: undefined, - borderWidth: undefined, - borderRadius: 0, - anchorX: 'center', - anchorY: 'center', - width: 20, - height: 20 -};