chartjs-chart-matrix 3.0.1 → 3.0.3

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.
@@ -33,11 +33,11 @@ class MatrixController extends chart_js.DatasetController {
33
33
  const options = this.resolveDataElementOptions(i, mode);
34
34
  const { width, height, anchorX, anchorY } = options;
35
35
  const properties = {
36
- x: resolveX(anchorX, x, width),
37
- y: resolveY(anchorY, y, height),
38
- width,
39
36
  height,
40
- options
37
+ options,
38
+ width,
39
+ x: resolveX(anchorX, x, width),
40
+ y: resolveY(anchorY, y, height)
41
41
  };
42
42
  this.updateElement(rects[i], i, properties, mode);
43
43
  }
@@ -55,32 +55,32 @@ class MatrixController extends chart_js.DatasetController {
55
55
  MatrixController.id = 'matrix';
56
56
  MatrixController.version = version;
57
57
  MatrixController.defaults = {
58
- dataElementType: 'matrix',
59
58
  animations: {
60
59
  numbers: {
61
- type: 'number',
62
60
  properties: [
63
61
  'x',
64
62
  'y',
65
63
  'width',
66
64
  'height'
67
- ]
65
+ ],
66
+ type: 'number'
68
67
  }
69
- }
68
+ },
69
+ dataElementType: 'matrix'
70
70
  };
71
71
  MatrixController.overrides = {
72
72
  interaction: {
73
- mode: 'nearest',
74
- intersect: true
73
+ intersect: true,
74
+ mode: 'nearest'
75
75
  },
76
76
  scales: {
77
77
  x: {
78
- type: 'linear',
79
- offset: true
78
+ offset: true,
79
+ type: 'linear'
80
80
  },
81
81
  y: {
82
- type: 'linear',
83
- reverse: true
82
+ reverse: true,
83
+ type: 'linear'
84
84
  }
85
85
  }
86
86
  };
@@ -111,10 +111,10 @@ function getBounds(element, useFinalPosition) {
111
111
  'height'
112
112
  ], useFinalPosition);
113
113
  return {
114
+ bottom: y + height,
114
115
  left: x,
115
- top: y,
116
116
  right: x + width,
117
- bottom: y + height
117
+ top: y
118
118
  };
119
119
  }
120
120
  function limit(value, min, max) {
@@ -132,10 +132,10 @@ function parseBorderWidth(options, maxW, maxH) {
132
132
  t = r = b = l = +value || 0;
133
133
  }
134
134
  return {
135
- t: limit(t, 0, maxH),
136
- r: limit(r, 0, maxW),
137
135
  b: limit(b, 0, maxH),
138
- l: limit(l, 0, maxW)
136
+ l: limit(l, 0, maxW),
137
+ r: limit(r, 0, maxW),
138
+ t: limit(t, 0, maxH)
139
139
  };
140
140
  }
141
141
  function boundingRects(element) {
@@ -144,17 +144,17 @@ function boundingRects(element) {
144
144
  const height = bounds.bottom - bounds.top;
145
145
  const border = parseBorderWidth(element.options, width / 2, height / 2);
146
146
  return {
147
- outer: {
148
- x: bounds.left,
149
- y: bounds.top,
150
- w: width,
151
- h: height
152
- },
153
147
  inner: {
154
- x: bounds.left + border.l,
155
- y: bounds.top + border.t,
148
+ h: height - border.t - border.b,
156
149
  w: width - border.l - border.r,
157
- h: height - border.t - border.b
150
+ x: bounds.left + border.l,
151
+ y: bounds.top + border.t
152
+ },
153
+ outer: {
154
+ h: height,
155
+ w: width,
156
+ x: bounds.left,
157
+ y: bounds.top
158
158
  }
159
159
  };
160
160
  }
@@ -174,18 +174,18 @@ class MatrixElement extends chart_js.Element {
174
174
  if (outer.w !== inner.w || outer.h !== inner.h) {
175
175
  ctx.beginPath();
176
176
  helpers.addRoundedRectPath(ctx, {
177
- x: outer.x,
178
- y: outer.y,
179
- w: outer.w,
180
177
  h: outer.h,
181
- radius
178
+ radius,
179
+ w: outer.w,
180
+ x: outer.x,
181
+ y: outer.y
182
182
  });
183
183
  helpers.addRoundedRectPath(ctx, {
184
- x: inner.x,
185
- y: inner.y,
186
- w: inner.w,
187
184
  h: inner.h,
188
- radius
185
+ radius,
186
+ w: inner.w,
187
+ x: inner.x,
188
+ y: inner.y
189
189
  });
190
190
  ctx.fillStyle = options.backgroundColor;
191
191
  ctx.fill();
@@ -194,11 +194,11 @@ class MatrixElement extends chart_js.Element {
194
194
  } else {
195
195
  ctx.beginPath();
196
196
  helpers.addRoundedRectPath(ctx, {
197
- x: inner.x,
198
- y: inner.y,
199
- w: inner.w,
200
197
  h: inner.h,
201
- radius
198
+ radius,
199
+ w: inner.w,
200
+ x: inner.x,
201
+ y: inner.y
202
202
  });
203
203
  ctx.fillStyle = options.backgroundColor;
204
204
  ctx.fill();
@@ -241,14 +241,14 @@ class MatrixElement extends chart_js.Element {
241
241
  }
242
242
  MatrixElement.id = 'matrix';
243
243
  MatrixElement.defaults = {
244
+ anchorX: 'center',
245
+ anchorY: 'center',
244
246
  backgroundColor: undefined,
245
247
  borderColor: undefined,
246
- borderWidth: undefined,
247
248
  borderRadius: 0,
248
- anchorX: 'center',
249
- anchorY: 'center',
250
- width: 20,
251
- height: 20
249
+ borderWidth: undefined,
250
+ height: 20,
251
+ width: 20
252
252
  };
253
253
 
254
254
  chart_js.Chart.register(MatrixController, MatrixElement);
@@ -30,11 +30,11 @@ class MatrixController extends DatasetController {
30
30
  const options = this.resolveDataElementOptions(i, mode);
31
31
  const { width, height, anchorX, anchorY } = options;
32
32
  const properties = {
33
- x: resolveX(anchorX, x, width),
34
- y: resolveY(anchorY, y, height),
35
- width,
36
33
  height,
37
- options
34
+ options,
35
+ width,
36
+ x: resolveX(anchorX, x, width),
37
+ y: resolveY(anchorY, y, height)
38
38
  };
39
39
  this.updateElement(rects[i], i, properties, mode);
40
40
  }
@@ -52,32 +52,32 @@ class MatrixController extends DatasetController {
52
52
  MatrixController.id = 'matrix';
53
53
  MatrixController.version = version;
54
54
  MatrixController.defaults = {
55
- dataElementType: 'matrix',
56
55
  animations: {
57
56
  numbers: {
58
- type: 'number',
59
57
  properties: [
60
58
  'x',
61
59
  'y',
62
60
  'width',
63
61
  'height'
64
- ]
62
+ ],
63
+ type: 'number'
65
64
  }
66
- }
65
+ },
66
+ dataElementType: 'matrix'
67
67
  };
68
68
  MatrixController.overrides = {
69
69
  interaction: {
70
- mode: 'nearest',
71
- intersect: true
70
+ intersect: true,
71
+ mode: 'nearest'
72
72
  },
73
73
  scales: {
74
74
  x: {
75
- type: 'linear',
76
- offset: true
75
+ offset: true,
76
+ type: 'linear'
77
77
  },
78
78
  y: {
79
- type: 'linear',
80
- reverse: true
79
+ reverse: true,
80
+ type: 'linear'
81
81
  }
82
82
  }
83
83
  };
@@ -108,10 +108,10 @@ function getBounds(element, useFinalPosition) {
108
108
  'height'
109
109
  ], useFinalPosition);
110
110
  return {
111
+ bottom: y + height,
111
112
  left: x,
112
- top: y,
113
113
  right: x + width,
114
- bottom: y + height
114
+ top: y
115
115
  };
116
116
  }
117
117
  function limit(value, min, max) {
@@ -129,10 +129,10 @@ function parseBorderWidth(options, maxW, maxH) {
129
129
  t = r = b = l = +value || 0;
130
130
  }
131
131
  return {
132
- t: limit(t, 0, maxH),
133
- r: limit(r, 0, maxW),
134
132
  b: limit(b, 0, maxH),
135
- l: limit(l, 0, maxW)
133
+ l: limit(l, 0, maxW),
134
+ r: limit(r, 0, maxW),
135
+ t: limit(t, 0, maxH)
136
136
  };
137
137
  }
138
138
  function boundingRects(element) {
@@ -141,17 +141,17 @@ function boundingRects(element) {
141
141
  const height = bounds.bottom - bounds.top;
142
142
  const border = parseBorderWidth(element.options, width / 2, height / 2);
143
143
  return {
144
- outer: {
145
- x: bounds.left,
146
- y: bounds.top,
147
- w: width,
148
- h: height
149
- },
150
144
  inner: {
151
- x: bounds.left + border.l,
152
- y: bounds.top + border.t,
145
+ h: height - border.t - border.b,
153
146
  w: width - border.l - border.r,
154
- h: height - border.t - border.b
147
+ x: bounds.left + border.l,
148
+ y: bounds.top + border.t
149
+ },
150
+ outer: {
151
+ h: height,
152
+ w: width,
153
+ x: bounds.left,
154
+ y: bounds.top
155
155
  }
156
156
  };
157
157
  }
@@ -171,18 +171,18 @@ class MatrixElement extends Element {
171
171
  if (outer.w !== inner.w || outer.h !== inner.h) {
172
172
  ctx.beginPath();
173
173
  addRoundedRectPath(ctx, {
174
- x: outer.x,
175
- y: outer.y,
176
- w: outer.w,
177
174
  h: outer.h,
178
- radius
175
+ radius,
176
+ w: outer.w,
177
+ x: outer.x,
178
+ y: outer.y
179
179
  });
180
180
  addRoundedRectPath(ctx, {
181
- x: inner.x,
182
- y: inner.y,
183
- w: inner.w,
184
181
  h: inner.h,
185
- radius
182
+ radius,
183
+ w: inner.w,
184
+ x: inner.x,
185
+ y: inner.y
186
186
  });
187
187
  ctx.fillStyle = options.backgroundColor;
188
188
  ctx.fill();
@@ -191,11 +191,11 @@ class MatrixElement extends Element {
191
191
  } else {
192
192
  ctx.beginPath();
193
193
  addRoundedRectPath(ctx, {
194
- x: inner.x,
195
- y: inner.y,
196
- w: inner.w,
197
194
  h: inner.h,
198
- radius
195
+ radius,
196
+ w: inner.w,
197
+ x: inner.x,
198
+ y: inner.y
199
199
  });
200
200
  ctx.fillStyle = options.backgroundColor;
201
201
  ctx.fill();
@@ -238,14 +238,14 @@ class MatrixElement extends Element {
238
238
  }
239
239
  MatrixElement.id = 'matrix';
240
240
  MatrixElement.defaults = {
241
+ anchorX: 'center',
242
+ anchorY: 'center',
241
243
  backgroundColor: undefined,
242
244
  borderColor: undefined,
243
- borderWidth: undefined,
244
245
  borderRadius: 0,
245
- anchorX: 'center',
246
- anchorY: 'center',
247
- width: 20,
248
- height: 20
246
+ borderWidth: undefined,
247
+ height: 20,
248
+ width: 20
249
249
  };
250
250
 
251
251
  export { MatrixController, MatrixElement };
@@ -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={x:n(p,r,c),y:o(f,d,g),width:c,height:g,options:u};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{left:r,top:i,right:r+n,bottom:i+o}}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,{t:a(o,0,i),r:a(s,0,e),b:a(h,0,i),l:a(l,0,e)}}(t.options,i/2,n/2);return{outer:{x:e.left,y:e.top,w:i,h:n},inner:{x:e.left+o.l,y:e.top+o.t,w:i-o.l-o.r,h:n-o.t-o.b}}}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={dataElementType:"matrix",animations:{numbers:{type:"number",properties:["x","y","width","height"]}}},i.overrides={interaction:{mode:"nearest",intersect:!0},scales:{x:{type:"linear",offset:!0},y:{type:"linear",reverse:!0}}};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,{x:n.x,y:n.y,w:n.w,h:n.h,radius:o}),r.addRoundedRectPath(t,{x:i.x,y:i.y,w:i.w,h:i.h,radius:o}),t.fillStyle=e.backgroundColor,t.fill(),t.fillStyle=e.borderColor,t.fill("evenodd")):(t.beginPath(),r.addRoundedRectPath(t,{x:i.x,y:i.y,w:i.w,h:i.h,radius:o}),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={backgroundColor:void 0,borderColor:void 0,borderWidth:void 0,borderRadius:0,anchorX:"center",anchorY:"center",width:20,height: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,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});
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 { DatasetController, UpdateMode } from 'chart.js'\nimport { AnchorX, AnchorY, MatrixControllerDatasetOptions, MatrixDataPoint } from 'types/index.esm'\n\nimport { version } from '../package.json'\n\nimport MatrixElement from './element'\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 dataElementType: 'matrix',\n\n animations: {\n numbers: {\n type: 'number',\n properties: ['x', 'y', 'width', 'height'],\n },\n },\n }\n\n static readonly overrides = {\n interaction: {\n mode: 'nearest',\n intersect: true,\n },\n scales: {\n x: {\n type: 'linear',\n offset: true,\n },\n y: {\n type: 'linear',\n reverse: true,\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 x: resolveX(anchorX, x, width),\n y: resolveY(anchorY, y, height),\n width,\n height,\n options,\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 { isObject } from 'chart.js/helpers'\nimport { MatrixOptions } from 'types/index.esm'\n\nimport MatrixElement from './element'\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 { left: x, top: y, right: x + width, bottom: y + height }\n}\n\nfunction limit(value: number, min: number, max: number) {\n return Math.max(Math.min(value, max), min)\n}\n\nexport function parseBorderWidth(options: Pick<MatrixOptions, 'borderWidth'>, maxW: number, maxH: number) {\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 t: limit(t, 0, maxH),\n r: limit(r, 0, maxW),\n b: limit(b, 0, maxH),\n l: limit(l, 0, maxW),\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 outer: {\n x: bounds.left,\n y: bounds.top,\n w: width,\n h: height,\n },\n inner: {\n x: bounds.left + border.l,\n y: bounds.top + border.t,\n w: width - border.l - border.r,\n h: height - border.t - border.b,\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 && (skipX || (x >= bounds.left && x <= bounds.right)) && (skipY || (y >= bounds.top && y <= bounds.bottom))\n )\n}\n","import { Element } from 'chart.js'\nimport { addRoundedRectPath, toTRBLCorners } from 'chart.js/helpers'\nimport { MatrixOptions, MatrixProps } from 'types/index.esm'\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 backgroundColor: undefined,\n borderColor: undefined,\n borderWidth: undefined,\n borderRadius: 0,\n anchorX: 'center',\n anchorY: 'center',\n width: 20,\n height: 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, { x: outer.x, y: outer.y, w: outer.w, h: outer.h, radius })\n addRoundedRectPath(ctx, { x: inner.x, y: inner.y, w: inner.w, h: inner.h, radius })\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, { x: inner.x, y: inner.y, w: inner.w, h: inner.h, radius })\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","left","top","right","bottom","limit","value","min","max","Math","boundingRects","bounds","border","maxW","maxH","borderWidth","t","r","b","l","isObject","parseBorderWidth","outer","w","h","inner","inRange","skipX","skipY","id","version","defaults","dataElementType","animations","numbers","type","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","axis","constructor","cfg","Object","assign","undefined","Chart","register"],"mappings":";;;;;;wWAOe,MAAMA,UAAyBC,EAAAA,kBAuCnCC,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,YAC1BU,EAAYhB,KAAKiB,0BAA0BN,EAAOP,GAClDc,EAAgBlB,KAAKmB,iBAAiBH,GAE5C,IAAK,IAAII,EAAIT,EAAOS,EAAIT,EAAQC,EAAOQ,IAAK,CAC1C,MAAMC,GAAUR,GAASb,KAAKsB,UAAUF,GAClCG,EAAIV,EAAQC,EAAOU,eAAiBV,EAAOW,iBAAiBJ,EAAOE,GACnEG,EAAIb,EAAQE,EAAOS,eAAiBT,EAAOU,iBAAiBJ,EAAOK,GACnEC,EAAU3B,KAAKiB,0BAA0BG,EAAGhB,IAC5CwB,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,EAAOC,QAAEA,GAAYJ,EACtCK,EAAa,CACjBT,EAAGU,EAASH,EAASP,EAAGK,GACxBF,EAAGQ,EAASH,EAASL,EAAGG,GACxBD,QACAC,SACAF,WAEF3B,KAAKmC,cAAczB,EAAMU,GAAIA,EAAGY,EAAY5B,EAC9C,CAEAJ,KAAKoC,oBAAoBlB,EAAed,EAAMY,EAChD,CAESqB,IAAAA,GACP,MAAMC,EAAMtC,KAAKuC,MAAMD,IACjB9B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,QAAAA,CAASC,GACP,MAAgB,MAATA,EAAe3G,KAAK4B,MAAQ,EAAI5B,KAAK6B,OAAS,CACvD,CA3DA,WAAA+E,CAAYC,GACV3G,QAEI2G,GACFC,OAAOC,OAAO/G,KAAM6G,EAExB,EAvBmBtB,EACHb,GAAK,SADFa,EAGMX,SAAW,CAClCoB,qBAAiBgB,EACjBd,iBAAac,EACbpD,iBAAaoD,EACbrB,aAAc,EACd7D,QAAS,SACTC,QAAS,SACTH,MAAO,GACPC,OAAQ,ICZZoF,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 {\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","axis","constructor","cfg","Object","assign","undefined","Chart","register"],"mappings":";;;;;;wWAae,MAAMA,UAAyBC,EAAAA,kBAsCnCC,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,YAC1BU,EAAYhB,KAAKiB,0BAA0BN,EAAOP,GAClDc,EAAgBlB,KAAKmB,iBAAiBH,GAE5C,IAAK,IAAII,EAAIT,EAAOS,EAAIT,EAAQC,EAAOQ,IAAK,CAC1C,MAAMC,GAAUR,GAASb,KAAKsB,UAAUF,GAClCG,EAAIV,EAAQC,EAAOU,eAAiBV,EAAOW,iBAAiBJ,EAAOE,GACnEG,EAAIb,EAAQE,EAAOS,eAAiBT,EAAOU,iBAAiBJ,EAAOK,GACnEC,EAAU3B,KAAKiB,0BAA0BG,EAAGhB,IAC5CwB,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,EAAOC,QAAEA,GAAYJ,EACtCK,EAAa,CACjBH,SACAF,UACAC,QACAL,EAAGU,EAASH,EAASP,EAAGK,GACxBF,EAAGQ,EAASH,EAASL,EAAGG,IAE1B7B,KAAKmC,cAAczB,EAAMU,GAAIA,EAAGY,EAAY5B,EAC9C,CAEAJ,KAAKoC,oBAAoBlB,EAAed,EAAMY,EAChD,CAESqB,IAAAA,GACP,MAAMC,EAAMtC,KAAKuC,MAAMD,IACjB9B,EAAOR,KAAKwC,UAAUhC,MAAQ,GACpC,IAAIY,EAAWqB,EAEf,IAAKrB,EAAI,EAAGqB,EAAOjC,EAAKC,OAAQW,E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GACV3G,QAEI2G,GACFC,OAAOC,OAAO/G,KAAM6G,EAExB,EAvBmBtB,EACHb,GAAK,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"}
package/package.json CHANGED
@@ -1,89 +1,36 @@
1
1
  {
2
- "name": "chartjs-chart-matrix",
3
- "version": "3.0.1",
4
- "description": "Chart.js module for creating matrix charts",
5
- "type": "module",
6
- "main": "dist/chartjs-chart-matrix.cjs",
7
- "module": "dist/chartjs-chart-matrix.esm.js",
8
- "types": "types/index.esm.d.ts",
9
- "jsdelivr": "dist/chartjs-chart-matrix.min.js",
10
- "unpkg": "dist/chartjs-chart-matrix.min.js",
11
- "exports": {
12
- "types": "./types/index.esm.d.ts",
13
- "import": "./dist/chartjs-chart-matrix.esm.js",
14
- "require": "./dist/chartjs-chart-matrix.cjs",
15
- "script": "./dist/chartjs-chart-matrix.min.js"
16
- },
17
- "sideEffects": [
18
- "dist/chartjs-chart-matrix.cjs",
19
- "dist/chartjs-chart-matrix-min.js"
20
- ],
21
- "scripts": {
22
- "autobuild": "rollup -c -w",
23
- "build": "rollup -c",
24
- "dev": "karma start ./karma.conf.cjs --no-single-run --auto-watch --browsers chrome",
25
- "dev:ff": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers firefox",
26
- "docs": "npm run build && vuepress build docs --no-cache",
27
- "docs:dev": "npm run build && vuepress dev docs --no-cache",
28
- "lint": "eslint",
29
- "typecheck": "tsc --noEmit && tsc --noEmit -p types/tests/",
30
- "test": "cross-env NODE_ENV=test concurrently \"npm:test-*\"",
31
- "pretest-unit": "swc --config-file .swcrc-spec src -d build",
32
- "test-unit": "cross-env JASMINE_CONFIG_PATH=jasmine.json c8 --src=src --reporter=text --reporter=lcov -o=coverage/unit jasmine",
33
- "test-karma": "karma start ./karma.conf.cjs --no-auto-watch --single-run",
34
- "test-integration:node-commonjs": "npm run test --prefix test/integration/node-commonjs",
35
- "test-integration:node-module": "npm run test --prefix test/integration/node-module"
36
- },
37
- "repository": {
38
- "type": "git",
39
- "url": "git+https://github.com/kurkle/chartjs-chart-matrix.git"
40
- },
41
- "keywords": [
42
- "chart.js",
43
- "chart",
44
- "matrix"
45
- ],
46
- "files": [
47
- "dist/*",
48
- "!dist/docs/**",
49
- "types/index.esm.d.ts"
50
- ],
51
2
  "author": "Jukka Kurkela",
52
- "license": "MIT",
53
3
  "bugs": {
54
4
  "url": "https://github.com/kurkle/chartjs-chart-matrix/issues"
55
5
  },
56
- "homepage": "https://chartjs-chart-matrix.pages.dev/",
6
+ "description": "Chart.js module for creating matrix charts",
57
7
  "devDependencies": {
58
- "@eslint/js": "^9.22.0",
8
+ "@astrojs/check": "^0.9.9",
9
+ "@astrojs/mdx": "^5.0.4",
10
+ "@astrojs/starlight": "^0.38.4",
11
+ "@biomejs/biome": "^2.4.14",
12
+ "@kurkle/configs": "^1.0.1",
59
13
  "@napi-rs/canvas": "^0.1.30",
60
14
  "@rollup/plugin-commonjs": "^29.0.0",
61
15
  "@rollup/plugin-json": "^6.0.0",
62
16
  "@rollup/plugin-node-resolve": "^16.0.1",
63
17
  "@rollup/plugin-swc": "^0.4.0",
64
- "@rollup/plugin-terser": "^0.4.4",
65
- "@swc/cli": "^0.7.9",
18
+ "@rollup/plugin-terser": "^1.0.0",
19
+ "@swc/cli": "^0.8.1",
66
20
  "@swc/core": "^1.11.9",
67
- "@types/jasmine": "^5.1.7",
21
+ "@types/jasmine": "^6.0.0",
68
22
  "@types/node": "^25.0.3",
69
- "@typescript-eslint/eslint-plugin": "^8.26.1",
70
- "@typescript-eslint/parser": "^8.26.1",
71
- "c8": "^10.1.3",
23
+ "astro": "^6.2.1",
24
+ "c8": "^11.0.0",
72
25
  "chart.js": "^4.0.1",
73
26
  "chartjs-adapter-date-fns": "^3.0.0",
74
27
  "chartjs-test-utils": "^0.5.0",
75
28
  "concurrently": "^9.0.1",
76
29
  "cross-env": "^10.1.0",
77
- "date-fns": "^2.19.0",
78
- "eslint": "^9.22.0",
79
- "eslint-config-chartjs": "^0.3.0",
80
- "eslint-config-prettier": "^10.1.1",
81
- "eslint-plugin-prettier": "^5.2.3",
82
- "eslint-plugin-simple-import-sort": "^12.1.1",
83
- "eslint-plugin-unused-imports": "^4.1.4",
30
+ "date-fns": "^2.30.0",
84
31
  "globals": "^17.0.0",
85
- "jasmine": "^5.6.0",
86
- "jasmine-core": "^5.1.2",
32
+ "jasmine": "^6.2.0",
33
+ "jasmine-core": "^6.2.0",
87
34
  "karma": "^6.2.0",
88
35
  "karma-chrome-launcher": "^3.1.0",
89
36
  "karma-coverage": "^2.0.3",
@@ -97,13 +44,63 @@
97
44
  "rollup-plugin-cleanup": "^3.2.1",
98
45
  "rollup-plugin-istanbul": "^5.0.0",
99
46
  "semantic-release": "^25.0.3",
100
- "typescript": "^5.3.3",
101
- "vuepress": "^1.9.7",
102
- "vuepress-plugin-flexsearch": "^0.3.0",
103
- "vuepress-plugin-redirect": "^1.2.5",
104
- "vuepress-theme-chartjs": "^0.2.0"
47
+ "typescript": "^5.9.3"
105
48
  },
49
+ "exports": {
50
+ "import": "./dist/chartjs-chart-matrix.esm.js",
51
+ "require": "./dist/chartjs-chart-matrix.cjs",
52
+ "script": "./dist/chartjs-chart-matrix.min.js",
53
+ "types": "./types/index.esm.d.ts"
54
+ },
55
+ "files": [
56
+ "dist/*",
57
+ "!dist/docs/**",
58
+ "types/index.esm.d.ts"
59
+ ],
60
+ "homepage": "https://chartjs-chart-matrix.pages.dev/",
61
+ "jsdelivr": "dist/chartjs-chart-matrix.min.js",
62
+ "keywords": [
63
+ "chart.js",
64
+ "chart",
65
+ "matrix"
66
+ ],
67
+ "license": "MIT",
68
+ "main": "dist/chartjs-chart-matrix.cjs",
69
+ "module": "dist/chartjs-chart-matrix.esm.js",
70
+ "name": "chartjs-chart-matrix",
106
71
  "peerDependencies": {
107
72
  "chart.js": ">=3.0.0"
108
- }
73
+ },
74
+ "repository": {
75
+ "type": "git",
76
+ "url": "git+https://github.com/kurkle/chartjs-chart-matrix.git"
77
+ },
78
+ "scripts": {
79
+ "autobuild": "rollup -c -w",
80
+ "build": "rollup -c",
81
+ "dev": "karma start ./karma.conf.cjs --no-single-run --auto-watch --browsers chrome",
82
+ "dev:ff": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers firefox",
83
+ "docs": "npm run build && astro build",
84
+ "docs:dev": "npm run build && astro dev",
85
+ "docs:version": "node ./docs/scripts/write-docs-version.cjs",
86
+ "lint": "biome check",
87
+ "predocs": "npm run docs:version",
88
+ "predocs:dev": "npm run docs:version",
89
+ "pretest-unit": "swc --config-file .swcrc-spec src -d build",
90
+ "test": "cross-env NODE_ENV=test concurrently \"npm:test-*\"",
91
+ "test-integration:node-commonjs": "npm run test --prefix test/integration/node-commonjs",
92
+ "test-integration:node-module": "npm run test --prefix test/integration/node-module",
93
+ "test-karma": "karma start ./karma.conf.cjs --no-auto-watch --single-run",
94
+ "test-unit": "cross-env JASMINE_CONFIG_PATH=jasmine.json c8 --src=src --reporter=text --reporter=lcov -o=coverage/unit jasmine",
95
+ "typecheck": "tsc --noEmit && tsc --noEmit -p types/tests/",
96
+ "typecheck:docs": "astro check"
97
+ },
98
+ "sideEffects": [
99
+ "dist/chartjs-chart-matrix.cjs",
100
+ "dist/chartjs-chart-matrix-min.js"
101
+ ],
102
+ "type": "module",
103
+ "types": "types/index.esm.d.ts",
104
+ "unpkg": "dist/chartjs-chart-matrix.min.js",
105
+ "version": "3.0.3"
109
106
  }
@@ -27,8 +27,7 @@ export interface MatrixOptions extends Omit<CommonElementOptions, 'borderWidth'>
27
27
  height: number
28
28
  }
29
29
  export interface MatrixControllerDatasetOptions
30
- extends
31
- ControllerDatasetOptions,
30
+ extends ControllerDatasetOptions,
32
31
  ScriptableAndArrayOptions<MatrixOptions, ScriptableContext<'matrix'>>,
33
32
  ScriptableAndArrayOptions<CommonHoverOptions, ScriptableContext<'matrix'>> {}
34
33
 
@@ -64,8 +63,11 @@ export const MatrixController: ChartComponent & {
64
63
  new (chart: Chart, datasetIndex: number): MatrixController
65
64
  }
66
65
 
67
- export interface MatrixElement<T extends MatrixProps = MatrixProps, O extends MatrixOptions = MatrixOptions>
68
- extends Element<T, O>, VisualElement {}
66
+ export interface MatrixElement<
67
+ T extends MatrixProps = MatrixProps,
68
+ O extends MatrixOptions = MatrixOptions,
69
+ > extends Element<T, O>,
70
+ VisualElement {}
69
71
 
70
72
  export const MatrixElement: ChartComponent & {
71
73
  prototype: MatrixElement