chartjs-chart-matrix 3.0.3 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,12 +24,22 @@ class MatrixController extends chart_js.DatasetController {
24
24
  updateElements(rects, start, count, mode) {
25
25
  const reset = mode === 'reset';
26
26
  const { xScale, yScale } = this._cachedMeta;
27
+ if (!xScale || !yScale) {
28
+ return;
29
+ }
27
30
  const firstOpts = this.resolveDataElementOptions(start, mode);
28
31
  const sharedOptions = this.getSharedOptions(firstOpts);
29
32
  for(let i = start; i < start + count; i++){
30
- const parsed = !reset && this.getParsed(i);
31
- const x = reset ? xScale.getBasePixel() : xScale.getPixelForValue(parsed.x);
32
- const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(parsed.y);
33
+ let x;
34
+ let y;
35
+ if (reset) {
36
+ x = xScale.getBasePixel();
37
+ y = yScale.getBasePixel();
38
+ } else {
39
+ const parsed = this.getParsed(i);
40
+ x = xScale.getPixelForValue(parsed.x);
41
+ y = yScale.getPixelForValue(parsed.y);
42
+ }
33
43
  const options = this.resolveDataElementOptions(i, mode);
34
44
  const { width, height, anchorX, anchorY } = options;
35
45
  const properties = {
@@ -41,7 +51,9 @@ class MatrixController extends chart_js.DatasetController {
41
51
  };
42
52
  this.updateElement(rects[i], i, properties, mode);
43
53
  }
44
- this.updateSharedOptions(sharedOptions, mode, firstOpts);
54
+ if (sharedOptions) {
55
+ this.updateSharedOptions(sharedOptions, mode, firstOpts);
56
+ }
45
57
  }
46
58
  draw() {
47
59
  const ctx = this.chart.ctx;
@@ -120,16 +132,17 @@ function getBounds(element, useFinalPosition) {
120
132
  function limit(value, min, max) {
121
133
  return Math.max(Math.min(value, max), min);
122
134
  }
135
+ const borderValue = (value)=>+(value ?? 0) || 0;
123
136
  function parseBorderWidth(options, maxW, maxH) {
124
137
  const value = options.borderWidth;
125
138
  let t, r, b, l;
126
- if (helpers.isObject(value)) {
127
- t = +value.top || 0;
128
- r = +value.right || 0;
129
- b = +value.bottom || 0;
130
- l = +value.left || 0;
139
+ if (value != null && helpers.isObject(value)) {
140
+ t = borderValue(value.top);
141
+ r = borderValue(value.right);
142
+ b = borderValue(value.bottom);
143
+ l = borderValue(value.left);
131
144
  } else {
132
- t = r = b = l = +value || 0;
145
+ t = r = b = l = borderValue(value);
133
146
  }
134
147
  return {
135
148
  b: limit(b, 0, maxH),
@@ -206,13 +219,13 @@ class MatrixElement extends chart_js.Element {
206
219
  ctx.restore();
207
220
  }
208
221
  inRange(mouseX, mouseY, useFinalPosition) {
209
- return inRange(this, mouseX, mouseY, useFinalPosition);
222
+ return inRange(this, mouseX, mouseY, useFinalPosition ?? false);
210
223
  }
211
224
  inXRange(mouseX, useFinalPosition) {
212
- return inRange(this, mouseX, null, useFinalPosition);
225
+ return inRange(this, mouseX, null, useFinalPosition ?? false);
213
226
  }
214
227
  inYRange(mouseY, useFinalPosition) {
215
- return inRange(this, null, mouseY, useFinalPosition);
228
+ return inRange(this, null, mouseY, useFinalPosition ?? false);
216
229
  }
217
230
  getCenterPoint(useFinalPosition) {
218
231
  const { x, y, width, height } = this.getProps([
@@ -233,7 +246,7 @@ class MatrixElement extends chart_js.Element {
233
246
  return axis === 'x' ? this.width / 2 : this.height / 2;
234
247
  }
235
248
  constructor(cfg){
236
- super();
249
+ super(), this.width = MatrixElement.defaults.width, this.height = MatrixElement.defaults.height;
237
250
  if (cfg) {
238
251
  Object.assign(this, cfg);
239
252
  }
@@ -21,12 +21,22 @@ class MatrixController extends DatasetController {
21
21
  updateElements(rects, start, count, mode) {
22
22
  const reset = mode === 'reset';
23
23
  const { xScale, yScale } = this._cachedMeta;
24
+ if (!xScale || !yScale) {
25
+ return;
26
+ }
24
27
  const firstOpts = this.resolveDataElementOptions(start, mode);
25
28
  const sharedOptions = this.getSharedOptions(firstOpts);
26
29
  for(let i = start; i < start + count; i++){
27
- const parsed = !reset && this.getParsed(i);
28
- const x = reset ? xScale.getBasePixel() : xScale.getPixelForValue(parsed.x);
29
- const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(parsed.y);
30
+ let x;
31
+ let y;
32
+ if (reset) {
33
+ x = xScale.getBasePixel();
34
+ y = yScale.getBasePixel();
35
+ } else {
36
+ const parsed = this.getParsed(i);
37
+ x = xScale.getPixelForValue(parsed.x);
38
+ y = yScale.getPixelForValue(parsed.y);
39
+ }
30
40
  const options = this.resolveDataElementOptions(i, mode);
31
41
  const { width, height, anchorX, anchorY } = options;
32
42
  const properties = {
@@ -38,7 +48,9 @@ class MatrixController extends DatasetController {
38
48
  };
39
49
  this.updateElement(rects[i], i, properties, mode);
40
50
  }
41
- this.updateSharedOptions(sharedOptions, mode, firstOpts);
51
+ if (sharedOptions) {
52
+ this.updateSharedOptions(sharedOptions, mode, firstOpts);
53
+ }
42
54
  }
43
55
  draw() {
44
56
  const ctx = this.chart.ctx;
@@ -117,16 +129,17 @@ function getBounds(element, useFinalPosition) {
117
129
  function limit(value, min, max) {
118
130
  return Math.max(Math.min(value, max), min);
119
131
  }
132
+ const borderValue = (value)=>+(value ?? 0) || 0;
120
133
  function parseBorderWidth(options, maxW, maxH) {
121
134
  const value = options.borderWidth;
122
135
  let t, r, b, l;
123
- if (isObject(value)) {
124
- t = +value.top || 0;
125
- r = +value.right || 0;
126
- b = +value.bottom || 0;
127
- l = +value.left || 0;
136
+ if (value != null && isObject(value)) {
137
+ t = borderValue(value.top);
138
+ r = borderValue(value.right);
139
+ b = borderValue(value.bottom);
140
+ l = borderValue(value.left);
128
141
  } else {
129
- t = r = b = l = +value || 0;
142
+ t = r = b = l = borderValue(value);
130
143
  }
131
144
  return {
132
145
  b: limit(b, 0, maxH),
@@ -203,13 +216,13 @@ class MatrixElement extends Element {
203
216
  ctx.restore();
204
217
  }
205
218
  inRange(mouseX, mouseY, useFinalPosition) {
206
- return inRange(this, mouseX, mouseY, useFinalPosition);
219
+ return inRange(this, mouseX, mouseY, useFinalPosition ?? false);
207
220
  }
208
221
  inXRange(mouseX, useFinalPosition) {
209
- return inRange(this, mouseX, null, useFinalPosition);
222
+ return inRange(this, mouseX, null, useFinalPosition ?? false);
210
223
  }
211
224
  inYRange(mouseY, useFinalPosition) {
212
- return inRange(this, null, mouseY, useFinalPosition);
225
+ return inRange(this, null, mouseY, useFinalPosition ?? false);
213
226
  }
214
227
  getCenterPoint(useFinalPosition) {
215
228
  const { x, y, width, height } = this.getProps([
@@ -230,7 +243,7 @@ class MatrixElement extends Element {
230
243
  return axis === 'x' ? this.width / 2 : this.height / 2;
231
244
  }
232
245
  constructor(cfg){
233
- super();
246
+ super(), this.width = MatrixElement.defaults.width, this.height = MatrixElement.defaults.height;
234
247
  if (cfg) {
235
248
  Object.assign(this, cfg);
236
249
  }
@@ -4,5 +4,5 @@
4
4
  * (c) 2026 Jukka Kurkela
5
5
  * Released under the MIT license
6
6
  */
7
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("chart.js"),require("chart.js/helpers")):"function"==typeof define&&define.amd?define(["exports","chart.js","chart.js/helpers"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["chartjs-chart-matrix"]={},t.Chart,t.Chart.helpers)}(this,function(t,e,r){"use strict";class i extends e.DatasetController{initialize(){this.enableOptionSharing=!0,super.initialize()}update(t){const e=this._cachedMeta;this.updateElements(e.data,0,e.data.length,t)}updateElements(t,e,r,i){const s="reset"===i,{xScale:a,yScale:h}=this._cachedMeta,l=this.resolveDataElementOptions(e,i),d=this.getSharedOptions(l);for(let l=e;l<e+r;l++){const e=!s&&this.getParsed(l),r=s?a.getBasePixel():a.getPixelForValue(e.x),d=s?h.getBasePixel():h.getPixelForValue(e.y),u=this.resolveDataElementOptions(l,i),{width:c,height:g,anchorX:p,anchorY:f}=u,x={height:g,options:u,width:c,x:n(p,r,c),y:o(f,d,g)};this.updateElement(t[l],l,x,i)}this.updateSharedOptions(d,i,l)}draw(){const t=this.chart.ctx,e=this.getMeta().data||[];let r,i;for(r=0,i=e.length;r<i;++r)e[r].draw(t)}}function n(t,e,r){return"left"===t||"start"===t?e:"right"===t||"end"===t?e-r:e-r/2}function o(t,e,r){return"top"===t||"start"===t?e:"bottom"===t||"end"===t?e-r:e-r/2}function s(t,e){const{x:r,y:i,width:n,height:o}=t.getProps(["x","y","width","height"],e);return{bottom:i+o,left:r,right:r+n,top:i}}function a(t,e,r){return Math.max(Math.min(t,r),e)}function h(t){const e=s(t,!1),i=e.right-e.left,n=e.bottom-e.top,o=function(t,e,i){const n=t.borderWidth;let o,s,h,l;return r.isObject(n)?(o=+n.top||0,s=+n.right||0,h=+n.bottom||0,l=+n.left||0):o=s=h=l=+n||0,{b:a(h,0,i),l:a(l,0,e),r:a(s,0,e),t:a(o,0,i)}}(t.options,i/2,n/2);return{inner:{h:n-o.t-o.b,w:i-o.l-o.r,x:e.left+o.l,y:e.top+o.t},outer:{h:n,w:i,x:e.left,y:e.top}}}function l(t,e,r,i){const n=null===e,o=null===r,a=!(!t||n&&o)&&s(t,i);return a&&(n||e>=a.left&&e<=a.right)&&(o||r>=a.top&&r<=a.bottom)}i.id="matrix",i.version="0.0.0-development",i.defaults={animations:{numbers:{properties:["x","y","width","height"],type:"number"}},dataElementType:"matrix"},i.overrides={interaction:{intersect:!0,mode:"nearest"},scales:{x:{offset:!0,type:"linear"},y:{reverse:!0,type:"linear"}}};class d extends e.Element{draw(t){const e=this.options,{inner:i,outer:n}=h(this),o=r.toTRBLCorners(e.borderRadius);t.save(),n.w!==i.w||n.h!==i.h?(t.beginPath(),r.addRoundedRectPath(t,{h:n.h,radius:o,w:n.w,x:n.x,y:n.y}),r.addRoundedRectPath(t,{h:i.h,radius:o,w:i.w,x:i.x,y:i.y}),t.fillStyle=e.backgroundColor,t.fill(),t.fillStyle=e.borderColor,t.fill("evenodd")):(t.beginPath(),r.addRoundedRectPath(t,{h:i.h,radius:o,w:i.w,x:i.x,y:i.y}),t.fillStyle=e.backgroundColor,t.fill()),t.restore()}inRange(t,e,r){return l(this,t,e,r)}inXRange(t,e){return l(this,t,null,e)}inYRange(t,e){return l(this,null,t,e)}getCenterPoint(t){const{x:e,y:r,width:i,height:n}=this.getProps(["x","y","width","height"],t);return{x:e+i/2,y:r+n/2}}tooltipPosition(){return this.getCenterPoint()}getRange(t){return"x"===t?this.width/2:this.height/2}constructor(t){super(),t&&Object.assign(this,t)}}d.id="matrix",d.defaults={anchorX:"center",anchorY:"center",backgroundColor:void 0,borderColor:void 0,borderRadius:0,borderWidth:void 0,height:20,width:20},e.Chart.register(i,d),t.MatrixController=i,t.MatrixElement=d});
7
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("chart.js"),require("chart.js/helpers")):"function"==typeof define&&define.amd?define(["exports","chart.js","chart.js/helpers"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["chartjs-chart-matrix"]={},t.Chart,t.Chart.helpers)}(this,function(t,e,i){"use strict";class r extends e.DatasetController{initialize(){this.enableOptionSharing=!0,super.initialize()}update(t){const e=this._cachedMeta;this.updateElements(e.data,0,e.data.length,t)}updateElements(t,e,i,r){const s="reset"===r,{xScale:h,yScale:a}=this._cachedMeta;if(!h||!a)return;const l=this.resolveDataElementOptions(e,r),d=this.getSharedOptions(l);for(let l=e;l<e+i;l++){let e,i;if(s)e=h.getBasePixel(),i=a.getBasePixel();else{const t=this.getParsed(l);e=h.getPixelForValue(t.x),i=a.getPixelForValue(t.y)}const d=this.resolveDataElementOptions(l,r),{width:u,height:c,anchorX:g,anchorY:f}=d,p={height:c,options:d,width:u,x:n(g,e,u),y:o(f,i,c)};this.updateElement(t[l],l,p,r)}d&&this.updateSharedOptions(d,r,l)}draw(){const t=this.chart.ctx,e=this.getMeta().data||[];let i,r;for(i=0,r=e.length;i<r;++i)e[i].draw(t)}}function n(t,e,i){return"left"===t||"start"===t?e:"right"===t||"end"===t?e-i:e-i/2}function o(t,e,i){return"top"===t||"start"===t?e:"bottom"===t||"end"===t?e-i:e-i/2}function s(t,e){const{x:i,y:r,width:n,height:o}=t.getProps(["x","y","width","height"],e);return{bottom:r+o,left:i,right:i+n,top:r}}function h(t,e,i){return Math.max(Math.min(t,i),e)}r.id="matrix",r.version="0.0.0-development",r.defaults={animations:{numbers:{properties:["x","y","width","height"],type:"number"}},dataElementType:"matrix"},r.overrides={interaction:{intersect:!0,mode:"nearest"},scales:{x:{offset:!0,type:"linear"},y:{reverse:!0,type:"linear"}}};const a=t=>+(t??0)||0;function l(t){const e=s(t,!1),r=e.right-e.left,n=e.bottom-e.top,o=function(t,e,r){const n=t.borderWidth;let o,s,l,d;return null!=n&&i.isObject(n)?(o=a(n.top),s=a(n.right),l=a(n.bottom),d=a(n.left)):o=s=l=d=a(n),{b:h(l,0,r),l:h(d,0,e),r:h(s,0,e),t:h(o,0,r)}}(t.options,r/2,n/2);return{inner:{h:n-o.t-o.b,w:r-o.l-o.r,x:e.left+o.l,y:e.top+o.t},outer:{h:n,w:r,x:e.left,y:e.top}}}function d(t,e,i,r){const n=null===e,o=null===i,h=!(!t||n&&o)&&s(t,r);return h&&(n||e>=h.left&&e<=h.right)&&(o||i>=h.top&&i<=h.bottom)}class u extends e.Element{draw(t){const e=this.options,{inner:r,outer:n}=l(this),o=i.toTRBLCorners(e.borderRadius);t.save(),n.w!==r.w||n.h!==r.h?(t.beginPath(),i.addRoundedRectPath(t,{h:n.h,radius:o,w:n.w,x:n.x,y:n.y}),i.addRoundedRectPath(t,{h:r.h,radius:o,w:r.w,x:r.x,y:r.y}),t.fillStyle=e.backgroundColor,t.fill(),t.fillStyle=e.borderColor,t.fill("evenodd")):(t.beginPath(),i.addRoundedRectPath(t,{h:r.h,radius:o,w:r.w,x:r.x,y:r.y}),t.fillStyle=e.backgroundColor,t.fill()),t.restore()}inRange(t,e,i){return d(this,t,e,i??!1)}inXRange(t,e){return d(this,t,null,e??!1)}inYRange(t,e){return d(this,null,t,e??!1)}getCenterPoint(t){const{x:e,y:i,width:r,height:n}=this.getProps(["x","y","width","height"],t);return{x:e+r/2,y:i+n/2}}tooltipPosition(){return this.getCenterPoint()}getRange(t){return"x"===t?this.width/2:this.height/2}constructor(t){super(),this.width=u.defaults.width,this.height=u.defaults.height,t&&Object.assign(this,t)}}u.id="matrix",u.defaults={anchorX:"center",anchorY:"center",backgroundColor:void 0,borderColor:void 0,borderRadius:0,borderWidth:void 0,height:20,width:20},e.Chart.register(r,u),t.MatrixController=r,t.MatrixElement=u});
8
8
  //# sourceMappingURL=chartjs-chart-matrix.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chartjs-chart-matrix.min.js","sources":["../src/controller.ts","../src/helpers.ts","../src/element.ts","../src/index.ts"],"sourcesContent":["import type { UpdateMode } from 'chart.js'\nimport type {\n AnchorX,\n AnchorY,\n MatrixControllerDatasetOptions,\n MatrixDataPoint,\n} from 'types/index.esm'\nimport type MatrixElement from './element'\n\nimport { DatasetController } from 'chart.js'\n\nimport { version } from '../package.json'\n\nexport default class MatrixController extends DatasetController<\n 'matrix',\n MatrixElement,\n MatrixElement,\n MatrixDataPoint\n> {\n static readonly id = 'matrix'\n static readonly version = version\n\n static readonly defaults = {\n animations: {\n numbers: {\n properties: ['x', 'y', 'width', 'height'],\n type: 'number',\n },\n },\n dataElementType: 'matrix',\n }\n\n static readonly overrides = {\n interaction: {\n intersect: true,\n mode: 'nearest',\n },\n scales: {\n x: {\n offset: true,\n type: 'linear',\n },\n y: {\n reverse: true,\n type: 'linear',\n },\n },\n }\n\n options: MatrixControllerDatasetOptions\n\n override initialize() {\n this.enableOptionSharing = true\n super.initialize()\n }\n\n override update(mode: UpdateMode) {\n const meta = this._cachedMeta\n\n this.updateElements(meta.data, 0, meta.data.length, mode)\n }\n\n override updateElements(rects: MatrixElement[], start: number, count: number, mode: UpdateMode) {\n const reset = mode === 'reset'\n const { xScale, yScale } = this._cachedMeta\n const firstOpts = this.resolveDataElementOptions(start, mode)\n const sharedOptions = this.getSharedOptions(firstOpts)\n\n for (let i = start; i < start + count; i++) {\n const parsed = !reset && this.getParsed(i)\n const x = reset ? xScale.getBasePixel() : xScale.getPixelForValue(parsed.x)\n const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(parsed.y)\n const options = this.resolveDataElementOptions(i, mode)\n const { width, height, anchorX, anchorY } = options\n const properties = {\n height,\n options,\n width,\n x: resolveX(anchorX, x, width),\n y: resolveY(anchorY, y, height),\n }\n this.updateElement(rects[i], i, properties, mode)\n }\n\n this.updateSharedOptions(sharedOptions, mode, firstOpts)\n }\n\n override draw() {\n const ctx = this.chart.ctx\n const data = this.getMeta().data || []\n let i: number, ilen: number\n\n for (i = 0, ilen = data.length; i < ilen; ++i) {\n data[i].draw(ctx)\n }\n }\n}\n\nfunction resolveX(anchorX: AnchorX, x: number, width: number) {\n if (anchorX === 'left' || anchorX === 'start') {\n return x\n }\n if (anchorX === 'right' || anchorX === 'end') {\n return x - width\n }\n return x - width / 2\n}\n\nfunction resolveY(anchorY: AnchorY, y: number, height: number) {\n if (anchorY === 'top' || anchorY === 'start') {\n return y\n }\n if (anchorY === 'bottom' || anchorY === 'end') {\n return y - height\n }\n return y - height / 2\n}\n","import type { MatrixOptions } from 'types/index.esm'\nimport type MatrixElement from './element'\n\nimport { isObject } from 'chart.js/helpers'\n\ntype Bounds = { left: number; top: number; right: number; bottom: number }\n\nfunction getBounds(element: MatrixElement, useFinalPosition: boolean): Bounds {\n const { x, y, width, height } = element.getProps(['x', 'y', 'width', 'height'], useFinalPosition)\n return { bottom: y + height, left: x, right: x + width, top: y }\n}\n\nfunction limit(value: number, min: number, max: number) {\n return Math.max(Math.min(value, max), min)\n}\n\nexport function parseBorderWidth(\n options: Pick<MatrixOptions, 'borderWidth'>,\n maxW: number,\n maxH: number\n) {\n const value = options.borderWidth\n let t: number, r: number, b: number, l: number\n\n if (isObject(value)) {\n t = +value.top || 0\n r = +value.right || 0\n b = +value.bottom || 0\n l = +value.left || 0\n } else {\n t = r = b = l = +value || 0\n }\n\n return {\n b: limit(b, 0, maxH),\n l: limit(l, 0, maxW),\n r: limit(r, 0, maxW),\n t: limit(t, 0, maxH),\n }\n}\n\nexport function boundingRects(element: MatrixElement) {\n const bounds = getBounds(element, false)\n const width = bounds.right - bounds.left\n const height = bounds.bottom - bounds.top\n const border = parseBorderWidth(element.options, width / 2, height / 2)\n\n return {\n inner: {\n h: height - border.t - border.b,\n w: width - border.l - border.r,\n x: bounds.left + border.l,\n y: bounds.top + border.t,\n },\n outer: {\n h: height,\n w: width,\n x: bounds.left,\n y: bounds.top,\n },\n }\n}\n\nexport function inRange(element: MatrixElement, x: number, y: number, useFinalPosition: boolean) {\n const skipX = x === null\n const skipY = y === null\n const bounds = !element || (skipX && skipY) ? false : getBounds(element, useFinalPosition)\n\n return (\n bounds &&\n (skipX || (x >= bounds.left && x <= bounds.right)) &&\n (skipY || (y >= bounds.top && y <= bounds.bottom))\n )\n}\n","import type { MatrixOptions, MatrixProps } from 'types/index.esm'\n\nimport { Element } from 'chart.js'\nimport { addRoundedRectPath, toTRBLCorners } from 'chart.js/helpers'\n\nimport { boundingRects, inRange } from './helpers'\n\nexport default class MatrixElement extends Element<MatrixProps, MatrixOptions> {\n static readonly id = 'matrix'\n\n static override readonly defaults = {\n anchorX: 'center',\n anchorY: 'center',\n backgroundColor: undefined,\n borderColor: undefined,\n borderRadius: 0,\n borderWidth: undefined,\n height: 20,\n width: 20,\n }\n\n width: number\n height: number\n\n constructor(cfg: MatrixProps) {\n super()\n\n if (cfg) {\n Object.assign(this, cfg)\n }\n }\n\n draw(ctx: CanvasRenderingContext2D) {\n const options = this.options\n const { inner, outer } = boundingRects(this)\n const radius = toTRBLCorners(options.borderRadius)\n\n ctx.save()\n\n if (outer.w !== inner.w || outer.h !== inner.h) {\n ctx.beginPath()\n addRoundedRectPath(ctx, { h: outer.h, radius, w: outer.w, x: outer.x, y: outer.y })\n addRoundedRectPath(ctx, { h: inner.h, radius, w: inner.w, x: inner.x, y: inner.y })\n ctx.fillStyle = options.backgroundColor\n ctx.fill()\n ctx.fillStyle = options.borderColor\n ctx.fill('evenodd')\n } else {\n ctx.beginPath()\n addRoundedRectPath(ctx, { h: inner.h, radius, w: inner.w, x: inner.x, y: inner.y })\n ctx.fillStyle = options.backgroundColor\n ctx.fill()\n }\n\n ctx.restore()\n }\n\n inRange(mouseX: number, mouseY: number, useFinalPosition?: boolean) {\n return inRange(this, mouseX, mouseY, useFinalPosition)\n }\n\n inXRange(mouseX: number, useFinalPosition?: boolean) {\n return inRange(this, mouseX, null, useFinalPosition)\n }\n\n inYRange(mouseY: number, useFinalPosition?: boolean) {\n return inRange(this, null, mouseY, useFinalPosition)\n }\n\n getCenterPoint(useFinalPosition?: boolean) {\n const { x, y, width, height } = this.getProps(['x', 'y', 'width', 'height'], useFinalPosition)\n return {\n x: x + width / 2,\n y: y + height / 2,\n }\n }\n\n override tooltipPosition() {\n return this.getCenterPoint()\n }\n\n getRange(axis: 'x' | 'y') {\n return axis === 'x' ? this.width / 2 : this.height / 2\n }\n}\n","import { Chart } from 'chart.js'\n\nimport MatrixController from './controller.js'\nimport MatrixElement from './element.js'\n\nChart.register(MatrixController, MatrixElement)\n\nexport { MatrixController, MatrixElement }\n"],"names":["MatrixController","DatasetController","initialize","this","enableOptionSharing","super","update","mode","meta","_cachedMeta","updateElements","data","length","rects","start","count","reset","xScale","yScale","firstOpts","resolveDataElementOptions","sharedOptions","getSharedOptions","i","parsed","getParsed","x","getBasePixel","getPixelForValue","y","options","width","height","anchorX","anchorY","properties","resolveX","resolveY","updateElement","updateSharedOptions","draw","ctx","chart","getMeta","ilen","getBounds","element","useFinalPosition","getProps","bottom","left","right","top","limit","value","min","max","Math","boundingRects","bounds","border","maxW","maxH","borderWidth","t","r","b","l","isObject","parseBorderWidth","inner","h","w","outer","inRange","skipX","skipY","id","version","defaults","animations","numbers","type","dataElementType","overrides","interaction","intersect","scales","offset","reverse","MatrixElement","Element","radius","toTRBLCorners","borderRadius","save","beginPath","addRoundedRectPath","fillStyle","backgroundColor","fill","borderColor","restore","mouseX","mouseY","inXRange","inYRange","getCenterPoint","tooltipPosition","getRange","ax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SADFa,EAGMX,SAAW,CAClC9C,QAAS,SACTC,QAAS,SACTiE,qBAAiBgB,EACjBd,iBAAac,EACbrB,aAAc,EACd/B,iBAAaoD,EACbnF,OAAQ,GACRD,MAAO,ICbXqF,EAAAA,MAAMC,SAASrH,EAAkB0F"}
1
+ {"version":3,"file":"chartjs-chart-matrix.min.js","sources":["../src/controller.ts","../src/helpers.ts","../src/element.ts","../src/index.ts"],"sourcesContent":["import type { UpdateMode } from 'chart.js'\nimport type { AnchorX, AnchorY, MatrixParsedDataPoint } from '../types/index.esm'\nimport type MatrixElement from './element'\n\nimport { DatasetController } from 'chart.js'\n\nimport { version } from '../package.json'\n\nexport default class MatrixController extends DatasetController<\n 'matrix',\n MatrixElement,\n MatrixElement,\n MatrixParsedDataPoint\n> {\n static readonly id = 'matrix'\n static readonly version = version\n\n static readonly defaults = {\n animations: {\n numbers: {\n properties: ['x', 'y', 'width', 'height'],\n type: 'number',\n },\n },\n dataElementType: 'matrix',\n }\n\n static readonly overrides = {\n interaction: {\n intersect: true,\n mode: 'nearest',\n },\n scales: {\n x: {\n offset: true,\n type: 'linear',\n },\n y: {\n reverse: true,\n type: 'linear',\n },\n },\n }\n\n override initialize() {\n this.enableOptionSharing = true\n super.initialize()\n }\n\n override update(mode: UpdateMode) {\n const meta = this._cachedMeta\n\n this.updateElements(meta.data, 0, meta.data.length, mode)\n }\n\n override updateElements(rects: MatrixElement[], start: number, count: number, mode: UpdateMode) {\n const reset = mode === 'reset'\n const { xScale, yScale } = this._cachedMeta\n\n if (!xScale || !yScale) {\n return\n }\n\n const firstOpts = this.resolveDataElementOptions(start, mode)\n const sharedOptions = this.getSharedOptions(firstOpts)\n\n for (let i = start; i < start + count; i++) {\n let x: number\n let y: number\n\n if (reset) {\n x = xScale.getBasePixel()\n y = yScale.getBasePixel()\n } else {\n const parsed = this.getParsed(i)\n x = xScale.getPixelForValue(parsed.x)\n y = yScale.getPixelForValue(parsed.y)\n }\n\n const options = this.resolveDataElementOptions(i, mode)\n const { width, height, anchorX, anchorY } = options\n const properties = {\n height,\n options,\n width,\n x: resolveX(anchorX, x, width),\n y: resolveY(anchorY, y, height),\n }\n this.updateElement(rects[i], i, properties, mode)\n }\n\n if (sharedOptions) {\n this.updateSharedOptions(sharedOptions, mode, firstOpts)\n }\n }\n\n override draw() {\n const ctx = this.chart.ctx\n const data = this.getMeta().data || []\n let i: number, ilen: number\n\n for (i = 0, ilen = data.length; i < ilen; ++i) {\n data[i].draw(ctx)\n }\n }\n}\n\nfunction resolveX(anchorX: AnchorX, x: number, width: number) {\n if (anchorX === 'left' || anchorX === 'start') {\n return x\n }\n if (anchorX === 'right' || anchorX === 'end') {\n return x - width\n }\n return x - width / 2\n}\n\nfunction resolveY(anchorY: AnchorY, y: number, height: number) {\n if (anchorY === 'top' || anchorY === 'start') {\n return y\n }\n if (anchorY === 'bottom' || anchorY === 'end') {\n return y - height\n }\n return y - height / 2\n}\n","import type MatrixElement from './element'\n\nimport { isObject } from 'chart.js/helpers'\n\ntype Bounds = { left: number; top: number; right: number; bottom: number }\n\nfunction getBounds(element: MatrixElement, useFinalPosition: boolean): Bounds {\n const { x, y, width, height } = element.getProps(['x', 'y', 'width', 'height'], useFinalPosition)\n return { bottom: y + height, left: x, right: x + width, top: y }\n}\n\nfunction limit(value: number, min: number, max: number) {\n return Math.max(Math.min(value, max), min)\n}\n\ntype BorderWidthObject = {\n bottom?: number | null\n left?: number | null\n right?: number | null\n top?: number | null\n}\ntype BorderWidth = number | BorderWidthObject\ntype BorderWidthOptions = { borderWidth?: BorderWidth | null }\n\nconst borderValue = (value?: string | number | null): number => +(value ?? 0) || 0\n\nexport function parseBorderWidth(options: BorderWidthOptions, maxW: number, maxH: number) {\n const value = options.borderWidth\n let t: number, r: number, b: number, l: number\n\n if (value != null && isObject(value)) {\n t = borderValue(value.top)\n r = borderValue(value.right)\n b = borderValue(value.bottom)\n l = borderValue(value.left)\n } else {\n t = r = b = l = borderValue(value)\n }\n\n return {\n b: limit(b, 0, maxH),\n l: limit(l, 0, maxW),\n r: limit(r, 0, maxW),\n t: limit(t, 0, maxH),\n }\n}\n\nexport function boundingRects(element: MatrixElement) {\n const bounds = getBounds(element, false)\n const width = bounds.right - bounds.left\n const height = bounds.bottom - bounds.top\n const border = parseBorderWidth(element.options, width / 2, height / 2)\n\n return {\n inner: {\n h: height - border.t - border.b,\n w: width - border.l - border.r,\n x: bounds.left + border.l,\n y: bounds.top + border.t,\n },\n outer: {\n h: height,\n w: width,\n x: bounds.left,\n y: bounds.top,\n },\n }\n}\n\nexport function inRange(\n element: MatrixElement | null,\n x: number | null,\n y: number | null,\n useFinalPosition: boolean\n) {\n const skipX = x === null\n const skipY = y === null\n const bounds = !element || (skipX && skipY) ? false : getBounds(element, useFinalPosition)\n\n return (\n bounds &&\n (skipX || (x >= bounds.left && x <= bounds.right)) &&\n (skipY || (y >= bounds.top && y <= bounds.bottom))\n )\n}\n","import type { MatrixOptions, MatrixProps } from '../types/index.esm'\n\nimport { Element } from 'chart.js'\nimport { addRoundedRectPath, toTRBLCorners } from 'chart.js/helpers'\n\nimport { boundingRects, inRange } from './helpers'\n\nexport default class MatrixElement extends Element<MatrixProps, MatrixOptions> {\n static readonly id = 'matrix'\n\n static override readonly defaults = {\n anchorX: 'center',\n anchorY: 'center',\n backgroundColor: undefined,\n borderColor: undefined,\n borderRadius: 0,\n borderWidth: undefined,\n height: 20,\n width: 20,\n }\n\n width = MatrixElement.defaults.width\n height = MatrixElement.defaults.height\n\n constructor(cfg: MatrixProps) {\n super()\n\n if (cfg) {\n Object.assign(this, cfg)\n }\n }\n\n draw(ctx: CanvasRenderingContext2D) {\n const options = this.options\n const { inner, outer } = boundingRects(this)\n const radius = toTRBLCorners(options.borderRadius)\n\n ctx.save()\n\n if (outer.w !== inner.w || outer.h !== inner.h) {\n ctx.beginPath()\n addRoundedRectPath(ctx, { h: outer.h, radius, w: outer.w, x: outer.x, y: outer.y })\n addRoundedRectPath(ctx, { h: inner.h, radius, w: inner.w, x: inner.x, y: inner.y })\n ctx.fillStyle = options.backgroundColor\n ctx.fill()\n ctx.fillStyle = options.borderColor\n ctx.fill('evenodd')\n } else {\n ctx.beginPath()\n addRoundedRectPath(ctx, { h: inner.h, radius, w: inner.w, x: inner.x, y: inner.y })\n ctx.fillStyle = options.backgroundColor\n ctx.fill()\n }\n\n ctx.restore()\n }\n\n inRange(mouseX: number, mouseY: number, useFinalPosition?: boolean) {\n return inRange(this, mouseX, mouseY, useFinalPosition ?? false)\n }\n\n inXRange(mouseX: number, useFinalPosition?: boolean) {\n return inRange(this, mouseX, null, useFinalPosition ?? false)\n }\n\n inYRange(mouseY: number, useFinalPosition?: boolean) {\n return inRange(this, null, mouseY, useFinalPosition ?? false)\n }\n\n getCenterPoint(useFinalPosition?: boolean) {\n const { x, y, width, height } = this.getProps(['x', 'y', 'width', 'height'], useFinalPosition)\n return {\n x: x + width / 2,\n y: y + height / 2,\n }\n }\n\n override tooltipPosition() {\n return this.getCenterPoint()\n }\n\n getRange(axis: 'x' | 'y') {\n return axis === 'x' ? this.width / 2 : this.height / 2\n }\n}\n","import { Chart } from 'chart.js'\n\nimport MatrixController from './controller.js'\nimport MatrixElement from './element.js'\n\nChart.register(MatrixController, MatrixElement)\n\nexport { MatrixController, MatrixElement }\n"],"names":["MatrixController","DatasetController","initialize","this","enableOptionSharing","super","update","mode","meta","_cachedMeta","updateElements","data","length","rects","start","count","reset","xScale","yScale","firstOpts","resolveDataElementOptions","sharedOptions","getSharedOptions","i","x","y","getBasePixel","parsed","getParsed","getPixelForValue","options","width","height","anchorX","anchorY","properties","resolveX","resolveY","updateElement","updateSharedOptions","draw","ctx","chart","getMeta","ilen","getBounds","element","useFinalPosition","getProps","bottom","left","right","top","limit","value","min","max","Math","id","version","defaults","animations","numbers","type","dataElementType","overrides","interaction","intersect","scales","offset","reverse","borderValue","boundingRects","bounds","border","maxW","maxH","borderWidth","t","r","b","l","isObject","parseBorderWidth","inner","h","w","outer","inRange","skipX","skipY","MatrixElement","Element","radius","toTRBLCorners","borderRadius","save","beginPath","addRoundedRectPath","fillStyle","backgroundColor","fill","borderColor","restore","mouseX","mouseY","inXRange","inYRange","getCenterPoint","tooltipPosition","getRange","axis","constructor","cfg","Object","assign","undefined","Chart","register"],"mappings":";;;;;;wWAQe,MAAMA,UAAyBC,EAAAA,kBAoCnCC,UAAAA,GACPC,KAAKC,qBAAsB,EAC3BC,MAAMH,YACR,CAESI,MAAAA,CAAOC,GACd,MAAMC,EAAOL,KAAKM,YAElBN,KAAKO,eAAeF,EAAKG,KAAM,EAAGH,EAAKG,KAAKC,OAAQL,EACtD,CAESG,cAAAA,CAAeG,EAAwBC,EAAeC,EAAeR,GAC5E,MAAMS,EAAiB,UAATT,GACRU,OAAEA,EAAMC,OAAEA,GAAWf,KAAKM,YAEhC,IAAKQ,IAAWC,EACd,OAGF,MAAMC,EAAYhB,KAAKiB,0BAA0BN,EAAOP,GAClDc,EAAgBlB,KAAKmB,iBAAiBH,GAE5C,IAAK,IAAII,EAAIT,EAAOS,EAAIT,EAAQC,EAAOQ,IAAK,CAC1C,IAAIC,EACAC,EAEJ,GAAIT,EACFQ,EAAIP,EAAOS,eACXD,EAAIP,EAAOQ,mBACN,CACL,MAAMC,EAASxB,KAAKyB,UAAUL,GAC9BC,EAAIP,EAAOY,iBAAiBF,EAAOH,GACnCC,EAAIP,EAAOW,iBAAiBF,EAAOF,EACrC,CAEA,MAAMK,EAAU3B,KAAKiB,0BAA0BG,EAAGhB,IAC5CwB,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,EAAOC,QAAEA,GAAYJ,EACtCK,EAAa,CACjBH,SACAF,UACAC,QACAP,EAAGY,EAASH,EAAST,EAAGO,GACxBN,EAAGY,EAASH,EAAST,EAAGO,IAE1B7B,KAAKmC,cAAczB,EAAMU,GAAIA,EAAGY,EAAY5B,EAC9C,CAEIc,GACFlB,KAAKoC,oBAAoBlB,EAAed,EAAMY,EAElD,CAESqB,IAAAA,GACP,MAAMC,EAAMtC,KAAK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AC,IAAK,IAAK,QAAS,UAAWD,GAC7E,MAAO,CACLvB,EAAGA,EAAIO,EAAQ,EACfN,EAAGA,EAAIO,EAAS,EAEpB,CAES6E,eAAAA,GACP,OAAO1G,KAAKyG,gBACd,CAEAE,QAAAA,CAASC,GACP,MAAgB,MAATA,EAAe5G,KAAK4B,MAAQ,EAAI5B,KAAK6B,OAAS,CACvD,CA3DA,WAAAgF,CAAYC,GACV5G,QAAKF,KAJP4B,MAAQ4D,EAAc/B,SAAS7B,MAAK5B,KACpC6B,OAAS2D,EAAc/B,SAAS5B,OAK1BiF,GACFC,OAAOC,OAAOhH,KAAM8G,EAExB,EAvBmBtB,EACHjC,GAAK,SADFiC,EAGM/B,SAAW,CAClC3B,QAAS,SACTC,QAAS,SACTkE,qBAAiBgB,EACjBd,iBAAac,EACbrB,aAAc,EACdlB,iBAAauC,EACbpF,OAAQ,GACRD,MAAO,ICbXsF,EAAAA,MAAMC,SAAStH,EAAkB2F"}
package/package.json CHANGED
@@ -6,11 +6,13 @@
6
6
  "description": "Chart.js module for creating matrix charts",
7
7
  "devDependencies": {
8
8
  "@astrojs/check": "^0.9.9",
9
- "@astrojs/mdx": "^5.0.4",
10
- "@astrojs/starlight": "^0.38.4",
9
+ "@astrojs/mdx": "^7.0.2",
10
+ "@astrojs/starlight": "^0.41.3",
11
11
  "@biomejs/biome": "^2.4.14",
12
+ "@emnapi/core": "^1.11.2",
13
+ "@emnapi/runtime": "^1.11.2",
12
14
  "@kurkle/configs": "^1.0.1",
13
- "@napi-rs/canvas": "^0.1.30",
15
+ "@napi-rs/canvas": "^1.0.0",
14
16
  "@rollup/plugin-commonjs": "^29.0.0",
15
17
  "@rollup/plugin-json": "^6.0.0",
16
18
  "@rollup/plugin-node-resolve": "^16.0.1",
@@ -19,15 +21,15 @@
19
21
  "@swc/cli": "^0.8.1",
20
22
  "@swc/core": "^1.11.9",
21
23
  "@types/jasmine": "^6.0.0",
22
- "@types/node": "^25.0.3",
23
- "astro": "^6.2.1",
24
+ "@types/node": "^26.0.0",
25
+ "astro": "^7.0.6",
24
26
  "c8": "^11.0.0",
25
27
  "chart.js": "^4.0.1",
26
28
  "chartjs-adapter-date-fns": "^3.0.0",
27
29
  "chartjs-test-utils": "^0.5.0",
28
- "concurrently": "^9.0.1",
30
+ "concurrently": "^10.0.3",
29
31
  "cross-env": "^10.1.0",
30
- "date-fns": "^2.30.0",
32
+ "date-fns": "^4.3.0",
31
33
  "globals": "^17.0.0",
32
34
  "jasmine": "^6.2.0",
33
35
  "jasmine-core": "^6.2.0",
@@ -44,7 +46,7 @@
44
46
  "rollup-plugin-cleanup": "^3.2.1",
45
47
  "rollup-plugin-istanbul": "^5.0.0",
46
48
  "semantic-release": "^25.0.3",
47
- "typescript": "^5.9.3"
49
+ "typescript": "^6.0.3"
48
50
  },
49
51
  "exports": {
50
52
  "import": "./dist/chartjs-chart-matrix.esm.js",
@@ -102,5 +104,5 @@
102
104
  "type": "module",
103
105
  "types": "types/index.esm.d.ts",
104
106
  "unpkg": "dist/chartjs-chart-matrix.min.js",
105
- "version": "3.0.3"
107
+ "version": "3.0.5"
106
108
  }
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  BorderRadius,
3
3
  CartesianScaleTypeRegistry,
4
4
  Chart,
@@ -32,6 +32,12 @@ export interface MatrixControllerDatasetOptions
32
32
  ScriptableAndArrayOptions<CommonHoverOptions, ScriptableContext<'matrix'>> {}
33
33
 
34
34
  export interface MatrixDataPoint {
35
+ x: number | string
36
+ y: number | string
37
+ v?: number
38
+ }
39
+
40
+ export interface MatrixParsedDataPoint {
35
41
  x: number
36
42
  y: number
37
43
  }
@@ -42,7 +48,7 @@ declare module 'chart.js' {
42
48
  chartOptions: CoreChartOptions<'matrix'>
43
49
  datasetOptions: MatrixControllerDatasetOptions
44
50
  defaultDataPoint: MatrixDataPoint
45
- parsedDataType: MatrixDataPoint
51
+ parsedDataType: MatrixParsedDataPoint
46
52
  metaExtensions: AnyObject
47
53
  scales: keyof CartesianScaleTypeRegistry
48
54
  }
@@ -58,7 +64,7 @@ export interface MatrixProps {
58
64
  }
59
65
 
60
66
  export type MatrixController = DatasetController
61
- export const MatrixController: ChartComponent & {
67
+ export declare const MatrixController: ChartComponent & {
62
68
  prototype: MatrixController
63
69
  new (chart: Chart, datasetIndex: number): MatrixController
64
70
  }
@@ -69,7 +75,7 @@ export interface MatrixElement<
69
75
  > extends Element<T, O>,
70
76
  VisualElement {}
71
77
 
72
- export const MatrixElement: ChartComponent & {
78
+ export declare const MatrixElement: ChartComponent & {
73
79
  prototype: MatrixElement
74
80
  new (cfg: AnyObject): MatrixElement
75
81
  }