chartjs-chart-matrix 3.0.2 → 3.0.4
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.
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* chartjs-chart-matrix v0.0.0-development
|
|
3
|
+
* https://chartjs-chart-matrix.pages.dev/
|
|
4
|
+
* (c) 2026 Jukka Kurkela
|
|
5
|
+
* Released under the MIT license
|
|
6
|
+
*/
|
|
7
|
+
(function (global, factory) {
|
|
8
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('chart.js'), require('chart.js/helpers')) :
|
|
9
|
+
typeof define === 'function' && define.amd ? define(['exports', 'chart.js', 'chart.js/helpers'], factory) :
|
|
10
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["chartjs-chart-matrix"] = {}, global.Chart, global.Chart.helpers));
|
|
11
|
+
})(this, (function (exports, chart_js, helpers) { 'use strict';
|
|
12
|
+
|
|
13
|
+
var version = "0.0.0-development";
|
|
14
|
+
|
|
15
|
+
class MatrixController extends chart_js.DatasetController {
|
|
16
|
+
initialize() {
|
|
17
|
+
this.enableOptionSharing = true;
|
|
18
|
+
super.initialize();
|
|
19
|
+
}
|
|
20
|
+
update(mode) {
|
|
21
|
+
const meta = this._cachedMeta;
|
|
22
|
+
this.updateElements(meta.data, 0, meta.data.length, mode);
|
|
23
|
+
}
|
|
24
|
+
updateElements(rects, start, count, mode) {
|
|
25
|
+
const reset = mode === 'reset';
|
|
26
|
+
const { xScale, yScale } = this._cachedMeta;
|
|
27
|
+
const firstOpts = this.resolveDataElementOptions(start, mode);
|
|
28
|
+
const sharedOptions = this.getSharedOptions(firstOpts);
|
|
29
|
+
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
|
+
const options = this.resolveDataElementOptions(i, mode);
|
|
34
|
+
const { width, height, anchorX, anchorY } = options;
|
|
35
|
+
const properties = {
|
|
36
|
+
height,
|
|
37
|
+
options,
|
|
38
|
+
width,
|
|
39
|
+
x: resolveX(anchorX, x, width),
|
|
40
|
+
y: resolveY(anchorY, y, height)
|
|
41
|
+
};
|
|
42
|
+
this.updateElement(rects[i], i, properties, mode);
|
|
43
|
+
}
|
|
44
|
+
this.updateSharedOptions(sharedOptions, mode, firstOpts);
|
|
45
|
+
}
|
|
46
|
+
draw() {
|
|
47
|
+
const ctx = this.chart.ctx;
|
|
48
|
+
const data = this.getMeta().data || [];
|
|
49
|
+
let i, ilen;
|
|
50
|
+
for(i = 0, ilen = data.length; i < ilen; ++i){
|
|
51
|
+
data[i].draw(ctx);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
MatrixController.id = 'matrix';
|
|
56
|
+
MatrixController.version = version;
|
|
57
|
+
MatrixController.defaults = {
|
|
58
|
+
animations: {
|
|
59
|
+
numbers: {
|
|
60
|
+
properties: [
|
|
61
|
+
'x',
|
|
62
|
+
'y',
|
|
63
|
+
'width',
|
|
64
|
+
'height'
|
|
65
|
+
],
|
|
66
|
+
type: 'number'
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
dataElementType: 'matrix'
|
|
70
|
+
};
|
|
71
|
+
MatrixController.overrides = {
|
|
72
|
+
interaction: {
|
|
73
|
+
intersect: true,
|
|
74
|
+
mode: 'nearest'
|
|
75
|
+
},
|
|
76
|
+
scales: {
|
|
77
|
+
x: {
|
|
78
|
+
offset: true,
|
|
79
|
+
type: 'linear'
|
|
80
|
+
},
|
|
81
|
+
y: {
|
|
82
|
+
reverse: true,
|
|
83
|
+
type: 'linear'
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
function resolveX(anchorX, x, width) {
|
|
88
|
+
if (anchorX === 'left' || anchorX === 'start') {
|
|
89
|
+
return x;
|
|
90
|
+
}
|
|
91
|
+
if (anchorX === 'right' || anchorX === 'end') {
|
|
92
|
+
return x - width;
|
|
93
|
+
}
|
|
94
|
+
return x - width / 2;
|
|
95
|
+
}
|
|
96
|
+
function resolveY(anchorY, y, height) {
|
|
97
|
+
if (anchorY === 'top' || anchorY === 'start') {
|
|
98
|
+
return y;
|
|
99
|
+
}
|
|
100
|
+
if (anchorY === 'bottom' || anchorY === 'end') {
|
|
101
|
+
return y - height;
|
|
102
|
+
}
|
|
103
|
+
return y - height / 2;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function getBounds(element, useFinalPosition) {
|
|
107
|
+
const { x, y, width, height } = element.getProps([
|
|
108
|
+
'x',
|
|
109
|
+
'y',
|
|
110
|
+
'width',
|
|
111
|
+
'height'
|
|
112
|
+
], useFinalPosition);
|
|
113
|
+
return {
|
|
114
|
+
bottom: y + height,
|
|
115
|
+
left: x,
|
|
116
|
+
right: x + width,
|
|
117
|
+
top: y
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function limit(value, min, max) {
|
|
121
|
+
return Math.max(Math.min(value, max), min);
|
|
122
|
+
}
|
|
123
|
+
function parseBorderWidth(options, maxW, maxH) {
|
|
124
|
+
const value = options.borderWidth;
|
|
125
|
+
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;
|
|
131
|
+
} else {
|
|
132
|
+
t = r = b = l = +value || 0;
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
b: limit(b, 0, maxH),
|
|
136
|
+
l: limit(l, 0, maxW),
|
|
137
|
+
r: limit(r, 0, maxW),
|
|
138
|
+
t: limit(t, 0, maxH)
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function boundingRects(element) {
|
|
142
|
+
const bounds = getBounds(element, false);
|
|
143
|
+
const width = bounds.right - bounds.left;
|
|
144
|
+
const height = bounds.bottom - bounds.top;
|
|
145
|
+
const border = parseBorderWidth(element.options, width / 2, height / 2);
|
|
146
|
+
return {
|
|
147
|
+
inner: {
|
|
148
|
+
h: height - border.t - border.b,
|
|
149
|
+
w: width - border.l - border.r,
|
|
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
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function inRange(element, x, y, useFinalPosition) {
|
|
162
|
+
const skipX = x === null;
|
|
163
|
+
const skipY = y === null;
|
|
164
|
+
const bounds = !element || skipX && skipY ? false : getBounds(element, useFinalPosition);
|
|
165
|
+
return bounds && (skipX || x >= bounds.left && x <= bounds.right) && (skipY || y >= bounds.top && y <= bounds.bottom);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
class MatrixElement extends chart_js.Element {
|
|
169
|
+
draw(ctx) {
|
|
170
|
+
const options = this.options;
|
|
171
|
+
const { inner, outer } = boundingRects(this);
|
|
172
|
+
const radius = helpers.toTRBLCorners(options.borderRadius);
|
|
173
|
+
ctx.save();
|
|
174
|
+
if (outer.w !== inner.w || outer.h !== inner.h) {
|
|
175
|
+
ctx.beginPath();
|
|
176
|
+
helpers.addRoundedRectPath(ctx, {
|
|
177
|
+
h: outer.h,
|
|
178
|
+
radius,
|
|
179
|
+
w: outer.w,
|
|
180
|
+
x: outer.x,
|
|
181
|
+
y: outer.y
|
|
182
|
+
});
|
|
183
|
+
helpers.addRoundedRectPath(ctx, {
|
|
184
|
+
h: inner.h,
|
|
185
|
+
radius,
|
|
186
|
+
w: inner.w,
|
|
187
|
+
x: inner.x,
|
|
188
|
+
y: inner.y
|
|
189
|
+
});
|
|
190
|
+
ctx.fillStyle = options.backgroundColor;
|
|
191
|
+
ctx.fill();
|
|
192
|
+
ctx.fillStyle = options.borderColor;
|
|
193
|
+
ctx.fill('evenodd');
|
|
194
|
+
} else {
|
|
195
|
+
ctx.beginPath();
|
|
196
|
+
helpers.addRoundedRectPath(ctx, {
|
|
197
|
+
h: inner.h,
|
|
198
|
+
radius,
|
|
199
|
+
w: inner.w,
|
|
200
|
+
x: inner.x,
|
|
201
|
+
y: inner.y
|
|
202
|
+
});
|
|
203
|
+
ctx.fillStyle = options.backgroundColor;
|
|
204
|
+
ctx.fill();
|
|
205
|
+
}
|
|
206
|
+
ctx.restore();
|
|
207
|
+
}
|
|
208
|
+
inRange(mouseX, mouseY, useFinalPosition) {
|
|
209
|
+
return inRange(this, mouseX, mouseY, useFinalPosition);
|
|
210
|
+
}
|
|
211
|
+
inXRange(mouseX, useFinalPosition) {
|
|
212
|
+
return inRange(this, mouseX, null, useFinalPosition);
|
|
213
|
+
}
|
|
214
|
+
inYRange(mouseY, useFinalPosition) {
|
|
215
|
+
return inRange(this, null, mouseY, useFinalPosition);
|
|
216
|
+
}
|
|
217
|
+
getCenterPoint(useFinalPosition) {
|
|
218
|
+
const { x, y, width, height } = this.getProps([
|
|
219
|
+
'x',
|
|
220
|
+
'y',
|
|
221
|
+
'width',
|
|
222
|
+
'height'
|
|
223
|
+
], useFinalPosition);
|
|
224
|
+
return {
|
|
225
|
+
x: x + width / 2,
|
|
226
|
+
y: y + height / 2
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
tooltipPosition() {
|
|
230
|
+
return this.getCenterPoint();
|
|
231
|
+
}
|
|
232
|
+
getRange(axis) {
|
|
233
|
+
return axis === 'x' ? this.width / 2 : this.height / 2;
|
|
234
|
+
}
|
|
235
|
+
constructor(cfg){
|
|
236
|
+
super();
|
|
237
|
+
if (cfg) {
|
|
238
|
+
Object.assign(this, cfg);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
MatrixElement.id = 'matrix';
|
|
243
|
+
MatrixElement.defaults = {
|
|
244
|
+
anchorX: 'center',
|
|
245
|
+
anchorY: 'center',
|
|
246
|
+
backgroundColor: undefined,
|
|
247
|
+
borderColor: undefined,
|
|
248
|
+
borderRadius: 0,
|
|
249
|
+
borderWidth: undefined,
|
|
250
|
+
height: 20,
|
|
251
|
+
width: 20
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
chart_js.Chart.register(MatrixController, MatrixElement);
|
|
255
|
+
|
|
256
|
+
exports.MatrixController = MatrixController;
|
|
257
|
+
exports.MatrixElement = MatrixElement;
|
|
258
|
+
|
|
259
|
+
}));
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* chartjs-chart-matrix v0.0.0-development
|
|
3
|
+
* https://chartjs-chart-matrix.pages.dev/
|
|
4
|
+
* (c) 2026 Jukka Kurkela
|
|
5
|
+
* Released under the MIT license
|
|
6
|
+
*/
|
|
7
|
+
import { DatasetController, Element } from 'chart.js';
|
|
8
|
+
import { isObject, toTRBLCorners, addRoundedRectPath } from 'chart.js/helpers';
|
|
9
|
+
|
|
10
|
+
var version = "0.0.0-development";
|
|
11
|
+
|
|
12
|
+
class MatrixController extends DatasetController {
|
|
13
|
+
initialize() {
|
|
14
|
+
this.enableOptionSharing = true;
|
|
15
|
+
super.initialize();
|
|
16
|
+
}
|
|
17
|
+
update(mode) {
|
|
18
|
+
const meta = this._cachedMeta;
|
|
19
|
+
this.updateElements(meta.data, 0, meta.data.length, mode);
|
|
20
|
+
}
|
|
21
|
+
updateElements(rects, start, count, mode) {
|
|
22
|
+
const reset = mode === 'reset';
|
|
23
|
+
const { xScale, yScale } = this._cachedMeta;
|
|
24
|
+
const firstOpts = this.resolveDataElementOptions(start, mode);
|
|
25
|
+
const sharedOptions = this.getSharedOptions(firstOpts);
|
|
26
|
+
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
|
+
const options = this.resolveDataElementOptions(i, mode);
|
|
31
|
+
const { width, height, anchorX, anchorY } = options;
|
|
32
|
+
const properties = {
|
|
33
|
+
height,
|
|
34
|
+
options,
|
|
35
|
+
width,
|
|
36
|
+
x: resolveX(anchorX, x, width),
|
|
37
|
+
y: resolveY(anchorY, y, height)
|
|
38
|
+
};
|
|
39
|
+
this.updateElement(rects[i], i, properties, mode);
|
|
40
|
+
}
|
|
41
|
+
this.updateSharedOptions(sharedOptions, mode, firstOpts);
|
|
42
|
+
}
|
|
43
|
+
draw() {
|
|
44
|
+
const ctx = this.chart.ctx;
|
|
45
|
+
const data = this.getMeta().data || [];
|
|
46
|
+
let i, ilen;
|
|
47
|
+
for(i = 0, ilen = data.length; i < ilen; ++i){
|
|
48
|
+
data[i].draw(ctx);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
MatrixController.id = 'matrix';
|
|
53
|
+
MatrixController.version = version;
|
|
54
|
+
MatrixController.defaults = {
|
|
55
|
+
animations: {
|
|
56
|
+
numbers: {
|
|
57
|
+
properties: [
|
|
58
|
+
'x',
|
|
59
|
+
'y',
|
|
60
|
+
'width',
|
|
61
|
+
'height'
|
|
62
|
+
],
|
|
63
|
+
type: 'number'
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
dataElementType: 'matrix'
|
|
67
|
+
};
|
|
68
|
+
MatrixController.overrides = {
|
|
69
|
+
interaction: {
|
|
70
|
+
intersect: true,
|
|
71
|
+
mode: 'nearest'
|
|
72
|
+
},
|
|
73
|
+
scales: {
|
|
74
|
+
x: {
|
|
75
|
+
offset: true,
|
|
76
|
+
type: 'linear'
|
|
77
|
+
},
|
|
78
|
+
y: {
|
|
79
|
+
reverse: true,
|
|
80
|
+
type: 'linear'
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
function resolveX(anchorX, x, width) {
|
|
85
|
+
if (anchorX === 'left' || anchorX === 'start') {
|
|
86
|
+
return x;
|
|
87
|
+
}
|
|
88
|
+
if (anchorX === 'right' || anchorX === 'end') {
|
|
89
|
+
return x - width;
|
|
90
|
+
}
|
|
91
|
+
return x - width / 2;
|
|
92
|
+
}
|
|
93
|
+
function resolveY(anchorY, y, height) {
|
|
94
|
+
if (anchorY === 'top' || anchorY === 'start') {
|
|
95
|
+
return y;
|
|
96
|
+
}
|
|
97
|
+
if (anchorY === 'bottom' || anchorY === 'end') {
|
|
98
|
+
return y - height;
|
|
99
|
+
}
|
|
100
|
+
return y - height / 2;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function getBounds(element, useFinalPosition) {
|
|
104
|
+
const { x, y, width, height } = element.getProps([
|
|
105
|
+
'x',
|
|
106
|
+
'y',
|
|
107
|
+
'width',
|
|
108
|
+
'height'
|
|
109
|
+
], useFinalPosition);
|
|
110
|
+
return {
|
|
111
|
+
bottom: y + height,
|
|
112
|
+
left: x,
|
|
113
|
+
right: x + width,
|
|
114
|
+
top: y
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function limit(value, min, max) {
|
|
118
|
+
return Math.max(Math.min(value, max), min);
|
|
119
|
+
}
|
|
120
|
+
function parseBorderWidth(options, maxW, maxH) {
|
|
121
|
+
const value = options.borderWidth;
|
|
122
|
+
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;
|
|
128
|
+
} else {
|
|
129
|
+
t = r = b = l = +value || 0;
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
b: limit(b, 0, maxH),
|
|
133
|
+
l: limit(l, 0, maxW),
|
|
134
|
+
r: limit(r, 0, maxW),
|
|
135
|
+
t: limit(t, 0, maxH)
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function boundingRects(element) {
|
|
139
|
+
const bounds = getBounds(element, false);
|
|
140
|
+
const width = bounds.right - bounds.left;
|
|
141
|
+
const height = bounds.bottom - bounds.top;
|
|
142
|
+
const border = parseBorderWidth(element.options, width / 2, height / 2);
|
|
143
|
+
return {
|
|
144
|
+
inner: {
|
|
145
|
+
h: height - border.t - border.b,
|
|
146
|
+
w: width - border.l - border.r,
|
|
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
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function inRange(element, x, y, useFinalPosition) {
|
|
159
|
+
const skipX = x === null;
|
|
160
|
+
const skipY = y === null;
|
|
161
|
+
const bounds = !element || skipX && skipY ? false : getBounds(element, useFinalPosition);
|
|
162
|
+
return bounds && (skipX || x >= bounds.left && x <= bounds.right) && (skipY || y >= bounds.top && y <= bounds.bottom);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
class MatrixElement extends Element {
|
|
166
|
+
draw(ctx) {
|
|
167
|
+
const options = this.options;
|
|
168
|
+
const { inner, outer } = boundingRects(this);
|
|
169
|
+
const radius = toTRBLCorners(options.borderRadius);
|
|
170
|
+
ctx.save();
|
|
171
|
+
if (outer.w !== inner.w || outer.h !== inner.h) {
|
|
172
|
+
ctx.beginPath();
|
|
173
|
+
addRoundedRectPath(ctx, {
|
|
174
|
+
h: outer.h,
|
|
175
|
+
radius,
|
|
176
|
+
w: outer.w,
|
|
177
|
+
x: outer.x,
|
|
178
|
+
y: outer.y
|
|
179
|
+
});
|
|
180
|
+
addRoundedRectPath(ctx, {
|
|
181
|
+
h: inner.h,
|
|
182
|
+
radius,
|
|
183
|
+
w: inner.w,
|
|
184
|
+
x: inner.x,
|
|
185
|
+
y: inner.y
|
|
186
|
+
});
|
|
187
|
+
ctx.fillStyle = options.backgroundColor;
|
|
188
|
+
ctx.fill();
|
|
189
|
+
ctx.fillStyle = options.borderColor;
|
|
190
|
+
ctx.fill('evenodd');
|
|
191
|
+
} else {
|
|
192
|
+
ctx.beginPath();
|
|
193
|
+
addRoundedRectPath(ctx, {
|
|
194
|
+
h: inner.h,
|
|
195
|
+
radius,
|
|
196
|
+
w: inner.w,
|
|
197
|
+
x: inner.x,
|
|
198
|
+
y: inner.y
|
|
199
|
+
});
|
|
200
|
+
ctx.fillStyle = options.backgroundColor;
|
|
201
|
+
ctx.fill();
|
|
202
|
+
}
|
|
203
|
+
ctx.restore();
|
|
204
|
+
}
|
|
205
|
+
inRange(mouseX, mouseY, useFinalPosition) {
|
|
206
|
+
return inRange(this, mouseX, mouseY, useFinalPosition);
|
|
207
|
+
}
|
|
208
|
+
inXRange(mouseX, useFinalPosition) {
|
|
209
|
+
return inRange(this, mouseX, null, useFinalPosition);
|
|
210
|
+
}
|
|
211
|
+
inYRange(mouseY, useFinalPosition) {
|
|
212
|
+
return inRange(this, null, mouseY, useFinalPosition);
|
|
213
|
+
}
|
|
214
|
+
getCenterPoint(useFinalPosition) {
|
|
215
|
+
const { x, y, width, height } = this.getProps([
|
|
216
|
+
'x',
|
|
217
|
+
'y',
|
|
218
|
+
'width',
|
|
219
|
+
'height'
|
|
220
|
+
], useFinalPosition);
|
|
221
|
+
return {
|
|
222
|
+
x: x + width / 2,
|
|
223
|
+
y: y + height / 2
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
tooltipPosition() {
|
|
227
|
+
return this.getCenterPoint();
|
|
228
|
+
}
|
|
229
|
+
getRange(axis) {
|
|
230
|
+
return axis === 'x' ? this.width / 2 : this.height / 2;
|
|
231
|
+
}
|
|
232
|
+
constructor(cfg){
|
|
233
|
+
super();
|
|
234
|
+
if (cfg) {
|
|
235
|
+
Object.assign(this, cfg);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
MatrixElement.id = 'matrix';
|
|
240
|
+
MatrixElement.defaults = {
|
|
241
|
+
anchorX: 'center',
|
|
242
|
+
anchorY: 'center',
|
|
243
|
+
backgroundColor: undefined,
|
|
244
|
+
borderColor: undefined,
|
|
245
|
+
borderRadius: 0,
|
|
246
|
+
borderWidth: undefined,
|
|
247
|
+
height: 20,
|
|
248
|
+
width: 20
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export { MatrixController, MatrixElement };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* chartjs-chart-matrix v0.0.0-development
|
|
3
|
+
* https://chartjs-chart-matrix.pages.dev/
|
|
4
|
+
* (c) 2026 Jukka Kurkela
|
|
5
|
+
* Released under the MIT license
|
|
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});
|
|
8
|
+
//# sourceMappingURL=chartjs-chart-matrix.min.js.map
|
|
@@ -0,0 +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 MatrixParsedDataPoint,\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 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 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,EA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AAI5B,KAAK6B,OAAS,CACvD,CA3DA,WAAA+E,CAAYC,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
package/types/index.esm.d.ts
CHANGED
|
@@ -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:
|
|
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
|
}
|