chartjs-chart-matrix
Advanced tools
Comparing version
@@ -6,4 +6,4 @@ { | ||
"license": "MIT", | ||
"version": "1.0.0-alpha4", | ||
"version": "1.0.0-alpha5", | ||
"main": "dist/chartjs-chart-matrix.js" | ||
} |
/*! | ||
* chartjs-chart-matrix v1.0.0-alpha4 | ||
* chartjs-chart-matrix v1.0.0-alpha5 | ||
* https://github.com/kurkle/chartjs-chart-matrix#readme | ||
* (c) 2019 Jukka Kurkela | ||
* (c) 2020 Jukka Kurkela | ||
* Released under the MIT license | ||
@@ -11,140 +11,412 @@ */ | ||
(global = global || self, factory(global.Chart)); | ||
}(this, function (Chart) { 'use strict'; | ||
}(this, (function (Chart) { 'use strict'; | ||
Chart = Chart && Chart.hasOwnProperty('default') ? Chart['default'] : Chart; | ||
Chart = Chart && Object.prototype.hasOwnProperty.call(Chart, 'default') ? Chart['default'] : Chart; | ||
var resolve = Chart.helpers.options.resolve; | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
var Controller = Chart.DatasetController.extend({ | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
dataElementType: Chart.elements.Rectangle, | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
update: function(reset) { | ||
var me = this; | ||
var meta = me.getMeta(); | ||
var data = meta.data || []; | ||
var i, ilen; | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
me._xScale = me.getScaleForId(meta.xAxisID); | ||
me._yScale = me.getScaleForId(meta.yAxisID); | ||
return obj; | ||
} | ||
for (i = 0, ilen = data.length; i < ilen; ++i) { | ||
me.updateElement(data[i], i, reset); | ||
} | ||
}, | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
updateElement: function(item, index, reset) { | ||
var me = this; | ||
var dataset = me.getDataset(); | ||
var datasetIndex = me.index; | ||
var value = dataset.data[index]; | ||
var xScale = me._xScale; | ||
var yScale = me._yScale; | ||
var options = me._resolveElementOptions(item, index); | ||
var x = reset ? xScale.getBasePixel() : xScale.getPixelForValue(value, index, datasetIndex); | ||
var y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(value, index, datasetIndex); | ||
var h = options.height; | ||
var w = options.width; | ||
var halfH = h / 2; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
item._xScale = xScale; | ||
item._yScale = yScale; | ||
item._options = options; | ||
item._datasetIndex = datasetIndex; | ||
item._index = index; | ||
return target; | ||
}; | ||
item._model = { | ||
x: x, | ||
base: y - halfH, | ||
y: y + halfH, | ||
width: w, | ||
height: h, | ||
backgroundColor: options.backgroundColor, | ||
borderColor: options.borderColor, | ||
borderSkipped: options.borderSkipped, | ||
borderWidth: options.borderWidth | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
item.pivot(); | ||
}, | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
draw: function() { | ||
var me = this; | ||
var data = me.getMeta().data || []; | ||
var i, ilen; | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
for (i = 0, ilen = data.length; i < ilen; ++i) { | ||
data[i].draw(); | ||
} | ||
}, | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
/** | ||
* @private | ||
*/ | ||
_resolveElementOptions: function(rectangle, index) { | ||
var me = this; | ||
var chart = me.chart; | ||
var datasets = chart.data.datasets; | ||
var dataset = datasets[me.index]; | ||
var options = chart.options.elements.rectangle; | ||
var values = {}; | ||
var i, ilen, key; | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
// Scriptable options | ||
var context = { | ||
chart: chart, | ||
dataIndex: index, | ||
dataset: dataset, | ||
datasetIndex: me.index | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
var keys = [ | ||
'backgroundColor', | ||
'borderColor', | ||
'borderSkipped', | ||
'borderWidth', | ||
'width', | ||
'height' | ||
]; | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
for (i = 0, ilen = keys.length; i < ilen; ++i) { | ||
key = keys[i]; | ||
values[key] = resolve([ | ||
dataset[key], | ||
options[key] | ||
], context, index); | ||
} | ||
try { | ||
Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
return values; | ||
} | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
}); | ||
return self; | ||
} | ||
Chart.controllers.matrix = Controller; | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (typeof call === "object" || typeof call === "function")) { | ||
return call; | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _createSuper(Derived) { | ||
return function () { | ||
var Super = _getPrototypeOf(Derived), | ||
result; | ||
if (_isNativeReflectConstruct()) { | ||
var NewTarget = _getPrototypeOf(this).constructor; | ||
result = Reflect.construct(Super, arguments, NewTarget); | ||
} else { | ||
result = Super.apply(this, arguments); | ||
} | ||
return _possibleConstructorReturn(this, result); | ||
}; | ||
} | ||
/** | ||
* Helper function to get the bounds of the rect | ||
* @param {Rectangle} rect the rect | ||
* @param {boolean} [useFinalPosition] | ||
* @return {object} bounds of the rect | ||
* @private | ||
*/ | ||
function getBounds(rect, useFinalPosition) { | ||
var _rect$getProps = rect.getProps(['x', 'y', 'width', 'height'], useFinalPosition), | ||
x = _rect$getProps.x, | ||
y = _rect$getProps.y, | ||
width = _rect$getProps.width, | ||
height = _rect$getProps.height; | ||
return { | ||
left: x, | ||
top: y, | ||
right: x + width, | ||
bottom: y + height | ||
}; | ||
} | ||
function limit(value, min, max) { | ||
return Math.max(Math.min(value, max), min); | ||
} | ||
function parseBorderWidth(rect, maxW, maxH) { | ||
var value = rect.options.borderWidth; | ||
var t, r, b, l; | ||
if (Chart.helpers.isObject(value)) { | ||
t = +value.top || 0; | ||
r = +value.right || 0; | ||
b = +value.bottom || 0; | ||
l = +value.left || 0; | ||
} else { | ||
t = r = b = l = +value || 0; | ||
} | ||
return { | ||
t: limit(t, 0, maxH), | ||
r: limit(r, 0, maxW), | ||
b: limit(b, 0, maxH), | ||
l: limit(l, 0, maxW) | ||
}; | ||
} | ||
function boundingRects(rect) { | ||
var bounds = getBounds(rect); | ||
var width = bounds.right - bounds.left; | ||
var height = bounds.bottom - bounds.top; | ||
var border = parseBorderWidth(rect, width / 2, height / 2); | ||
return { | ||
outer: { | ||
x: bounds.left, | ||
y: bounds.top, | ||
w: width, | ||
h: height | ||
}, | ||
inner: { | ||
x: bounds.left + border.l, | ||
y: bounds.top + border.t, | ||
w: width - border.l - border.r, | ||
h: height - border.t - border.b | ||
} | ||
}; | ||
} | ||
function _inRange(rect, x, y, useFinalPosition) { | ||
var skipX = x === null; | ||
var skipY = y === null; | ||
var bounds = !rect || skipX && skipY ? false : getBounds(rect, useFinalPosition); | ||
return bounds && (skipX || x >= bounds.left && x <= bounds.right) && (skipY || y >= bounds.top && y <= bounds.bottom); | ||
} | ||
var Rectangle = /*#__PURE__*/function (_Chart$Element) { | ||
_inherits(Rectangle, _Chart$Element); | ||
var _super = _createSuper(Rectangle); | ||
function Rectangle(cfg) { | ||
var _this; | ||
_classCallCheck(this, Rectangle); | ||
_this = _super.call(this); | ||
_this.options = undefined; | ||
_this.width = undefined; | ||
_this.height = undefined; | ||
if (cfg) { | ||
_extends(_assertThisInitialized(_this), cfg); | ||
} | ||
return _this; | ||
} | ||
_createClass(Rectangle, [{ | ||
key: "draw", | ||
value: function draw(ctx) { | ||
var options = this.options; | ||
var _boundingRects = boundingRects(this), | ||
inner = _boundingRects.inner, | ||
outer = _boundingRects.outer; | ||
ctx.save(); | ||
if (outer.w !== inner.w || outer.h !== inner.h) { | ||
ctx.beginPath(); | ||
ctx.rect(outer.x, outer.y, outer.w, outer.h); | ||
ctx.clip(); | ||
ctx.rect(inner.x, inner.y, inner.w, inner.h); | ||
ctx.fillStyle = options.backgroundColor; | ||
ctx.fill(); | ||
ctx.fillStyle = options.borderColor; | ||
ctx.fill('evenodd'); | ||
} else { | ||
ctx.fillStyle = options.backgroundColor; | ||
ctx.fillRect(inner.x, inner.y, inner.w, inner.h); | ||
} | ||
ctx.restore(); | ||
} | ||
}, { | ||
key: "inRange", | ||
value: function inRange(mouseX, mouseY, useFinalPosition) { | ||
return _inRange(this, mouseX, mouseY, useFinalPosition); | ||
} | ||
}, { | ||
key: "inXRange", | ||
value: function inXRange(mouseX, useFinalPosition) { | ||
return _inRange(this, mouseX, null, useFinalPosition); | ||
} | ||
}, { | ||
key: "inYRange", | ||
value: function inYRange(mouseY, useFinalPosition) { | ||
return _inRange(this, null, mouseY, useFinalPosition); | ||
} | ||
}, { | ||
key: "getCenterPoint", | ||
value: function getCenterPoint(useFinalPosition) { | ||
var _this$getProps = this.getProps(['x', 'y', 'width', 'height'], useFinalPosition), | ||
x = _this$getProps.x, | ||
y = _this$getProps.y, | ||
width = _this$getProps.width, | ||
height = _this$getProps.height; | ||
return { | ||
x: x + width / 2, | ||
y: y + height / 2 | ||
}; | ||
} | ||
}, { | ||
key: "tooltipPosition", | ||
value: function tooltipPosition() { | ||
return this.getCenterPoint(); | ||
} | ||
}, { | ||
key: "getRange", | ||
value: function getRange(axis) { | ||
return axis === 'x' ? this.width / 2 : this.height / 2; | ||
} | ||
}]); | ||
return Rectangle; | ||
}(Chart.Element); | ||
_defineProperty(Rectangle, "_type", 'rectangle'); | ||
var MatrixController = /*#__PURE__*/function (_Chart$DatasetControl) { | ||
_inherits(MatrixController, _Chart$DatasetControl); | ||
var _super = _createSuper(MatrixController); | ||
function MatrixController() { | ||
_classCallCheck(this, MatrixController); | ||
return _super.apply(this, arguments); | ||
} | ||
_createClass(MatrixController, [{ | ||
key: "update", | ||
value: function update(mode) { | ||
var me = this; | ||
var meta = me._cachedMeta; | ||
me.updateElements(meta.data, 0, mode); | ||
} | ||
}, { | ||
key: "updateElements", | ||
value: function updateElements(rects, start, mode) { | ||
var me = this; | ||
var reset = mode === 'reset'; | ||
var _me$_cachedMeta = me._cachedMeta, | ||
xScale = _me$_cachedMeta.xScale, | ||
yScale = _me$_cachedMeta.yScale; | ||
var firstOpts = me.resolveDataElementOptions(start, mode); | ||
var sharedOptions = me.getSharedOptions(mode, rects[start], firstOpts); | ||
for (var i = 0; i < rects.length; i++) { | ||
var index = start + i; | ||
var parsed = !reset && me.getParsed(index); | ||
var x = reset ? xScale.getBasePixel() : xScale.getPixelForValue(parsed.x); | ||
var y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(parsed.y); | ||
var options = me.resolveDataElementOptions(i, mode); | ||
var width = options.width, | ||
height = options.height; | ||
var properties = { | ||
x: x - width / 2, | ||
y: y - height / 2, | ||
width: width, | ||
height: height, | ||
options: options | ||
}; | ||
me.updateElement(rects[i], index, properties, mode); | ||
} | ||
me.updateSharedOptions(sharedOptions, mode); | ||
} | ||
}, { | ||
key: "draw", | ||
value: function draw() { | ||
var me = this; | ||
var data = me.getMeta().data || []; | ||
var i, ilen; | ||
for (i = 0, ilen = data.length; i < ilen; ++i) { | ||
data[i].draw(me._ctx); | ||
} | ||
} | ||
}]); | ||
return MatrixController; | ||
}(Chart.DatasetController); | ||
MatrixController.prototype.dataElementType = Rectangle; | ||
MatrixController.prototype.dataElementOptions = ['backgroundColor', 'borderColor', 'borderWidth', 'width', 'height']; | ||
Chart.controllers.matrix = MatrixController; | ||
Chart.defaults.matrix = { | ||
hover: { | ||
mode: 'nearest', | ||
intersect: true | ||
}, | ||
tooltips: { | ||
mode: 'nearest', | ||
intersect: true | ||
}, | ||
scales: { | ||
xAxes: [{ | ||
type: 'linear' | ||
}], | ||
yAxes: [{ | ||
type: 'linear' | ||
}] | ||
}, | ||
elements: { | ||
rectangle: { | ||
borderSkipped: false, | ||
width: 20, | ||
height: 20 | ||
} | ||
} | ||
hover: { | ||
mode: 'nearest', | ||
intersect: true | ||
}, | ||
datasets: { | ||
animation: { | ||
numbers: { | ||
type: 'number', | ||
properties: ['x', 'y', 'width', 'height'] | ||
} | ||
} | ||
}, | ||
tooltips: { | ||
mode: 'nearest', | ||
intersect: true | ||
}, | ||
scales: { | ||
x: { | ||
type: 'linear', | ||
offset: true | ||
}, | ||
y: { | ||
type: 'linear', | ||
reverse: true | ||
} | ||
}, | ||
elements: { | ||
rectangle: { | ||
width: 20, | ||
height: 20 | ||
} | ||
} | ||
}; | ||
})); | ||
}))); |
/*! | ||
* chartjs-chart-matrix v1.0.0-alpha4 | ||
* chartjs-chart-matrix v1.0.0-alpha5 | ||
* https://github.com/kurkle/chartjs-chart-matrix#readme | ||
* (c) 2019 Jukka Kurkela | ||
* (c) 2020 Jukka Kurkela | ||
* Released under the MIT license | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("chart.js")):"function"==typeof define&&define.amd?define(["chart.js"],t):t((e=e||self).Chart)}(this,function(e){"use strict";var t=(e=e&&e.hasOwnProperty("default")?e.default:e).helpers.options.resolve,r=e.DatasetController.extend({dataElementType:e.elements.Rectangle,update:function(e){var t,r,a=this,o=a.getMeta(),d=o.data||[];for(a._xScale=a.getScaleForId(o.xAxisID),a._yScale=a.getScaleForId(o.yAxisID),t=0,r=d.length;t<r;++t)a.updateElement(d[t],t,e)},updateElement:function(e,t,r){var a=this,o=a.getDataset(),d=a.index,n=o.data[t],i=a._xScale,l=a._yScale,s=a._resolveElementOptions(e,t),h=r?i.getBasePixel():i.getPixelForValue(n,t,d),c=r?l.getBasePixel():l.getPixelForValue(n,t,d),p=s.height,x=s.width,u=p/2;e._xScale=i,e._yScale=l,e._options=s,e._datasetIndex=d,e._index=t,e._model={x:h,base:c-u,y:c+u,width:x,height:p,backgroundColor:s.backgroundColor,borderColor:s.borderColor,borderSkipped:s.borderSkipped,borderWidth:s.borderWidth},e.pivot()},draw:function(){var e,t,r=this.getMeta().data||[];for(e=0,t=r.length;e<t;++e)r[e].draw()},_resolveElementOptions:function(e,r){var a,o,d,n=this.chart,i=n.data.datasets[this.index],l=n.options.elements.rectangle,s={},h={chart:n,dataIndex:r,dataset:i,datasetIndex:this.index},c=["backgroundColor","borderColor","borderSkipped","borderWidth","width","height"];for(a=0,o=c.length;a<o;++a)s[d=c[a]]=t([i[d],l[d]],h,r);return s}});e.controllers.matrix=r,e.defaults.matrix={hover:{mode:"nearest",intersect:!0},tooltips:{mode:"nearest",intersect:!0},scales:{xAxes:[{type:"linear"}],yAxes:[{type:"linear"}]},elements:{rectangle:{borderSkipped:!1,width:20,height:20}}}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("chart.js")):"function"==typeof define&&define.amd?define(["chart.js"],e):e((t=t||self).Chart)}(this,(function(t){"use strict";function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function n(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function o(){return(o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&u(t,e)}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function u(t,e){return(u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function c(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function f(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?c(t):e}function h(t){return function(){var e,r=a(t);if(l()){var n=a(this).constructor;e=Reflect.construct(r,arguments,n)}else e=r.apply(this,arguments);return f(this,e)}}function s(t,e){var r=t.getProps(["x","y","width","height"],e),n=r.x,o=r.y;return{left:n,top:o,right:n+r.width,bottom:o+r.height}}function p(t,e,r){return Math.max(Math.min(t,r),e)}function y(e){var r=s(e),n=r.right-r.left,o=r.bottom-r.top,i=function(e,r,n){var o,i,a,u,l=e.options.borderWidth;return t.helpers.isObject(l)?(o=+l.top||0,i=+l.right||0,a=+l.bottom||0,u=+l.left||0):o=i=a=u=+l||0,{t:p(o,0,n),r:p(i,0,r),b:p(a,0,n),l:p(u,0,r)}}(e,n/2,o/2);return{outer:{x:r.left,y:r.top,w:n,h:o},inner:{x:r.left+i.l,y:r.top+i.t,w:n-i.l-i.r,h:o-i.t-i.b}}}function d(t,e,r,n){var o=null===e,i=null===r,a=!(!t||o&&i)&&s(t,n);return a&&(o||e>=a.left&&e<=a.right)&&(i||r>=a.top&&r<=a.bottom)}var g,v,b,w=function(t){i(a,t);var r=h(a);function a(t){var n;return e(this,a),(n=r.call(this)).options=void 0,n.width=void 0,n.height=void 0,t&&o(c(n),t),n}return n(a,[{key:"draw",value:function(t){var e=this.options,r=y(this),n=r.inner,o=r.outer;t.save(),o.w!==n.w||o.h!==n.h?(t.beginPath(),t.rect(o.x,o.y,o.w,o.h),t.clip(),t.rect(n.x,n.y,n.w,n.h),t.fillStyle=e.backgroundColor,t.fill(),t.fillStyle=e.borderColor,t.fill("evenodd")):(t.fillStyle=e.backgroundColor,t.fillRect(n.x,n.y,n.w,n.h)),t.restore()}},{key:"inRange",value:function(t,e,r){return d(this,t,e,r)}},{key:"inXRange",value:function(t,e){return d(this,t,null,e)}},{key:"inYRange",value:function(t,e){return d(this,null,t,e)}},{key:"getCenterPoint",value:function(t){var e=this.getProps(["x","y","width","height"],t),r=e.x,n=e.y;return{x:r+e.width/2,y:n+e.height/2}}},{key:"tooltipPosition",value:function(){return this.getCenterPoint()}},{key:"getRange",value:function(t){return"x"===t?this.width/2:this.height/2}}]),a}((t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t).Element);b="rectangle",(v="_type")in(g=w)?Object.defineProperty(g,v,{value:b,enumerable:!0,configurable:!0,writable:!0}):g[v]=b;var m=function(t){i(o,t);var r=h(o);function o(){return e(this,o),r.apply(this,arguments)}return n(o,[{key:"update",value:function(t){var e=this._cachedMeta;this.updateElements(e.data,0,t)}},{key:"updateElements",value:function(t,e,r){for(var n=this,o="reset"===r,i=n._cachedMeta,a=i.xScale,u=i.yScale,l=n.resolveDataElementOptions(e,r),c=n.getSharedOptions(r,t[e],l),f=0;f<t.length;f++){var h=e+f,s=!o&&n.getParsed(h),p=o?a.getBasePixel():a.getPixelForValue(s.x),y=o?u.getBasePixel():u.getPixelForValue(s.y),d=n.resolveDataElementOptions(f,r),g=d.width,v=d.height,b={x:p-g/2,y:y-v/2,width:g,height:v,options:d};n.updateElement(t[f],h,b,r)}n.updateSharedOptions(c,r)}},{key:"draw",value:function(){var t,e,r=this.getMeta().data||[];for(t=0,e=r.length;t<e;++t)r[t].draw(this._ctx)}}]),o}(t.DatasetController);m.prototype.dataElementType=w,m.prototype.dataElementOptions=["backgroundColor","borderColor","borderWidth","width","height"],t.controllers.matrix=m,t.defaults.matrix={hover:{mode:"nearest",intersect:!0},datasets:{animation:{numbers:{type:"number",properties:["x","y","width","height"]}}},tooltips:{mode:"nearest",intersect:!0},scales:{x:{type:"linear",offset:!0},y:{type:"linear",reverse:!0}},elements:{rectangle:{width:20,height:20}}}})); |
{ | ||
"name": "chartjs-chart-matrix", | ||
"version": "1.0.0-alpha4", | ||
"version": "1.0.0-alpha5", | ||
"description": "Chart.js module for creating matrix charts", | ||
"main": "dist/chartjs-chart-matrix.js", | ||
"module": "dist/chartjs-chart-matrix.esm.js", | ||
"scripts": { | ||
@@ -29,9 +30,19 @@ "test": "gulp test" | ||
"devDependencies": { | ||
"chart.js": "^2.8.0", | ||
"eslint": "^5.16.0", | ||
"eslint-config-chartjs": "^0.1.0", | ||
"eslint-plugin-es": "^1.4.0", | ||
"eslint-plugin-html": "^5.0.3", | ||
"@babel/core": "^7.9.0", | ||
"@babel/plugin-proposal-class-properties": "^7.8.3", | ||
"@babel/plugin-transform-object-assign": "^7.8.3", | ||
"@babel/preset-env": "^7.9.5", | ||
"@rollup/plugin-commonjs": "^11.1.0", | ||
"@rollup/plugin-node-resolve": "^7.1.3", | ||
"babel-eslint": "^10.1.0", | ||
"babel-plugin-istanbul": "^6.0.0", | ||
"chart.js": "^3.0.0-alpha", | ||
"chartjs-adapter-date-fns": "^1.1.0-alpha", | ||
"date-fns": "^2.12.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-chartjs": "^0.2.0", | ||
"eslint-config-esnext": "^4.0.0", | ||
"eslint-plugin-html": "^6.0.1", | ||
"gulp": "^4.0.2", | ||
"gulp-eslint": "^5.0.0", | ||
"gulp-eslint": "^6.0.0", | ||
"gulp-file": "^0.4.0", | ||
@@ -41,23 +52,21 @@ "gulp-replace": "^1.0.0", | ||
"gulp-zip": "^4.2.0", | ||
"jasmine-core": "^3.4.0", | ||
"karma": "^4.1.0", | ||
"jasmine-core": "^3.5.0", | ||
"karma": "^5.0.1", | ||
"karma-coverage": "^1.1.2", | ||
"karma-firefox-launcher": "^1.1.0", | ||
"karma-firefox-launcher": "^1.3.0", | ||
"karma-jasmine": "^2.0.1", | ||
"karma-jasmine-html-reporter": "^1.4.2", | ||
"karma-rollup-preprocessor": "^7.0.0", | ||
"karma-jasmine-html-reporter": "^1.5.3", | ||
"karma-rollup-preprocessor": "^7.0.5", | ||
"karma-spec-reporter": "0.0.32", | ||
"merge2": "^1.2.3", | ||
"moment": "^2.24.0", | ||
"merge2": "^1.3.0", | ||
"pixelmatch": "^4.0.2", | ||
"rollup": "^1.11.3", | ||
"rollup-plugin-commonjs": "^9.3.4", | ||
"rollup-plugin-istanbul": "^2.0.1", | ||
"rollup-plugin-node-resolve": "^4.2.3", | ||
"rollup-plugin-terser": "^4.0.4", | ||
"yargs": "^13.2.2" | ||
"rollup": "^2.6.0", | ||
"rollup-plugin-babel": "^4.4.0", | ||
"rollup-plugin-terser": "^5.3.0", | ||
"yargs": "^13.3.2" | ||
}, | ||
"peerDependencies": { | ||
"chart.js": ">= 2.8.0 < 3" | ||
} | ||
"chart.js": "^3.0.0-alpha" | ||
}, | ||
"dependencies": {} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
31006
192.51%8
33.33%656
343.24%35
25%3
50%1
Infinity%