chartjs-chart-matrix
Advanced tools
Comparing version 1.0.0-alpha8 to 1.0.0-beta
/*! | ||
* chartjs-chart-matrix v1.0.0-alpha8 | ||
* chartjs-chart-matrix v1.0.0-beta | ||
* https://github.com/kurkle/chartjs-chart-matrix#readme | ||
@@ -8,5 +8,9 @@ * (c) 2020 Jukka Kurkela | ||
import { DatasetController, Element } from 'chart.js'; | ||
import { isObject } from 'chart.js/helpers/core'; | ||
import { isObject } from 'chart.js/helpers'; | ||
class MatrixController extends DatasetController { | ||
initialize() { | ||
this.enableOptionSharing = true; | ||
super.initialize(); | ||
} | ||
@@ -17,6 +21,6 @@ update(mode) { | ||
me.updateElements(meta.data, 0, mode); | ||
me.updateElements(meta.data, 0, meta.data.length, mode); | ||
} | ||
updateElements(rects, start, mode) { | ||
updateElements(rects, start, count, mode) { | ||
const me = this; | ||
@@ -28,5 +32,4 @@ const reset = mode === 'reset'; | ||
for (let i = 0; i < rects.length; i++) { | ||
const index = start + i; | ||
const parsed = !reset && me.getParsed(index); | ||
for (let i = start; i < start + count; i++) { | ||
const parsed = !reset && me.getParsed(i); | ||
const x = reset ? xScale.getBasePixel() : xScale.getPixelForValue(parsed.x); | ||
@@ -43,3 +46,3 @@ const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(parsed.y); | ||
}; | ||
me.updateElement(rects[i], index, properties, mode); | ||
me.updateElement(rects[i], i, properties, mode); | ||
} | ||
@@ -46,0 +49,0 @@ |
/*! | ||
* chartjs-chart-matrix v1.0.0-alpha8 | ||
* chartjs-chart-matrix v1.0.0-beta | ||
* https://github.com/kurkle/chartjs-chart-matrix#readme | ||
@@ -10,7 +10,9 @@ * (c) 2020 Jukka Kurkela | ||
typeof define === 'function' && define.amd ? define(['chart.js'], factory) : | ||
(global = global || self, factory(global.Chart)); | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Chart)); | ||
}(this, (function (Chart) { 'use strict'; | ||
var Chart__default = 'default' in Chart ? Chart['default'] : Chart; | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var Chart__default = /*#__PURE__*/_interopDefaultLegacy(Chart); | ||
function _extends() { | ||
@@ -57,9 +59,15 @@ _extends = Object.assign || function (target) { | ||
_proto.initialize = function initialize() { | ||
this.enableOptionSharing = true; | ||
_DatasetController.prototype.initialize.call(this); | ||
}; | ||
_proto.update = function update(mode) { | ||
var me = this; | ||
var meta = me._cachedMeta; | ||
me.updateElements(meta.data, 0, mode); | ||
me.updateElements(meta.data, 0, meta.data.length, mode); | ||
}; | ||
_proto.updateElements = function updateElements(rects, start, mode) { | ||
_proto.updateElements = function updateElements(rects, start, count, mode) { | ||
var me = this; | ||
@@ -73,5 +81,4 @@ var reset = mode === 'reset'; | ||
for (var i = 0; i < rects.length; i++) { | ||
var index = start + i; | ||
var parsed = !reset && me.getParsed(index); | ||
for (var i = start; i < start + count; i++) { | ||
var parsed = !reset && me.getParsed(i); | ||
var x = reset ? xScale.getBasePixel() : xScale.getPixelForValue(parsed.x); | ||
@@ -91,3 +98,3 @@ var y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(parsed.y); | ||
}; | ||
me.updateElement(rects[i], index, properties, mode); | ||
me.updateElement(rects[i], i, properties, mode); | ||
} | ||
@@ -144,9 +151,2 @@ | ||
/*! | ||
* Chart.js v3.0.0-alpha.2 | ||
* https://www.chartjs.org | ||
* (c) 2020 Chart.js Contributors | ||
* Released under the MIT License | ||
*/ | ||
function isObject(value) { | ||
@@ -156,2 +156,20 @@ return value !== null && Object.prototype.toString.call(value) === '[object Object]'; | ||
var supportsEventListenerOptions = function () { | ||
var passiveSupported = false; | ||
try { | ||
var options = { | ||
get passive() { | ||
passiveSupported = true; | ||
return false; | ||
} | ||
}; | ||
window.addEventListener('test', null, options); | ||
window.removeEventListener('test', null, options); | ||
} catch (e) {} | ||
return passiveSupported; | ||
}(); | ||
/** | ||
@@ -320,4 +338,4 @@ * Helper function to get the bounds of the rect | ||
Chart__default.register(MatrixController, Matrix); | ||
Chart__default['default'].register(MatrixController, Matrix); | ||
}))); |
/*! | ||
* chartjs-chart-matrix v1.0.0-alpha8 | ||
* chartjs-chart-matrix v1.0.0-beta | ||
* https://github.com/kurkle/chartjs-chart-matrix#readme | ||
@@ -7,9 +7,2 @@ * (c) 2020 Jukka Kurkela | ||
*/ | ||
!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";var e="default"in t?t.default:t;function r(){return(r=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 n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var o=function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var r=e.prototype;return r.update=function(t){var e=this._cachedMeta;this.updateElements(e.data,0,t)},r.updateElements=function(t,e,r){for(var n=this,o="reset"===r,i=n._cachedMeta,a=i.xScale,h=i.yScale,l=n.resolveDataElementOptions(e,r),s=n.getSharedOptions(r,t[e],l),u=0;u<t.length;u++){var c=e+u,d=!o&&n.getParsed(c),f=o?a.getBasePixel():a.getPixelForValue(d.x),p=o?h.getBasePixel():h.getPixelForValue(d.y),g=n.resolveDataElementOptions(u,r),y=g.width,v=g.height,b=g.anchorX,x=g.anchorY,m={x:"left"===b?f:f-y/("right"===b?1:2),y:"top"===x?p:p-v/("bottom"===x?1:2),width:y,height:v,options:g};n.updateElement(t[u],c,m,r)}n.updateSharedOptions(s,r)},r.draw=function(){var t,e,r=this.getMeta().data||[];for(t=0,e=r.length;t<e;++t)r[t].draw(this._ctx)},e}(t.DatasetController);function i(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 a(t,e,r){return Math.max(Math.min(t,r),e)}function h(t,e,r){var n,o,i,h,l=t.options.borderWidth;return! | ||
/*! | ||
* Chart.js v3.0.0-alpha.2 | ||
* https://www.chartjs.org | ||
* (c) 2020 Chart.js Contributors | ||
* Released under the MIT License | ||
*/ | ||
function(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}(l)?n=o=i=h=+l||0:(n=+l.top||0,o=+l.right||0,i=+l.bottom||0,h=+l.left||0),{t:a(n,0,r),r:a(o,0,e),b:a(i,0,r),l:a(h,0,e)}}function l(t,e,r,n){var o=null===e,a=null===r,h=!(!t||o&&a)&&i(t,n);return h&&(o||e>=h.left&&e<=h.right)&&(a||r>=h.top&&r<=h.bottom)}o.id="matrix",o.defaults={dataElementType:"matrix",dataElementOptions:["backgroundColor","borderColor","borderWidth","anchorX","anchorY","width","height"],hover:{mode:"nearest",intersect:!0},datasets:{animation:{numbers:{type:"number",properties:["x","y","width","height"]}},anchorX:"center",anchorY:"center"},tooltips:{mode:"nearest",intersect:!0},scales:{x:{type:"linear",offset:!0},y:{type:"linear",reverse:!0}}};var s=function(t){function e(e){var n;return(n=t.call(this)||this).options=void 0,n.width=void 0,n.height=void 0,e&&r(function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(n),e),n}n(e,t);var o=e.prototype;return o.draw=function(t){var e,r,n,o,a,l=this.options,s=(r=i(e=this),n=r.right-r.left,o=r.bottom-r.top,a=h(e,n/2,o/2),{outer:{x:r.left,y:r.top,w:n,h:o},inner:{x:r.left+a.l,y:r.top+a.t,w:n-a.l-a.r,h:o-a.t-a.b}}),u=s.inner,c=s.outer;t.save(),c.w!==u.w||c.h!==u.h?(t.beginPath(),t.rect(c.x,c.y,c.w,c.h),t.clip(),t.rect(u.x,u.y,u.w,u.h),t.fillStyle=l.backgroundColor,t.fill(),t.fillStyle=l.borderColor,t.fill("evenodd")):(t.fillStyle=l.backgroundColor,t.fillRect(u.x,u.y,u.w,u.h)),t.restore()},o.inRange=function(t,e,r){return l(this,t,e,r)},o.inXRange=function(t,e){return l(this,t,null,e)},o.inYRange=function(t,e){return l(this,null,t,e)},o.getCenterPoint=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}},o.tooltipPosition=function(){return this.getCenterPoint()},o.getRange=function(t){return"x"===t?this.width/2:this.height/2},e}(t.Element);s.id="matrix",s.defaults={width:20,height:20},e.register(o,s)})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("chart.js")):"function"==typeof define&&define.amd?define(["chart.js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Chart)}(this,(function(t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=e(t);function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function i(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var o=function(t){function e(){return t.apply(this,arguments)||this}i(e,t);var n=e.prototype;return n.initialize=function(){this.enableOptionSharing=!0,t.prototype.initialize.call(this)},n.update=function(t){var e=this._cachedMeta;this.updateElements(e.data,0,e.data.length,t)},n.updateElements=function(t,e,n,r){for(var i=this,o="reset"===r,a=i._cachedMeta,l=a.xScale,h=a.yScale,s=i.resolveDataElementOptions(e,r),u=i.getSharedOptions(r,t[e],s),c=e;c<e+n;c++){var d=!o&&i.getParsed(c),f=o?l.getBasePixel():l.getPixelForValue(d.x),p=o?h.getBasePixel():h.getPixelForValue(d.y),g=i.resolveDataElementOptions(c,r),y=g.width,v=g.height,b=g.anchorX,w=g.anchorY,m={x:"left"===b?f:f-y/("right"===b?1:2),y:"top"===w?p:p-v/("bottom"===w?1:2),width:y,height:v,options:g};i.updateElement(t[c],c,m,r)}i.updateSharedOptions(u,r)},n.draw=function(){var t,e,n=this.getMeta().data||[];for(t=0,e=n.length;t<e;++t)n[t].draw(this._ctx)},e}(t.DatasetController);o.id="matrix",o.defaults={dataElementType:"matrix",dataElementOptions:["backgroundColor","borderColor","borderWidth","anchorX","anchorY","width","height"],hover:{mode:"nearest",intersect:!0},datasets:{animation:{numbers:{type:"number",properties:["x","y","width","height"]}},anchorX:"center",anchorY:"center"},tooltips:{mode:"nearest",intersect:!0},scales:{x:{type:"linear",offset:!0},y:{type:"linear",reverse:!0}}};!function(){var t=!1;try{var e={get passive(){return t=!0,!1}};window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(t){}}();function a(t,e){var n=t.getProps(["x","y","width","height"],e),r=n.x,i=n.y;return{left:r,top:i,right:r+n.width,bottom:i+n.height}}function l(t,e,n){return Math.max(Math.min(t,n),e)}function h(t,e,n){var r,i,o,a,h=t.options.borderWidth;return!function(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}(h)?r=i=o=a=+h||0:(r=+h.top||0,i=+h.right||0,o=+h.bottom||0,a=+h.left||0),{t:l(r,0,n),r:l(i,0,e),b:l(o,0,n),l:l(a,0,e)}}function s(t,e,n,r){var i=null===e,o=null===n,l=!(!t||i&&o)&&a(t,r);return l&&(i||e>=l.left&&e<=l.right)&&(o||n>=l.top&&n<=l.bottom)}var u=function(t){function e(e){var n;return(n=t.call(this)||this).options=void 0,n.width=void 0,n.height=void 0,e&&r(function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(n),e),n}i(e,t);var n=e.prototype;return n.draw=function(t){var e,n,r,i,o,l=this.options,s=(n=a(e=this),r=n.right-n.left,i=n.bottom-n.top,o=h(e,r/2,i/2),{outer:{x:n.left,y:n.top,w:r,h:i},inner:{x:n.left+o.l,y:n.top+o.t,w:r-o.l-o.r,h:i-o.t-o.b}}),u=s.inner,c=s.outer;t.save(),c.w!==u.w||c.h!==u.h?(t.beginPath(),t.rect(c.x,c.y,c.w,c.h),t.clip(),t.rect(u.x,u.y,u.w,u.h),t.fillStyle=l.backgroundColor,t.fill(),t.fillStyle=l.borderColor,t.fill("evenodd")):(t.fillStyle=l.backgroundColor,t.fillRect(u.x,u.y,u.w,u.h)),t.restore()},n.inRange=function(t,e,n){return s(this,t,e,n)},n.inXRange=function(t,e){return s(this,t,null,e)},n.inYRange=function(t,e){return s(this,null,t,e)},n.getCenterPoint=function(t){var e=this.getProps(["x","y","width","height"],t),n=e.x,r=e.y;return{x:n+e.width/2,y:r+e.height/2}},n.tooltipPosition=function(){return this.getCenterPoint()},n.getRange=function(t){return"x"===t?this.width/2:this.height/2},e}(t.Element);u.id="matrix",u.defaults={width:20,height:20},n.default.register(o,u)})); |
{ | ||
"name": "chartjs-chart-matrix", | ||
"version": "1.0.0-alpha8", | ||
"version": "1.0.0-beta", | ||
"description": "Chart.js module for creating matrix charts", | ||
@@ -33,29 +33,29 @@ "main": "dist/chartjs-chart-matrix.js", | ||
"devDependencies": { | ||
"@babel/core": "^7.10.5", | ||
"@babel/core": "^7.11.6", | ||
"@babel/plugin-transform-object-assign": "^7.10.4", | ||
"@babel/preset-env": "^7.10.4", | ||
"@rollup/plugin-commonjs": "^11.1.0", | ||
"@rollup/plugin-node-resolve": "^7.1.3", | ||
"@babel/preset-env": "^7.11.5", | ||
"@rollup/plugin-commonjs": "^15.1.0", | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
"babel-eslint": "^10.1.0", | ||
"babel-plugin-istanbul": "^6.0.0", | ||
"chart.js": "^3.0.0-alpha.2", | ||
"chartjs-adapter-date-fns": "^1.1.0-alpha", | ||
"chart.js": "^3.0.0-beta.3", | ||
"chartjs-adapter-date-fns": "^1.1.0-alpha.3", | ||
"cross-env": "^7.0.2", | ||
"date-fns": "^2.15.0", | ||
"eslint": "^6.8.0", | ||
"date-fns": "^2.16.1", | ||
"eslint": "^7.10.0", | ||
"eslint-config-chartjs": "^0.2.0", | ||
"eslint-config-esnext": "^4.1.0", | ||
"eslint-plugin-html": "^6.0.1", | ||
"jasmine-core": "^3.5.0", | ||
"karma": "^5.1.0", | ||
"karma-coverage": "^1.1.2", | ||
"eslint-plugin-html": "^6.1.0", | ||
"jasmine-core": "^3.6.0", | ||
"karma": "^5.2.3", | ||
"karma-coverage": "^2.0.3", | ||
"karma-firefox-launcher": "^1.3.0", | ||
"karma-jasmine": "^2.0.1", | ||
"karma-jasmine": "^4.0.1", | ||
"karma-jasmine-html-reporter": "^1.5.4", | ||
"karma-rollup-preprocessor": "^7.0.5", | ||
"karma-spec-reporter": "0.0.32", | ||
"pixelmatch": "^4.0.2", | ||
"rollup": "^2.21.0", | ||
"pixelmatch": "^5.2.1", | ||
"rollup": "^2.28.2", | ||
"rollup-plugin-babel": "^4.4.0", | ||
"rollup-plugin-terser": "^5.3.0" | ||
"rollup-plugin-terser": "^7.0.2" | ||
}, | ||
@@ -62,0 +62,0 @@ "peerDependencies": { |
# chartjs-chart-matrix | ||
[Chart.js](https://www.chartjs.org/) **v3.0.0-alpha.2** module for creating matrix charts | ||
[Chart.js](https://www.chartjs.org/) **v3.0.0-beta.3** module for creating matrix charts | ||
@@ -5,0 +5,0 @@ ![npm](https://img.shields.io/npm/v/chartjs-chart-matrix.svg) [![release](https://img.shields.io/github/release/kurkle/chartjs-chart-matrix.svg?style=flat-square)](https://github.com/kurkle/chartjs-chart-matrix/releases/latest) [![travis](https://img.shields.io/travis/kurkle/chartjs-chart-matrix.svg?style=flat-square&maxAge=60)](https://travis-ci.org/kurkle/chartjs-chart-matrix) ![npm bundle size](https://img.shields.io/bundlephobia/min/chartjs-chart-matrix.svg) ![GitHub](https://img.shields.io/github/license/kurkle/chartjs-chart-matrix.svg) |
23691
509