@sgratzl/chartjs-chart-boxplot
Advanced tools
Comparing version 3.0.0-alpha.2 to 3.0.0-alpha.3
import ChartNS from 'chart.js'; | ||
const Chart = ChartNS; | ||
const plugins = ChartNS.plugins; | ||
const controllers = ChartNS.controllers; | ||
// export const plugins = ChartNS.plugins; | ||
const defaults = ChartNS.defaults; | ||
const helpers = ChartNS.helpers; | ||
// export const scaleService = ChartNS.scaleService; | ||
// export const DataSetController = ChartNS.DataSetController; | ||
const BarController = controllers.bar; | ||
const HorizontalBarController = controllers.horizontalBar; | ||
// export const LineController = controllers.line; | ||
// export const PolarAreaController = controllers.polarArea; | ||
// export const ScatterController = controllers.scatter; | ||
// export const Scale = ChartNS.Scale; | ||
// export const LinearScale = ChartNS.scaleService.getScaleConstructor('linear'); | ||
// export const LogarithmicScale = ChartNS.scaleService.getScaleConstructor('logarithmic'); | ||
// export const CategoryScale = ChartNS.scaleService.getScaleConstructor('category'); | ||
// export const DatasetController = ChartNS.DatasetController; | ||
const BarController = ChartNS.controllers.bar; | ||
// export const BubbleController = ChartNS.controllers.bubble; | ||
const HorizontalBarController = ChartNS.controllers.horizontalBar; | ||
// export const LineController = ChartNS.controllers.line; | ||
// export const PolarAreaController = ChartNS.controllers.polarArea; | ||
// export const ScatterController = ChartNS.controllers.scatter; | ||
function registerController(controller) { | ||
ChartNS.controllers[controller.id] = controller; | ||
defaults.set(controller.id, controller.defaults); | ||
return controller; | ||
} | ||
const Element = ChartNS.Element; | ||
@@ -21,6 +30,36 @@ // export const Rectangle = ChartNS.elements.Rectangle; | ||
// export const Line = ChartNS.elements.Line; | ||
// export const Arc = ChartNS.elements.Arc; | ||
function registerElement(element) { | ||
defaults.set('elements', { | ||
[element.id]: element.defaults, | ||
}); | ||
return element; | ||
} | ||
const merge = ChartNS.helpers.merge; | ||
const drawPoint = ChartNS.helpers.canvas.drawPoint; | ||
// export const resolve = ChartNS.helpers.options.resolve; | ||
// export const color = ChartNS.helpers.color; | ||
// export const valueOrDefault = ChartNS.helpers.valueOrDefault; | ||
// export const clipArea = ChartNS.helpers.canvas.clipArea; | ||
// export const unclipArea = ChartNS.helpers.canvas.unclipArea; | ||
// export const _parseFont = ChartNS.helpers.options._parseFont; | ||
// export const splineCurve = ChartNS.helpers.curve.splineCurve; | ||
function patchControllerConfig(config, controller) { | ||
controller.register(); | ||
config.type = controller.id; | ||
return config; | ||
} | ||
function registerTooltipPositioner(positioner) { | ||
// register my position logic | ||
const tooltip = ChartNS.plugins.getAll().find((d) => d.id === 'tooltip'); | ||
if (tooltip) { | ||
tooltip.positioners[positioner.id] = positioner; | ||
} | ||
return positioner; | ||
} | ||
// See <http://en.wikipedia.org/wiki/Kernel_(statistics)>. | ||
@@ -788,12 +827,8 @@ | ||
BoxAndWiskers._type = 'boxandwhiskers'; | ||
BoxAndWiskers.register = () => { | ||
defaults.set('elements', { | ||
[BoxAndWiskers._type]: Object.assign({}, defaults.elements.rectangle, baseDefaults, { | ||
medianColor: 'transparent', | ||
lowerBackgroundColor: 'transparent', | ||
}), | ||
}); | ||
return BoxAndWiskers; | ||
}; | ||
BoxAndWiskers.id = BoxAndWiskers._type = 'boxandwhiskers'; | ||
BoxAndWiskers.defaults = Object.assign({}, defaults.elements.rectangle, baseDefaults, { | ||
medianColor: 'transparent', | ||
lowerBackgroundColor: 'transparent', | ||
}); | ||
BoxAndWiskers.register = () => registerElement(BoxAndWiskers); | ||
@@ -889,9 +924,5 @@ class ViolinElement extends StatsBase { | ||
ViolinElement._type = 'violin'; | ||
ViolinElement.register = () => { | ||
defaults.set('elements', { | ||
[ViolinElement._type]: Object.assign({}, defaults.elements.rectangle, baseDefaults), | ||
}); | ||
return ViolinElement; | ||
}; | ||
ViolinElement.id = ViolinElement._type = 'violin'; | ||
ViolinElement.defaults = Object.assign({}, defaults.elements.rectangle, baseDefaults); | ||
ViolinElement.register = () => registerElement(ViolinElement); | ||
@@ -965,8 +996,3 @@ const interpolators = { | ||
outlierPositioner.id = 'averageInstance'; | ||
outlierPositioner.register = () => { | ||
// register my position logic | ||
const tooltip = plugins.getAll().find((d) => d.id === 'tooltip'); | ||
tooltip.positioners[outlierPositioner.id] = outlierPositioner; | ||
return outlierPositioner; | ||
}; | ||
outlierPositioner.register = () => registerTooltipPositioner(outlierPositioner); | ||
@@ -1103,8 +1129,2 @@ function baseDefaults$1(keys) { | ||
function patchControllerConfig(config, controller) { | ||
controller.register(); | ||
config.type = controller.id; | ||
return config; | ||
} | ||
class BoxPlotController extends StatsBase$1 { | ||
@@ -1136,24 +1156,20 @@ _parseStats(value, config) { | ||
defaults.set( | ||
BoxPlotController.id, | ||
merge({}, [ | ||
defaults.bar, | ||
baseDefaults$1(boxOptionsKeys), | ||
{ | ||
datasets: { | ||
animation: { | ||
numbers: { | ||
type: 'number', | ||
properties: defaults.bar.datasets.animation.numbers.properties.concat( | ||
['q1', 'q3', 'min', 'max', 'median', 'whiskerMin', 'whiskerMax'], | ||
boxOptionsKeys.filter((c) => !c.endsWith('Color')) | ||
), | ||
}, | ||
BoxPlotController.defaults = merge({}, [ | ||
defaults.bar, | ||
baseDefaults$1(boxOptionsKeys), | ||
{ | ||
datasets: { | ||
animation: { | ||
numbers: { | ||
type: 'number', | ||
properties: defaults.bar.datasets.animation.numbers.properties.concat( | ||
['q1', 'q3', 'min', 'max', 'median', 'whiskerMin', 'whiskerMax'], | ||
boxOptionsKeys.filter((c) => !c.endsWith('Color')) | ||
), | ||
}, | ||
}, | ||
}, | ||
]) | ||
); | ||
controllers[BoxPlotController.id] = BoxPlotController; | ||
return BoxPlotController; | ||
}, | ||
]); | ||
return registerController(BoxPlotController); | ||
}; | ||
@@ -1184,24 +1200,20 @@ | ||
defaults.set( | ||
HorizontalBoxPlotController.id, | ||
merge({}, [ | ||
defaults.horizontalBar, | ||
baseDefaults$1(boxOptionsKeys), | ||
{ | ||
datasets: { | ||
animation: { | ||
numbers: { | ||
type: 'number', | ||
properties: defaults.bar.datasets.animation.numbers.properties.concat( | ||
['q1', 'q3', 'min', 'max', 'median', 'whiskerMin', 'whiskerMax'], | ||
boxOptionsKeys.filter((c) => !c.endsWith('Color')) | ||
), | ||
}, | ||
HorizontalBoxPlotController.defaults = merge({}, [ | ||
defaults.horizontalBar, | ||
baseDefaults$1(boxOptionsKeys), | ||
{ | ||
datasets: { | ||
animation: { | ||
numbers: { | ||
type: 'number', | ||
properties: defaults.bar.datasets.animation.numbers.properties.concat( | ||
['q1', 'q3', 'min', 'max', 'median', 'whiskerMin', 'whiskerMax'], | ||
boxOptionsKeys.filter((c) => !c.endsWith('Color')) | ||
), | ||
}, | ||
}, | ||
}, | ||
]) | ||
); | ||
controllers[HorizontalBoxPlotController.id] = HorizontalBoxPlotController; | ||
return HorizontalBoxPlotController; | ||
}, | ||
]); | ||
return registerController(HorizontalBoxPlotController); | ||
}; | ||
@@ -1246,29 +1258,25 @@ | ||
defaults.set( | ||
ViolinController.id, | ||
helpers.merge({}, [ | ||
defaults.bar, | ||
baseDefaults$1(baseOptionKeys), | ||
{ | ||
datasets: { | ||
points: 100, | ||
animation: { | ||
numbers: { | ||
type: 'number', | ||
properties: defaults.bar.datasets.animation.numbers.properties.concat( | ||
['q1', 'q3', 'min', 'max', 'median', 'maxEstimate'], | ||
baseOptionKeys.filter((c) => !c.endsWith('Color')) | ||
), | ||
}, | ||
kdeCoords: { | ||
fn: interpolateKdeCoords, | ||
properties: ['coords'], | ||
}, | ||
ViolinController.defaults = merge({}, [ | ||
defaults.bar, | ||
baseDefaults$1(baseOptionKeys), | ||
{ | ||
datasets: { | ||
points: 100, | ||
animation: { | ||
numbers: { | ||
type: 'number', | ||
properties: defaults.bar.datasets.animation.numbers.properties.concat( | ||
['q1', 'q3', 'min', 'max', 'median', 'maxEstimate'], | ||
baseOptionKeys.filter((c) => !c.endsWith('Color')) | ||
), | ||
}, | ||
kdeCoords: { | ||
fn: interpolateKdeCoords, | ||
properties: ['coords'], | ||
}, | ||
}, | ||
}, | ||
]) | ||
); | ||
controllers[ViolinController.id] = ViolinController; | ||
return ViolinController; | ||
}, | ||
]); | ||
return registerController(ViolinController); | ||
}; | ||
@@ -1299,29 +1307,25 @@ | ||
defaults.set( | ||
HorizontalViolinController.id, | ||
helpers.merge({}, [ | ||
defaults.horizontalBar, | ||
baseDefaults$1(baseOptionKeys), | ||
{ | ||
datasets: { | ||
points: 100, | ||
animation: { | ||
numbers: { | ||
type: 'number', | ||
properties: defaults.bar.datasets.animation.numbers.properties.concat( | ||
['q1', 'q3', 'min', 'max', 'median', 'maxEstimate'], | ||
baseOptionKeys.filter((c) => !c.endsWith('Color')) | ||
), | ||
}, | ||
kdeCoords: { | ||
fn: interpolateKdeCoords, | ||
properties: ['coords'], | ||
}, | ||
HorizontalViolinController.defaults = merge({}, [ | ||
defaults.horizontalBar, | ||
baseDefaults$1(baseOptionKeys), | ||
{ | ||
datasets: { | ||
points: 100, | ||
animation: { | ||
numbers: { | ||
type: 'number', | ||
properties: defaults.bar.datasets.animation.numbers.properties.concat( | ||
['q1', 'q3', 'min', 'max', 'median', 'maxEstimate'], | ||
baseOptionKeys.filter((c) => !c.endsWith('Color')) | ||
), | ||
}, | ||
kdeCoords: { | ||
fn: interpolateKdeCoords, | ||
properties: ['coords'], | ||
}, | ||
}, | ||
}, | ||
]) | ||
); | ||
controllers[HorizontalViolinController.id] = HorizontalViolinController; | ||
return HorizontalViolinController; | ||
}, | ||
]); | ||
return registerController(HorizontalViolinController); | ||
}; | ||
@@ -1328,0 +1332,0 @@ |
@@ -9,19 +9,2 @@ (function (global, factory) { | ||
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; | ||
} | ||
return obj; | ||
} | ||
var defineProperty = _defineProperty; | ||
function _classCallCheck(instance, Constructor) { | ||
@@ -138,21 +121,74 @@ if (!(instance instanceof Constructor)) { | ||
var Chart = ChartNS; | ||
var plugins = ChartNS.plugins; | ||
var controllers = ChartNS.controllers; | ||
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; | ||
} | ||
return obj; | ||
} | ||
var defineProperty = _defineProperty; | ||
var Chart = ChartNS; // export const plugins = ChartNS.plugins; | ||
var defaults = ChartNS.defaults; | ||
var helpers = ChartNS.helpers; // export const scaleService = ChartNS.scaleService; | ||
// export const DataSetController = ChartNS.DataSetController; | ||
// export const LinearScale = ChartNS.scaleService.getScaleConstructor('linear'); | ||
// export const LogarithmicScale = ChartNS.scaleService.getScaleConstructor('logarithmic'); | ||
// export const CategoryScale = ChartNS.scaleService.getScaleConstructor('category'); | ||
// export const DatasetController = ChartNS.DatasetController; | ||
var BarController = controllers.bar; | ||
var HorizontalBarController = controllers.horizontalBar; // export const LineController = controllers.line; | ||
// export const PolarAreaController = controllers.polarArea; | ||
// export const ScatterController = controllers.scatter; | ||
var BarController = ChartNS.controllers.bar; // export const BubbleController = ChartNS.controllers.bubble; | ||
var HorizontalBarController = ChartNS.controllers.horizontalBar; // export const LineController = ChartNS.controllers.line; | ||
// export const PolarAreaController = ChartNS.controllers.polarArea; | ||
// export const ScatterController = ChartNS.controllers.scatter; | ||
function registerController(controller) { | ||
ChartNS.controllers[controller.id] = controller; | ||
defaults.set(controller.id, controller.defaults); | ||
return controller; | ||
} | ||
var Element = ChartNS.Element; // export const Rectangle = ChartNS.elements.Rectangle; | ||
// export const Point = ChartNS.elements.Point; | ||
// export const Line = ChartNS.elements.Line; | ||
// export const Arc = ChartNS.elements.Arc; | ||
function registerElement(element) { | ||
defaults.set('elements', defineProperty({}, element.id, element.defaults)); | ||
return element; | ||
} | ||
var merge = ChartNS.helpers.merge; | ||
var drawPoint = ChartNS.helpers.canvas.drawPoint; | ||
var drawPoint = ChartNS.helpers.canvas.drawPoint; // export const resolve = ChartNS.helpers.options.resolve; | ||
// export const color = ChartNS.helpers.color; | ||
// export const valueOrDefault = ChartNS.helpers.valueOrDefault; | ||
// export const clipArea = ChartNS.helpers.canvas.clipArea; | ||
// export const unclipArea = ChartNS.helpers.canvas.unclipArea; | ||
// export const _parseFont = ChartNS.helpers.options._parseFont; | ||
// export const splineCurve = ChartNS.helpers.curve.splineCurve; | ||
function patchControllerConfig(config, controller) { | ||
controller.register(); | ||
config.type = controller.id; | ||
return config; | ||
} | ||
function registerTooltipPositioner(positioner) { | ||
// register my position logic | ||
var tooltip = ChartNS.plugins.getAll().find(function (d) { | ||
return d.id === 'tooltip'; | ||
}); | ||
if (tooltip) { | ||
tooltip.positioners[positioner.id] = positioner; | ||
} | ||
return positioner; | ||
} | ||
// See <http://en.wikipedia.org/wiki/Kernel_(statistics)>. | ||
@@ -1043,10 +1079,10 @@ function gaussian(u) { | ||
}(StatsBase); | ||
BoxAndWiskers._type = 'boxandwhiskers'; | ||
BoxAndWiskers.id = BoxAndWiskers._type = 'boxandwhiskers'; | ||
BoxAndWiskers.defaults = Object.assign({}, defaults.elements.rectangle, baseDefaults, { | ||
medianColor: 'transparent', | ||
lowerBackgroundColor: 'transparent' | ||
}); | ||
BoxAndWiskers.register = function () { | ||
defaults.set('elements', defineProperty({}, BoxAndWiskers._type, Object.assign({}, defaults.elements.rectangle, baseDefaults, { | ||
medianColor: 'transparent', | ||
lowerBackgroundColor: 'transparent' | ||
}))); | ||
return BoxAndWiskers; | ||
return registerElement(BoxAndWiskers); | ||
}; | ||
@@ -1170,7 +1206,7 @@ | ||
}(StatsBase); | ||
ViolinElement._type = 'violin'; | ||
ViolinElement.id = ViolinElement._type = 'violin'; | ||
ViolinElement.defaults = Object.assign({}, defaults.elements.rectangle, baseDefaults); | ||
ViolinElement.register = function () { | ||
defaults.set('elements', defineProperty({}, ViolinElement._type, Object.assign({}, defaults.elements.rectangle, baseDefaults))); | ||
return ViolinElement; | ||
return registerElement(ViolinElement); | ||
}; | ||
@@ -1293,8 +1329,3 @@ | ||
outlierPositioner.register = function () { | ||
// register my position logic | ||
var tooltip = plugins.getAll().find(function (d) { | ||
return d.id === 'tooltip'; | ||
}); | ||
tooltip.positioners[outlierPositioner.id] = outlierPositioner; | ||
return outlierPositioner; | ||
return registerTooltipPositioner(outlierPositioner); | ||
}; | ||
@@ -1482,8 +1513,2 @@ | ||
function patchControllerConfig(config, controller) { | ||
controller.register(); | ||
config.type = controller.id; | ||
return config; | ||
} | ||
function _createSuper$4(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$4(); return function () { var Super = getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn(this, result); }; } | ||
@@ -1538,3 +1563,3 @@ | ||
BoxPlotController.prototype.dataElementOptions = BarController.prototype.dataElementOptions.concat(boxOptionsKeys); | ||
defaults.set(BoxPlotController.id, merge({}, [defaults.bar, baseDefaults$1(boxOptionsKeys), { | ||
BoxPlotController.defaults = merge({}, [defaults.bar, baseDefaults$1(boxOptionsKeys), { | ||
datasets: { | ||
@@ -1550,5 +1575,4 @@ animation: { | ||
} | ||
}])); | ||
controllers[BoxPlotController.id] = BoxPlotController; | ||
return BoxPlotController; | ||
}]); | ||
return registerController(BoxPlotController); | ||
}; | ||
@@ -1600,3 +1624,3 @@ | ||
HorizontalBoxPlotController.prototype.dataElementOptions = HorizontalBarController.prototype.dataElementOptions.concat(boxOptionsKeys); | ||
defaults.set(HorizontalBoxPlotController.id, merge({}, [defaults.horizontalBar, baseDefaults$1(boxOptionsKeys), { | ||
HorizontalBoxPlotController.defaults = merge({}, [defaults.horizontalBar, baseDefaults$1(boxOptionsKeys), { | ||
datasets: { | ||
@@ -1612,5 +1636,4 @@ animation: { | ||
} | ||
}])); | ||
controllers[HorizontalBoxPlotController.id] = HorizontalBoxPlotController; | ||
return HorizontalBoxPlotController; | ||
}]); | ||
return registerController(HorizontalBoxPlotController); | ||
}; | ||
@@ -1692,3 +1715,3 @@ | ||
ViolinController.prototype.dataElementOptions = BarController.prototype.dataElementOptions.concat(baseOptionKeys); | ||
defaults.set(ViolinController.id, helpers.merge({}, [defaults.bar, baseDefaults$1(baseOptionKeys), { | ||
ViolinController.defaults = merge({}, [defaults.bar, baseDefaults$1(baseOptionKeys), { | ||
datasets: { | ||
@@ -1709,5 +1732,4 @@ points: 100, | ||
} | ||
}])); | ||
controllers[ViolinController.id] = ViolinController; | ||
return ViolinController; | ||
}]); | ||
return registerController(ViolinController); | ||
}; | ||
@@ -1759,3 +1781,3 @@ | ||
HorizontalViolinController.prototype.dataElementOptions = HorizontalViolinController.prototype.dataElementOptions.concat(baseOptionKeys); | ||
defaults.set(HorizontalViolinController.id, helpers.merge({}, [defaults.horizontalBar, baseDefaults$1(baseOptionKeys), { | ||
HorizontalViolinController.defaults = merge({}, [defaults.horizontalBar, baseDefaults$1(baseOptionKeys), { | ||
datasets: { | ||
@@ -1776,5 +1798,4 @@ points: 100, | ||
} | ||
}])); | ||
controllers[HorizontalViolinController.id] = HorizontalViolinController; | ||
return HorizontalViolinController; | ||
}]); | ||
return registerController(HorizontalViolinController); | ||
}; | ||
@@ -1781,0 +1802,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("chart.js")):"function"==typeof define&&define.amd?define(["exports","chart.js"],e):e((t=t||self).ChartBoxPlot={},t.Chart)}(this,function(t,e){"use strict";e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;var r=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t};var n=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function i(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)}}var o=function(t,e,r){return e&&i(t.prototype,e),r&&i(t,r),t};function a(t,e){return t(e={exports:{}},e.exports),e.exports}var u=a(function(t){function e(r,n){return t.exports=e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},e(r,n)}t.exports=e});var s=function(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)},l=a(function(t){function e(r){"@babel/helpers - typeof";return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=e=function(t){return typeof t}:t.exports=e=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(r)}t.exports=e});var c=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t};var f=function(t,e){return!e||"object"!==l(e)&&"function"!=typeof e?c(t):e},h=a(function(t){function e(r){return t.exports=e=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},e(r)}t.exports=e}),d=e,p=e.plugins,m=e.controllers,y=e.defaults,v=e.helpers,g=m.bar,x=m.horizontalBar,b=e.Element,k=e.helpers.merge,w=e.helpers.canvas.drawPoint;function q(t){return 1/Math.sqrt(2*Math.PI)*Math.exp(-.5*t*t)}function _(t,e){return t-e}function M(t){var e=function(t,e){var r=(t=t.slice().sort(_)).length-1;return e.map(function(e){if(0===e)return t[0];if(1===e)return t[r];var n=1+e*r,i=Math.floor(n),o=n-i,a=t[i-1];return 0===o?a:a+o*(t[i]-a)})}(t,[.25,.75]);return e[1]-e[0]}function P(t){var e=M(t)/1.34;return 1.06*Math.min(Math.sqrt(function(t){var e=t.length;if(e<1)return NaN;if(1===e)return 0;for(var r=function(t){var e=t.length;if(0===e)return NaN;for(var r=0,n=-1;++n<e;)r+=(t[n]-r)/(n+1);return r}(t),n=-1,i=0;++n<e;){var o=t[n]-r;i+=o*o}return i/(e-1)}(t)),e)*Math.pow(t.length,-.2)}function R(t,e){var r=t.length-1,n=function(n){var i=n*r,o=Math.floor(i),a=i-o,u=t[o];return 0===a?u:e(u,t[Math.min(o+1,r)],a)};return{min:t[0],q1:n(.25),median:n(.5),q3:n(.75),max:t[r]}}function S(t){return R(t,function(t,e,r){return t+r*(e-t)})}function C(t){return R(t,function(t,e,r){return t+(e-t)*r})}function O(t){return R(t,function(t){return t})}function B(t){return R(t,function(t,e){return e})}function T(t){return R(t,function(t,e,r){return r<.5?t:e})}function E(t){return R(t,function(t,e){return.5*(t+e)})}function I(t){var e=t.length,r=Math.floor((e+3)/2)/2,n=function(e){return.5*(t[Math.floor(e)-1]+t[Math.ceil(e)-1])};return{min:t[0],q1:n(r),median:n((e+1)/2),q3:n(e+1-r),max:t[e-1]}}function N(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.5,n=t.q3-t.q1,i="number"==typeof r&&r>0,o=i?Math.max(t.min,t.q1-r*n):t.min,a=i?Math.min(t.max,t.q3+r*n):t.max;if(Array.isArray(e)){for(var u=0;u<e.length;u++){var s=e[u];if(s>=o){o=s;break}}for(var l=e.length-1;l>=0;l--){var c=e[l];if(c<=a){a=c;break}}}return{whiskerMin:o,whiskerMax:a}}var A={coef:1.5,quantiles:7};function V(t){return{coef:null==t||"number"!=typeof t.coef?A.coef:t.coef,quantiles:function(t){return"function"==typeof t?t:{hinges:I,fivenum:I,7:S,quantiles:S,linear:C,lower:O,higher:B,nearest:T,midpoint:E}[t]||S}(null==t?null:t.quantiles)}}function D(t,e){if(0===t.length)return{};(t=t.filter(function(t){return"number"==typeof t&&!Number.isNaN(t)})).sort(function(t,e){return t-e});for(var r=(0,V(e).quantiles)(t),n=function(){var t=q,e=[],r=P;function n(n,i){var o=r.call(this,e);return n.map(function(r){for(var n=-1,i=0,a=e.length;++n<a;)i+=t((r-e[n])/o);return[r,i/o/a]})}return n.kernel=function(e){return arguments.length?(t=e,n):t},n.sample=function(t){return arguments.length?(e=t,n):e},n.bandwidth=function(t){return arguments.length?(r="function"==typeof(e=t)?e:function(){return e},n):r;var e},n}().sample(t),i=[],o=(r.max-r.min)/e.points,a=r.min;a<=r.max&&o>0;a+=o)i.push(a);return i[i.length-1]!==r.max&&i.push(r.max),r.items=t,r.coords=n(i).map(function(t){return{v:t[0],estimate:t[1]}}),r.maxEstimate=r.coords.reduce(function(t,e){return Math.max(t,e.estimate)},Number.NEGATIVE_INFINITY),r}function W(t,e){if(!t)return null;if("number"==typeof t.median&&"number"==typeof t.q1&&"number"==typeof t.q3){if(void 0===t.whiskerMin){var r=V(e).coef,n=N(t,Array.isArray(t.items)?t.items.slice().sort(function(t,e){return t-e}):null,r),i=n.whiskerMin,o=n.whiskerMax;t.whiskerMin=i,t.whiskerMax=o}return t}return Array.isArray(t)?function(t,e){if(0===t.length)return{min:NaN,max:NaN,median:NaN,q1:NaN,q3:NaN,whiskerMin:NaN,whiskerMax:NaN,outliers:[]};(t=t.filter(function(t){return"number"==typeof t&&!Number.isNaN(t)})).sort(function(t,e){return t-e});var r=V(e),n=r.quantiles,i=r.coef,o=n(t),a=N(o,t,i),u=a.whiskerMin,s=a.whiskerMax;return o.outliers=t.filter(function(t){return t<u||t>s}),o.whiskerMin=u,o.whiskerMax=s,o.items=t,o}(t,e):void 0}function j(t){var e=function(){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}}();return function(){var r,n=h(t);if(e){var i=h(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}var H={borderWidth:1,outlierStyle:"circle",outlierRadius:2,outlierBackgroundColor:y.elements.rectangle.backgroundColor,outlierBorderColor:y.elements.rectangle.borderColor,outlierBorderWidth:1,itemStyle:"circle",itemRadius:0,itemBackgroundColor:y.elements.rectangle.backgroundColor,itemBorderColor:y.elements.rectangle.borderColor,itemBorderWidth:0,hitPadding:2,outlierHitRadius:4},z=Object.keys(H),L=function(t){s(r,b);var e=j(r);function r(){return n(this,r),e.apply(this,arguments)}return o(r,[{key:"isVertical",value:function(){return null==this.height}},{key:"_drawItems",value:function(t){var e=this.isVertical(),r=this.getProps(["x","y","items","width","height"]),n=this.options;if(!(n.itemRadius<=0||!r.items||r.items.length<=0)){t.save(),t.strokeStyle=n.itemBorderColor,t.fillStyle=n.itemBackgroundColor,t.lineWith=n.itemBorderWidth;var i,o=(void 0===(i=1e3*this._datasetIndex+this._index)&&(i=Date.now()),function(){return(i=(9301*i+49297)%233280)/233280}),a={pointStyle:n.itemStyle,radius:n.itemRadius,borderWidth:n.itemBorderWidth};e?r.items.forEach(function(e){w(t,a,r.x-r.width/2+o()*r.width,e)}):r.items.forEach(function(e){w(t,a,e,r.y-r.height/2+o()*r.height)}),t.restore()}}},{key:"_drawOutliers",value:function(t){var e=this.isVertical(),r=this.getProps(["x","y","outliers"]),n=this.options;if(!(n.outlierRadius<=0)&&r.outliers&&0!==r.outliers.length){t.save(),t.fillStyle=n.outlierBackgroundColor,t.strokeStyle=n.outlierBorderColor,t.lineWidth=n.outlierBorderWidth;var i={pointStyle:n.outlierStyle,radius:n.outlierRadius,borderWidth:n.outlierBorderWidth};e?r.outliers.forEach(function(e){w(t,i,r.x,e)}):r.outliers.forEach(function(e){w(t,i,e,r.y)}),t.restore()}}},{key:"_getBounds",value:function(t){return{left:0,top:0,right:0,bottom:0}}},{key:"_getHitBounds",value:function(t){var e=this.options.hitPadding,r=this._getBounds(t);return{left:r.left-e,top:r.top-e,right:r.right+e,bottom:r.bottom+e}}},{key:"inRange",value:function(t,e,r){return(!Number.isNaN(this.x)||!Number.isNaN(this.y))&&(this._boxInRange(t,e,r)||this._outlierIndexInRange(t,e,r)>=0)}},{key:"inXRange",value:function(t,e){var r=this._getHitBounds(e);return t>=r.left&&t<=r.right}},{key:"inYRange",value:function(t,e){var r=this._getHitBounds(e);return t>=r.top&&t<=r.bottom}},{key:"_outlierIndexInRange",value:function(t,e,r){var n=this.getProps(["x","y"],r),i=this.options.outlierHitRadius,o=this._getOutliers(r),a=this.isVertical();if(a&&Math.abs(t-n.x)>i||!a&&Math.abs(e-n.y)>i)return-1;for(var u=a?e:t,s=0;s<o.length;s++)if(Math.abs(o[s]-u)<=i)return s;return-1}},{key:"_boxInRange",value:function(t,e,r){var n=this._getHitBounds(r);return t>=n.left&&t<=n.right&&e>=n.top&&e<=n.bottom}},{key:"getCenterPoint",value:function(t){var e=this.getProps(["x","y"],t);return{x:e.x,y:e.y}}},{key:"_getOutliers",value:function(t){return this.getProps(["outliers"],t).outliers||[]}},{key:"tooltipPosition",value:function(t,e){if(!t)return this.getCenterPoint();delete e._tooltipOutlier;var r=this.getProps(["x","y"]),n=this._outlierIndexInRange(t.x,t.y);return n<0?this.getCenterPoint():(e._tooltipOutlier={index:n,datasetIndex:this._datasetIndex},this.isVertical()?{x:r.x,y:this._getOutliers()[n]}:{x:this._getOutliers()[n],y:r.y})}}]),r}();function F(t){var e=function(){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}}();return function(){var r,n=h(t);if(e){var i=h(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}var Y=z.concat(["medianColor","lowerBackgroundColor"]),G=function(t){s(r,L);var e=F(r);function r(){return n(this,r),e.apply(this,arguments)}return o(r,[{key:"draw",value:function(t){t.save(),t.fillStyle=this.options.backgroundColor,t.strokeStyle=this.options.borderColor,t.lineWidth=this.options.borderWidth,this._drawBoxPlot(t),this._drawOutliers(t),t.restore(),this._drawItems(t)}},{key:"_drawBoxPlot",value:function(t){this.isVertical()?this._drawBoxPlotVertical(t):this._drawBoxPlotHorizontal(t)}},{key:"_drawBoxPlotVertical",value:function(t){var e=this.options,r=this.getProps(["x","width","q1","q3","median","whiskerMin","whiskerMax"]),n=r.x,i=r.width,o=n-i/2;r.q3>r.q1?t.fillRect(o,r.q1,i,r.q3-r.q1):t.fillRect(o,r.q3,i,r.q1-r.q3),t.save(),e.medianColor&&"none"!==e.medianColor&&(t.strokeStyle=e.medianColor),t.beginPath(),t.moveTo(o,r.median),t.lineTo(o+i,r.median),t.closePath(),t.stroke(),t.restore(),t.save(),e.lowerBackgroundColor&&"none"!==e.lowerBackgroundColor&&(t.fillStyle=e.lowerBackgroundColor,r.q3>r.q1?t.fillRect(o,r.median,i,r.q3-r.median):t.fillRect(o,r.median,i,r.q1-r.median)),t.restore(),r.q3>r.q1?t.strokeRect(o,r.q1,i,r.q3-r.q1):t.strokeRect(o,r.q3,i,r.q1-r.q3),t.beginPath(),t.moveTo(o,r.whiskerMin),t.lineTo(o+i,r.whiskerMin),t.moveTo(n,r.whiskerMin),t.lineTo(n,r.q1),t.moveTo(o,r.whiskerMax),t.lineTo(o+i,r.whiskerMax),t.moveTo(n,r.whiskerMax),t.lineTo(n,r.q3),t.closePath(),t.stroke()}},{key:"_drawBoxPlotHorizontal",value:function(t){var e=this.options,r=this.getProps(["y","height","q1","q3","median","whiskerMin","whiskerMax"]),n=r.y,i=r.height,o=n-i/2;r.q3>r.q1?t.fillRect(r.q1,o,r.q3-r.q1,i):t.fillRect(r.q3,o,r.q1-r.q3,i),t.save(),e.medianColor&&"transparent"!==e.medianColor&&(t.strokeStyle=e.medianColor),t.beginPath(),t.moveTo(r.median,o),t.lineTo(r.median,o+i),t.closePath(),t.stroke(),t.restore(),t.save(),e.lowerBackgroundColor&&"transparent"!==e.lowerBackgroundColor&&(t.fillStyle=e.lowerBackgroundColor,r.q3>r.q1?t.fillRect(r.median,o,r.q3-r.median,i):t.fillRect(r.median,o,r.q1-r.median,i)),t.restore(),r.q3>r.q1?t.strokeRect(r.q1,o,r.q3-r.q1,i):t.strokeRect(r.q3,o,r.q1-r.q3,i),t.beginPath(),t.moveTo(r.whiskerMin,o),t.lineTo(r.whiskerMin,o+i),t.moveTo(r.whiskerMin,n),t.lineTo(r.q1,n),t.moveTo(r.whiskerMax,o),t.lineTo(r.whiskerMax,o+i),t.moveTo(r.whiskerMax,n),t.lineTo(r.q3,n),t.closePath(),t.stroke()}},{key:"_getBounds",value:function(t){var e=this.isVertical();if(null==this.x)return{left:0,top:0,right:0,bottom:0};if(e){var r=this.getProps(["x","width","whiskerMin","whiskerMax"],t),n=r.x,i=r.width,o=n-i/2;return{left:o,top:r.whiskerMax,right:o+i,bottom:r.whiskerMin}}var a=this.getProps(["y","height","whiskerMin","whiskerMax"],t),u=a.y,s=a.height,l=a.whiskerMax,c=u-s/2;return{left:a.whiskerMin,top:c,right:l,bottom:c+s}}}]),r}();function K(t){var e=function(){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}}();return function(){var r,n=h(t);if(e){var i=h(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}G._type="boxandwhiskers",G.register=function(){return y.set("elements",r({},G._type,Object.assign({},y.elements.rectangle,H,{medianColor:"transparent",lowerBackgroundColor:"transparent"}))),G};var X=function(t){s(r,L);var e=K(r);function r(){return n(this,r),e.apply(this,arguments)}return o(r,[{key:"draw",value:function(t){t.save(),t.fillStyle=this.options.backgroundColor,t.strokeStyle=this.options.borderColor,t.lineWidth=this.options.borderWidth;var e=this.getProps(["x","y","width","height","min","max","coords","maxEstimate"]);w(t,{pointStyle:"rectRot",radius:5,borderWidth:this.options.borderWidth},e.x,e.y),e.coords&&e.coords.length>0&&this._drawCoords(t,e),this._drawOutliers(t),t.restore(),this._drawItems(t)}},{key:"_drawCoords",value:function(t,e){if(t.beginPath(),this.isVertical()){var r=e.x,n=e.width/2/e.maxEstimate;t.moveTo(r,e.min),e.coords.forEach(function(e){t.lineTo(r-e.estimate*n,e.v)}),t.lineTo(r,e.max),t.moveTo(r,e.min),e.coords.forEach(function(e){t.lineTo(r+e.estimate*n,e.v)}),t.lineTo(r,e.max)}else{var i=e.y,o=e.height/2/e.maxEstimate;t.moveTo(e.min,i),e.coords.forEach(function(e){t.lineTo(e.v,i-e.estimate*o)}),t.lineTo(e.max,i),t.moveTo(e.min,i),e.coords.forEach(function(e){t.lineTo(e.v,i+e.estimate*o)}),t.lineTo(e.max,i)}t.closePath(),t.stroke(),t.fill()}},{key:"_getBounds",value:function(t){if(this.isVertical()){var e=this.getProps(["x","width","min","max"],t),r=e.x,n=e.width,i=e.min,o=r-n/2;return{left:o,top:e.max,right:o+n,bottom:i}}var a=this.getProps(["y","height","min","max"],t),u=a.y,s=a.height,l=u-s/2;return{left:a.min,top:l,right:a.max,bottom:l+s}}}]),r}();X._type="violin",X.register=function(){return y.set("elements",r({},X._type,Object.assign({},y.elements.rectangle,H))),X};var J=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=h(t)););return t},Q=a(function(t){function e(r,n,i){return"undefined"!=typeof Reflect&&Reflect.get?t.exports=e=Reflect.get:t.exports=e=function(t,e,r){var n=J(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},e(r,n,i||r)}t.exports=e}),U={number:function(t,e,r){return t===e?e:null==t?e:null==e?t:t+(e-t)*r}};function Z(t,e,r){return"number"==typeof t&&"number"==typeof e?U.number(t,e,r):Array.isArray(t)&&Array.isArray(e)?e.map(function(e,n){return U.number(t[n],e,r)}):e}function $(t,e,r){return Array.isArray(t)&&Array.isArray(e)?e.map(function(e,n){return{v:U.number(t[n]?t[n].v:null,e.v,r),estimate:U.number(t[n]?t[n].estimate:null,e.estimate,r)}}):e}function tt(t){var e=t.value;e&&null!=this._tooltipOutlier&&t.datasetIndex===this._tooltipOutlier.datasetIndex&&(e.hoveredOutlierIndex=this._tooltipOutlier.index)}function et(t,e){if(!t.length)return!1;var r,n,i=0,o=0,a=0;for(r=0,n=t.length;r<n;++r){var u=t[r].element;if(u&&u.hasValue()){var s=u.tooltipPosition(e,this);i+=s.x,o+=s.y,++a}}return{x:i/a,y:o/a}}function rt(t){var e=function(){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}}();return function(){var r,n=h(t);if(e){var i=h(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}function nt(t){var e=["borderColor","backgroundColor"].concat(t.filter(function(t){return t.endsWith("Color")}));return{datasets:Object.assign({animation:{numberArray:{fn:Z,properties:["outliers","items"]},colors:{type:"color",properties:e},show:{colors:{type:"color",properties:e,from:"transparent"}},hide:{colors:{type:"color",properties:e,to:"transparent"}}},minStats:"min",maxStats:"max"},A),tooltips:{position:et.register().id,callbacks:{beforeLabel:tt}}}}et.id="averageInstance",et.register=function(){return p.getAll().find(function(t){return"tooltip"===t.id}).positioners[et.id]=et,et};var it=function(t){s(r,g);var e=rt(r);function r(){return n(this,r),e.apply(this,arguments)}return o(r,[{key:"getMinMax",value:function(t,e){var n=t.axis,i=this._config;t.axis=i.minStats;var o=Q(h(r.prototype),"getMinMax",this).call(this,t,e).min;t.axis=i.maxStats;var a=Q(h(r.prototype),"getMinMax",this).call(this,t,e).max;return t.axis=n,{min:o,max:a}}},{key:"parsePrimitiveData",value:function(t,e,r,n){for(var i=t.vScale,o=t.iScale,a=o.getLabels(),u=[],s=0;s<n;s++){var l=s+r,c={};c[o.axis]=o.parse(a[l],l);var f=this._parseStats(null==e?null:e[l],this._config);f&&(Object.assign(c,f),c[i.axis]=f.median),u.push(c)}return u}},{key:"parseArrayData",value:function(t,e,r,n){return this.parsePrimitiveData(t,e,r,n)}},{key:"parseObjectData",value:function(t,e,r,n){return this.parsePrimitiveData(t,e,r,n)}},{key:"_parseStats",value:function(t,e){return{}}},{key:"getLabelAndValue",value:function(t){var e=Q(h(r.prototype),"getLabelAndValue",this).call(this,t),n=this._cachedMeta.vScale,i=this.getParsed(t);if(!n||!i||"NaN"===e.value)return e;e.value={raw:i,hoveredOutlierIndex:-1},this._transformStats(e.value,i,function(t){return n.getLabelForValue(t)},"string");var o=this._toStringStats(e.value);return e.value.toString=function(){return this.hoveredOutlierIndex>=0?"(outlier: ".concat(this.outliers[this.hoveredOutlierIndex],")"):o},e}},{key:"_toStringStats",value:function(t){return""}},{key:"_transformStats",value:function(t,e,r,n){}},{key:"updateElement",value:function(t,e,n,i){var o="reset"===i,a=this._cachedMeta.vScale,u=this.getParsed(e),s=a.getBasePixel();n._datasetIndex=this.index,n._index=e,this._transformStats(n,u,function(t){return o?s:a.getPixelForValue(t)},i),Q(h(r.prototype),"updateElement",this).call(this,t,e,n,i)}}]),r}();function ot(t,e){return e.register(),t.type=e.id,t}function at(t){var e=function(){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}}();return function(){var r,n=h(t);if(e){var i=h(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}var ut=function(t){s(r,it);var e=at(r);function r(){return n(this,r),e.apply(this,arguments)}return o(r,[{key:"_parseStats",value:function(t,e){return W(t,e)}},{key:"_toStringStats",value:function(t){return"(min: ".concat(t.min,", 25% quantile: ").concat(t.q1,", median: ").concat(t.median,", 75% quantile: ").concat(t.q3,", max: ").concat(t.max,")")}},{key:"_transformStats",value:function(t,e,r){for(var n=0,i=["min","max","median","q3","q1","whiskerMin","whiskerMax"];n<i.length;n++){var o=i[n];t[o]=r(e[o])}for(var a=0,u=["outliers","items"];a<u.length;a++){var s=u[a];Array.isArray(e[s])&&(t[s]=e[s].map(r))}}}]),r}();ut.id="boxplot",ut.register=function(){return ut.prototype.dataElementType=G.register(),ut.prototype.dataElementOptions=g.prototype.dataElementOptions.concat(Y),y.set(ut.id,k({},[y.bar,nt(Y),{datasets:{animation:{numbers:{type:"number",properties:y.bar.datasets.animation.numbers.properties.concat(["q1","q3","min","max","median","whiskerMin","whiskerMax"],Y.filter(function(t){return!t.endsWith("Color")}))}}}}])),m[ut.id]=ut,ut};var st=function(t){s(r,d);var e=at(r);function r(t,i){return n(this,r),e.call(this,t,ot(i,ut))}return r}();st.id=ut.id;var lt=function(t){s(r,ut);var e=at(r);function r(){return n(this,r),e.apply(this,arguments)}return o(r,[{key:"getValueScaleId",value:function(){return this._cachedMeta.xAxisID}},{key:"getIndexScaleId",value:function(){return this._cachedMeta.yAxisID}}]),r}();lt.id="horizontalBoxplot",lt.register=function(){return lt.prototype.dataElementType=G.register(),lt.prototype.dataElementOptions=x.prototype.dataElementOptions.concat(Y),y.set(lt.id,k({},[y.horizontalBar,nt(Y),{datasets:{animation:{numbers:{type:"number",properties:y.bar.datasets.animation.numbers.properties.concat(["q1","q3","min","max","median","whiskerMin","whiskerMax"],Y.filter(function(t){return!t.endsWith("Color")}))}}}}])),m[lt.id]=lt,lt};var ct=function(t){s(r,d);var e=at(r);function r(t,i){return n(this,r),e.call(this,t,ot(i,lt))}return r}();function ft(t){var e=function(){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}}();return function(){var r,n=h(t);if(e){var i=h(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}ct.id=lt.id;var ht=function(t){s(r,it);var e=ft(r);function r(){return n(this,r),e.apply(this,arguments)}return o(r,[{key:"_parseStats",value:function(t,e){return function(t,e){return t?"number"==typeof t.median&&Array.isArray(t.coords)?t:Array.isArray(t)?D(t,e):void 0:null}(t,e)}},{key:"_toStringStats",value:function(t){return"(min: ".concat(t.min,", 25% quantile: ").concat(t.q1,", median: ").concat(t.median,", 75% quantile: ").concat(t.q3,", max: ").concat(t.max,")")}},{key:"_transformStats",value:function(t,e,r){for(var n=0,i=["min","max","median","q3","q1"];n<i.length;n++){var o=i[n];t[o]=r(e[o])}t.maxEstimate=e.maxEstimate;for(var a=0,u=["outliers","items"];a<u.length;a++){var s=u[a];Array.isArray(e[s])&&(t[s]=e[s].map(r))}Array.isArray(e.coords)&&(t.coords=e.coords.map(function(t){return Object.assign({},t,{v:r(t.v)})}))}}]),r}();ht.id="violin",ht.register=function(){return ht.prototype.dataElementType=X.register(),ht.prototype.dataElementOptions=g.prototype.dataElementOptions.concat(z),y.set(ht.id,v.merge({},[y.bar,nt(z),{datasets:{points:100,animation:{numbers:{type:"number",properties:y.bar.datasets.animation.numbers.properties.concat(["q1","q3","min","max","median","maxEstimate"],z.filter(function(t){return!t.endsWith("Color")}))},kdeCoords:{fn:$,properties:["coords"]}}}}])),m[ht.id]=ht,ht};var dt=function(t){s(r,d);var e=ft(r);function r(t,i){return n(this,r),e.call(this,t,ot(i,ht))}return r}();dt.id=ht.id;var pt=function(t){s(r,ht);var e=ft(r);function r(){return n(this,r),e.apply(this,arguments)}return o(r,[{key:"getValueScaleId",value:function(){return this._cachedMeta.xAxisID}},{key:"getIndexScaleId",value:function(){return this._cachedMeta.yAxisID}}]),r}();pt.id="horizontalViolin",pt.register=function(){return pt.prototype.dataElementType=X.register(),pt.prototype.dataElementOptions=pt.prototype.dataElementOptions.concat(z),y.set(pt.id,v.merge({},[y.horizontalBar,nt(z),{datasets:{points:100,animation:{numbers:{type:"number",properties:y.bar.datasets.animation.numbers.properties.concat(["q1","q3","min","max","median","maxEstimate"],z.filter(function(t){return!t.endsWith("Color")}))},kdeCoords:{fn:$,properties:["coords"]}}}}])),m[pt.id]=pt,pt};var mt=function(t){s(r,d);var e=ft(r);function r(t,i){return n(this,r),e.call(this,t,ot(i,pt))}return r}();mt.id=pt.id,ut.register(),lt.register(),ht.register(),pt.register(),t.BoxAndWiskers=G,t.BoxPlotChart=st,t.BoxPlotController=ut,t.HorizontalBoxPlotChart=ct,t.HorizontalBoxPlotController=lt,t.HorizontalViolinChart=mt,t.HorizontalViolinController=pt,t.ViolinChart=dt,t.ViolinController=ht,t.ViolinElement=X,t.boxOptionsKeys=Y,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("chart.js")):"function"==typeof define&&define.amd?define(["exports","chart.js"],e):e((t=t||self).ChartBoxPlot={},t.Chart)}(this,function(t,e){"use strict";e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;var r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function n(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)}}var i=function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t};function o(t,e){return t(e={exports:{}},e.exports),e.exports}var a=o(function(t){function e(r,n){return t.exports=e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},e(r,n)}t.exports=e});var u=function(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&&a(t,e)},s=o(function(t){function e(r){"@babel/helpers - typeof";return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=e=function(t){return typeof t}:t.exports=e=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(r)}t.exports=e});var l=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t};var c=function(t,e){return!e||"object"!==s(e)&&"function"!=typeof e?l(t):e},f=o(function(t){function e(r){return t.exports=e=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},e(r)}t.exports=e});var h=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t},d=e,p=e.defaults,m=e.controllers.bar,y=e.controllers.horizontalBar;function v(t){return e.controllers[t.id]=t,p.set(t.id,t.defaults),t}var g=e.Element;function x(t){return p.set("elements",h({},t.id,t.defaults)),t}var b=e.helpers.merge,k=e.helpers.canvas.drawPoint;function w(t,e){return e.register(),t.type=e.id,t}function q(t){return 1/Math.sqrt(2*Math.PI)*Math.exp(-.5*t*t)}function _(t,e){return t-e}function M(t){var e=function(t,e){var r=(t=t.slice().sort(_)).length-1;return e.map(function(e){if(0===e)return t[0];if(1===e)return t[r];var n=1+e*r,i=Math.floor(n),o=n-i,a=t[i-1];return 0===o?a:a+o*(t[i]-a)})}(t,[.25,.75]);return e[1]-e[0]}function P(t){var e=M(t)/1.34;return 1.06*Math.min(Math.sqrt(function(t){var e=t.length;if(e<1)return NaN;if(1===e)return 0;for(var r=function(t){var e=t.length;if(0===e)return NaN;for(var r=0,n=-1;++n<e;)r+=(t[n]-r)/(n+1);return r}(t),n=-1,i=0;++n<e;){var o=t[n]-r;i+=o*o}return i/(e-1)}(t)),e)*Math.pow(t.length,-.2)}function R(t,e){var r=t.length-1,n=function(n){var i=n*r,o=Math.floor(i),a=i-o,u=t[o];return 0===a?u:e(u,t[Math.min(o+1,r)],a)};return{min:t[0],q1:n(.25),median:n(.5),q3:n(.75),max:t[r]}}function S(t){return R(t,function(t,e,r){return t+r*(e-t)})}function C(t){return R(t,function(t,e,r){return t+(e-t)*r})}function O(t){return R(t,function(t){return t})}function B(t){return R(t,function(t,e){return e})}function T(t){return R(t,function(t,e,r){return r<.5?t:e})}function E(t){return R(t,function(t,e){return.5*(t+e)})}function I(t){var e=t.length,r=Math.floor((e+3)/2)/2,n=function(e){return.5*(t[Math.floor(e)-1]+t[Math.ceil(e)-1])};return{min:t[0],q1:n(r),median:n((e+1)/2),q3:n(e+1-r),max:t[e-1]}}function N(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.5,n=t.q3-t.q1,i="number"==typeof r&&r>0,o=i?Math.max(t.min,t.q1-r*n):t.min,a=i?Math.min(t.max,t.q3+r*n):t.max;if(Array.isArray(e)){for(var u=0;u<e.length;u++){var s=e[u];if(s>=o){o=s;break}}for(var l=e.length-1;l>=0;l--){var c=e[l];if(c<=a){a=c;break}}}return{whiskerMin:o,whiskerMax:a}}var A={coef:1.5,quantiles:7};function V(t){return{coef:null==t||"number"!=typeof t.coef?A.coef:t.coef,quantiles:function(t){return"function"==typeof t?t:{hinges:I,fivenum:I,7:S,quantiles:S,linear:C,lower:O,higher:B,nearest:T,midpoint:E}[t]||S}(null==t?null:t.quantiles)}}function D(t,e){if(0===t.length)return{};(t=t.filter(function(t){return"number"==typeof t&&!Number.isNaN(t)})).sort(function(t,e){return t-e});for(var r=(0,V(e).quantiles)(t),n=function(){var t=q,e=[],r=P;function n(n,i){var o=r.call(this,e);return n.map(function(r){for(var n=-1,i=0,a=e.length;++n<a;)i+=t((r-e[n])/o);return[r,i/o/a]})}return n.kernel=function(e){return arguments.length?(t=e,n):t},n.sample=function(t){return arguments.length?(e=t,n):e},n.bandwidth=function(t){return arguments.length?(r="function"==typeof(e=t)?e:function(){return e},n):r;var e},n}().sample(t),i=[],o=(r.max-r.min)/e.points,a=r.min;a<=r.max&&o>0;a+=o)i.push(a);return i[i.length-1]!==r.max&&i.push(r.max),r.items=t,r.coords=n(i).map(function(t){return{v:t[0],estimate:t[1]}}),r.maxEstimate=r.coords.reduce(function(t,e){return Math.max(t,e.estimate)},Number.NEGATIVE_INFINITY),r}function W(t,e){if(!t)return null;if("number"==typeof t.median&&"number"==typeof t.q1&&"number"==typeof t.q3){if(void 0===t.whiskerMin){var r=V(e).coef,n=N(t,Array.isArray(t.items)?t.items.slice().sort(function(t,e){return t-e}):null,r),i=n.whiskerMin,o=n.whiskerMax;t.whiskerMin=i,t.whiskerMax=o}return t}return Array.isArray(t)?function(t,e){if(0===t.length)return{min:NaN,max:NaN,median:NaN,q1:NaN,q3:NaN,whiskerMin:NaN,whiskerMax:NaN,outliers:[]};(t=t.filter(function(t){return"number"==typeof t&&!Number.isNaN(t)})).sort(function(t,e){return t-e});var r=V(e),n=r.quantiles,i=r.coef,o=n(t),a=N(o,t,i),u=a.whiskerMin,s=a.whiskerMax;return o.outliers=t.filter(function(t){return t<u||t>s}),o.whiskerMin=u,o.whiskerMax=s,o.items=t,o}(t,e):void 0}function j(t){var e=function(){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}}();return function(){var r,n=f(t);if(e){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return c(this,r)}}var H={borderWidth:1,outlierStyle:"circle",outlierRadius:2,outlierBackgroundColor:p.elements.rectangle.backgroundColor,outlierBorderColor:p.elements.rectangle.borderColor,outlierBorderWidth:1,itemStyle:"circle",itemRadius:0,itemBackgroundColor:p.elements.rectangle.backgroundColor,itemBorderColor:p.elements.rectangle.borderColor,itemBorderWidth:0,hitPadding:2,outlierHitRadius:4},z=Object.keys(H),L=function(t){u(n,g);var e=j(n);function n(){return r(this,n),e.apply(this,arguments)}return i(n,[{key:"isVertical",value:function(){return null==this.height}},{key:"_drawItems",value:function(t){var e=this.isVertical(),r=this.getProps(["x","y","items","width","height"]),n=this.options;if(!(n.itemRadius<=0||!r.items||r.items.length<=0)){t.save(),t.strokeStyle=n.itemBorderColor,t.fillStyle=n.itemBackgroundColor,t.lineWith=n.itemBorderWidth;var i,o=(void 0===(i=1e3*this._datasetIndex+this._index)&&(i=Date.now()),function(){return(i=(9301*i+49297)%233280)/233280}),a={pointStyle:n.itemStyle,radius:n.itemRadius,borderWidth:n.itemBorderWidth};e?r.items.forEach(function(e){k(t,a,r.x-r.width/2+o()*r.width,e)}):r.items.forEach(function(e){k(t,a,e,r.y-r.height/2+o()*r.height)}),t.restore()}}},{key:"_drawOutliers",value:function(t){var e=this.isVertical(),r=this.getProps(["x","y","outliers"]),n=this.options;if(!(n.outlierRadius<=0)&&r.outliers&&0!==r.outliers.length){t.save(),t.fillStyle=n.outlierBackgroundColor,t.strokeStyle=n.outlierBorderColor,t.lineWidth=n.outlierBorderWidth;var i={pointStyle:n.outlierStyle,radius:n.outlierRadius,borderWidth:n.outlierBorderWidth};e?r.outliers.forEach(function(e){k(t,i,r.x,e)}):r.outliers.forEach(function(e){k(t,i,e,r.y)}),t.restore()}}},{key:"_getBounds",value:function(t){return{left:0,top:0,right:0,bottom:0}}},{key:"_getHitBounds",value:function(t){var e=this.options.hitPadding,r=this._getBounds(t);return{left:r.left-e,top:r.top-e,right:r.right+e,bottom:r.bottom+e}}},{key:"inRange",value:function(t,e,r){return(!Number.isNaN(this.x)||!Number.isNaN(this.y))&&(this._boxInRange(t,e,r)||this._outlierIndexInRange(t,e,r)>=0)}},{key:"inXRange",value:function(t,e){var r=this._getHitBounds(e);return t>=r.left&&t<=r.right}},{key:"inYRange",value:function(t,e){var r=this._getHitBounds(e);return t>=r.top&&t<=r.bottom}},{key:"_outlierIndexInRange",value:function(t,e,r){var n=this.getProps(["x","y"],r),i=this.options.outlierHitRadius,o=this._getOutliers(r),a=this.isVertical();if(a&&Math.abs(t-n.x)>i||!a&&Math.abs(e-n.y)>i)return-1;for(var u=a?e:t,s=0;s<o.length;s++)if(Math.abs(o[s]-u)<=i)return s;return-1}},{key:"_boxInRange",value:function(t,e,r){var n=this._getHitBounds(r);return t>=n.left&&t<=n.right&&e>=n.top&&e<=n.bottom}},{key:"getCenterPoint",value:function(t){var e=this.getProps(["x","y"],t);return{x:e.x,y:e.y}}},{key:"_getOutliers",value:function(t){return this.getProps(["outliers"],t).outliers||[]}},{key:"tooltipPosition",value:function(t,e){if(!t)return this.getCenterPoint();delete e._tooltipOutlier;var r=this.getProps(["x","y"]),n=this._outlierIndexInRange(t.x,t.y);return n<0?this.getCenterPoint():(e._tooltipOutlier={index:n,datasetIndex:this._datasetIndex},this.isVertical()?{x:r.x,y:this._getOutliers()[n]}:{x:this._getOutliers()[n],y:r.y})}}]),n}();function F(t){var e=function(){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}}();return function(){var r,n=f(t);if(e){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return c(this,r)}}var Y=z.concat(["medianColor","lowerBackgroundColor"]),G=function(t){u(n,L);var e=F(n);function n(){return r(this,n),e.apply(this,arguments)}return i(n,[{key:"draw",value:function(t){t.save(),t.fillStyle=this.options.backgroundColor,t.strokeStyle=this.options.borderColor,t.lineWidth=this.options.borderWidth,this._drawBoxPlot(t),this._drawOutliers(t),t.restore(),this._drawItems(t)}},{key:"_drawBoxPlot",value:function(t){this.isVertical()?this._drawBoxPlotVertical(t):this._drawBoxPlotHorizontal(t)}},{key:"_drawBoxPlotVertical",value:function(t){var e=this.options,r=this.getProps(["x","width","q1","q3","median","whiskerMin","whiskerMax"]),n=r.x,i=r.width,o=n-i/2;r.q3>r.q1?t.fillRect(o,r.q1,i,r.q3-r.q1):t.fillRect(o,r.q3,i,r.q1-r.q3),t.save(),e.medianColor&&"none"!==e.medianColor&&(t.strokeStyle=e.medianColor),t.beginPath(),t.moveTo(o,r.median),t.lineTo(o+i,r.median),t.closePath(),t.stroke(),t.restore(),t.save(),e.lowerBackgroundColor&&"none"!==e.lowerBackgroundColor&&(t.fillStyle=e.lowerBackgroundColor,r.q3>r.q1?t.fillRect(o,r.median,i,r.q3-r.median):t.fillRect(o,r.median,i,r.q1-r.median)),t.restore(),r.q3>r.q1?t.strokeRect(o,r.q1,i,r.q3-r.q1):t.strokeRect(o,r.q3,i,r.q1-r.q3),t.beginPath(),t.moveTo(o,r.whiskerMin),t.lineTo(o+i,r.whiskerMin),t.moveTo(n,r.whiskerMin),t.lineTo(n,r.q1),t.moveTo(o,r.whiskerMax),t.lineTo(o+i,r.whiskerMax),t.moveTo(n,r.whiskerMax),t.lineTo(n,r.q3),t.closePath(),t.stroke()}},{key:"_drawBoxPlotHorizontal",value:function(t){var e=this.options,r=this.getProps(["y","height","q1","q3","median","whiskerMin","whiskerMax"]),n=r.y,i=r.height,o=n-i/2;r.q3>r.q1?t.fillRect(r.q1,o,r.q3-r.q1,i):t.fillRect(r.q3,o,r.q1-r.q3,i),t.save(),e.medianColor&&"transparent"!==e.medianColor&&(t.strokeStyle=e.medianColor),t.beginPath(),t.moveTo(r.median,o),t.lineTo(r.median,o+i),t.closePath(),t.stroke(),t.restore(),t.save(),e.lowerBackgroundColor&&"transparent"!==e.lowerBackgroundColor&&(t.fillStyle=e.lowerBackgroundColor,r.q3>r.q1?t.fillRect(r.median,o,r.q3-r.median,i):t.fillRect(r.median,o,r.q1-r.median,i)),t.restore(),r.q3>r.q1?t.strokeRect(r.q1,o,r.q3-r.q1,i):t.strokeRect(r.q3,o,r.q1-r.q3,i),t.beginPath(),t.moveTo(r.whiskerMin,o),t.lineTo(r.whiskerMin,o+i),t.moveTo(r.whiskerMin,n),t.lineTo(r.q1,n),t.moveTo(r.whiskerMax,o),t.lineTo(r.whiskerMax,o+i),t.moveTo(r.whiskerMax,n),t.lineTo(r.q3,n),t.closePath(),t.stroke()}},{key:"_getBounds",value:function(t){var e=this.isVertical();if(null==this.x)return{left:0,top:0,right:0,bottom:0};if(e){var r=this.getProps(["x","width","whiskerMin","whiskerMax"],t),n=r.x,i=r.width,o=n-i/2;return{left:o,top:r.whiskerMax,right:o+i,bottom:r.whiskerMin}}var a=this.getProps(["y","height","whiskerMin","whiskerMax"],t),u=a.y,s=a.height,l=a.whiskerMax,c=u-s/2;return{left:a.whiskerMin,top:c,right:l,bottom:c+s}}}]),n}();function K(t){var e=function(){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}}();return function(){var r,n=f(t);if(e){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return c(this,r)}}G.id=G._type="boxandwhiskers",G.defaults=Object.assign({},p.elements.rectangle,H,{medianColor:"transparent",lowerBackgroundColor:"transparent"}),G.register=function(){return x(G)};var X=function(t){u(n,L);var e=K(n);function n(){return r(this,n),e.apply(this,arguments)}return i(n,[{key:"draw",value:function(t){t.save(),t.fillStyle=this.options.backgroundColor,t.strokeStyle=this.options.borderColor,t.lineWidth=this.options.borderWidth;var e=this.getProps(["x","y","width","height","min","max","coords","maxEstimate"]);k(t,{pointStyle:"rectRot",radius:5,borderWidth:this.options.borderWidth},e.x,e.y),e.coords&&e.coords.length>0&&this._drawCoords(t,e),this._drawOutliers(t),t.restore(),this._drawItems(t)}},{key:"_drawCoords",value:function(t,e){if(t.beginPath(),this.isVertical()){var r=e.x,n=e.width/2/e.maxEstimate;t.moveTo(r,e.min),e.coords.forEach(function(e){t.lineTo(r-e.estimate*n,e.v)}),t.lineTo(r,e.max),t.moveTo(r,e.min),e.coords.forEach(function(e){t.lineTo(r+e.estimate*n,e.v)}),t.lineTo(r,e.max)}else{var i=e.y,o=e.height/2/e.maxEstimate;t.moveTo(e.min,i),e.coords.forEach(function(e){t.lineTo(e.v,i-e.estimate*o)}),t.lineTo(e.max,i),t.moveTo(e.min,i),e.coords.forEach(function(e){t.lineTo(e.v,i+e.estimate*o)}),t.lineTo(e.max,i)}t.closePath(),t.stroke(),t.fill()}},{key:"_getBounds",value:function(t){if(this.isVertical()){var e=this.getProps(["x","width","min","max"],t),r=e.x,n=e.width,i=e.min,o=r-n/2;return{left:o,top:e.max,right:o+n,bottom:i}}var a=this.getProps(["y","height","min","max"],t),u=a.y,s=a.height,l=u-s/2;return{left:a.min,top:l,right:a.max,bottom:l+s}}}]),n}();X.id=X._type="violin",X.defaults=Object.assign({},p.elements.rectangle,H),X.register=function(){return x(X)};var J=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=f(t)););return t},Q=o(function(t){function e(r,n,i){return"undefined"!=typeof Reflect&&Reflect.get?t.exports=e=Reflect.get:t.exports=e=function(t,e,r){var n=J(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},e(r,n,i||r)}t.exports=e}),U={number:function(t,e,r){return t===e?e:null==t?e:null==e?t:t+(e-t)*r}};function Z(t,e,r){return"number"==typeof t&&"number"==typeof e?U.number(t,e,r):Array.isArray(t)&&Array.isArray(e)?e.map(function(e,n){return U.number(t[n],e,r)}):e}function $(t,e,r){return Array.isArray(t)&&Array.isArray(e)?e.map(function(e,n){return{v:U.number(t[n]?t[n].v:null,e.v,r),estimate:U.number(t[n]?t[n].estimate:null,e.estimate,r)}}):e}function tt(t){var e=t.value;e&&null!=this._tooltipOutlier&&t.datasetIndex===this._tooltipOutlier.datasetIndex&&(e.hoveredOutlierIndex=this._tooltipOutlier.index)}function et(t,e){if(!t.length)return!1;var r,n,i=0,o=0,a=0;for(r=0,n=t.length;r<n;++r){var u=t[r].element;if(u&&u.hasValue()){var s=u.tooltipPosition(e,this);i+=s.x,o+=s.y,++a}}return{x:i/a,y:o/a}}function rt(t){var e=function(){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}}();return function(){var r,n=f(t);if(e){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return c(this,r)}}function nt(t){var e=["borderColor","backgroundColor"].concat(t.filter(function(t){return t.endsWith("Color")}));return{datasets:Object.assign({animation:{numberArray:{fn:Z,properties:["outliers","items"]},colors:{type:"color",properties:e},show:{colors:{type:"color",properties:e,from:"transparent"}},hide:{colors:{type:"color",properties:e,to:"transparent"}}},minStats:"min",maxStats:"max"},A),tooltips:{position:et.register().id,callbacks:{beforeLabel:tt}}}}et.id="averageInstance",et.register=function(){return t=et,(r=e.plugins.getAll().find(function(t){return"tooltip"===t.id}))&&(r.positioners[t.id]=t),t;var t,r};var it=function(t){u(n,m);var e=rt(n);function n(){return r(this,n),e.apply(this,arguments)}return i(n,[{key:"getMinMax",value:function(t,e){var r=t.axis,i=this._config;t.axis=i.minStats;var o=Q(f(n.prototype),"getMinMax",this).call(this,t,e).min;t.axis=i.maxStats;var a=Q(f(n.prototype),"getMinMax",this).call(this,t,e).max;return t.axis=r,{min:o,max:a}}},{key:"parsePrimitiveData",value:function(t,e,r,n){for(var i=t.vScale,o=t.iScale,a=o.getLabels(),u=[],s=0;s<n;s++){var l=s+r,c={};c[o.axis]=o.parse(a[l],l);var f=this._parseStats(null==e?null:e[l],this._config);f&&(Object.assign(c,f),c[i.axis]=f.median),u.push(c)}return u}},{key:"parseArrayData",value:function(t,e,r,n){return this.parsePrimitiveData(t,e,r,n)}},{key:"parseObjectData",value:function(t,e,r,n){return this.parsePrimitiveData(t,e,r,n)}},{key:"_parseStats",value:function(t,e){return{}}},{key:"getLabelAndValue",value:function(t){var e=Q(f(n.prototype),"getLabelAndValue",this).call(this,t),r=this._cachedMeta.vScale,i=this.getParsed(t);if(!r||!i||"NaN"===e.value)return e;e.value={raw:i,hoveredOutlierIndex:-1},this._transformStats(e.value,i,function(t){return r.getLabelForValue(t)},"string");var o=this._toStringStats(e.value);return e.value.toString=function(){return this.hoveredOutlierIndex>=0?"(outlier: ".concat(this.outliers[this.hoveredOutlierIndex],")"):o},e}},{key:"_toStringStats",value:function(t){return""}},{key:"_transformStats",value:function(t,e,r,n){}},{key:"updateElement",value:function(t,e,r,i){var o="reset"===i,a=this._cachedMeta.vScale,u=this.getParsed(e),s=a.getBasePixel();r._datasetIndex=this.index,r._index=e,this._transformStats(r,u,function(t){return o?s:a.getPixelForValue(t)},i),Q(f(n.prototype),"updateElement",this).call(this,t,e,r,i)}}]),n}();function ot(t){var e=function(){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}}();return function(){var r,n=f(t);if(e){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return c(this,r)}}var at=function(t){u(n,it);var e=ot(n);function n(){return r(this,n),e.apply(this,arguments)}return i(n,[{key:"_parseStats",value:function(t,e){return W(t,e)}},{key:"_toStringStats",value:function(t){return"(min: ".concat(t.min,", 25% quantile: ").concat(t.q1,", median: ").concat(t.median,", 75% quantile: ").concat(t.q3,", max: ").concat(t.max,")")}},{key:"_transformStats",value:function(t,e,r){for(var n=0,i=["min","max","median","q3","q1","whiskerMin","whiskerMax"];n<i.length;n++){var o=i[n];t[o]=r(e[o])}for(var a=0,u=["outliers","items"];a<u.length;a++){var s=u[a];Array.isArray(e[s])&&(t[s]=e[s].map(r))}}}]),n}();at.id="boxplot",at.register=function(){return at.prototype.dataElementType=G.register(),at.prototype.dataElementOptions=m.prototype.dataElementOptions.concat(Y),at.defaults=b({},[p.bar,nt(Y),{datasets:{animation:{numbers:{type:"number",properties:p.bar.datasets.animation.numbers.properties.concat(["q1","q3","min","max","median","whiskerMin","whiskerMax"],Y.filter(function(t){return!t.endsWith("Color")}))}}}}]),v(at)};var ut=function(t){u(n,d);var e=ot(n);function n(t,i){return r(this,n),e.call(this,t,w(i,at))}return n}();ut.id=at.id;var st=function(t){u(n,at);var e=ot(n);function n(){return r(this,n),e.apply(this,arguments)}return i(n,[{key:"getValueScaleId",value:function(){return this._cachedMeta.xAxisID}},{key:"getIndexScaleId",value:function(){return this._cachedMeta.yAxisID}}]),n}();st.id="horizontalBoxplot",st.register=function(){return st.prototype.dataElementType=G.register(),st.prototype.dataElementOptions=y.prototype.dataElementOptions.concat(Y),st.defaults=b({},[p.horizontalBar,nt(Y),{datasets:{animation:{numbers:{type:"number",properties:p.bar.datasets.animation.numbers.properties.concat(["q1","q3","min","max","median","whiskerMin","whiskerMax"],Y.filter(function(t){return!t.endsWith("Color")}))}}}}]),v(st)};var lt=function(t){u(n,d);var e=ot(n);function n(t,i){return r(this,n),e.call(this,t,w(i,st))}return n}();function ct(t){var e=function(){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}}();return function(){var r,n=f(t);if(e){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return c(this,r)}}lt.id=st.id;var ft=function(t){u(n,it);var e=ct(n);function n(){return r(this,n),e.apply(this,arguments)}return i(n,[{key:"_parseStats",value:function(t,e){return function(t,e){return t?"number"==typeof t.median&&Array.isArray(t.coords)?t:Array.isArray(t)?D(t,e):void 0:null}(t,e)}},{key:"_toStringStats",value:function(t){return"(min: ".concat(t.min,", 25% quantile: ").concat(t.q1,", median: ").concat(t.median,", 75% quantile: ").concat(t.q3,", max: ").concat(t.max,")")}},{key:"_transformStats",value:function(t,e,r){for(var n=0,i=["min","max","median","q3","q1"];n<i.length;n++){var o=i[n];t[o]=r(e[o])}t.maxEstimate=e.maxEstimate;for(var a=0,u=["outliers","items"];a<u.length;a++){var s=u[a];Array.isArray(e[s])&&(t[s]=e[s].map(r))}Array.isArray(e.coords)&&(t.coords=e.coords.map(function(t){return Object.assign({},t,{v:r(t.v)})}))}}]),n}();ft.id="violin",ft.register=function(){return ft.prototype.dataElementType=X.register(),ft.prototype.dataElementOptions=m.prototype.dataElementOptions.concat(z),ft.defaults=b({},[p.bar,nt(z),{datasets:{points:100,animation:{numbers:{type:"number",properties:p.bar.datasets.animation.numbers.properties.concat(["q1","q3","min","max","median","maxEstimate"],z.filter(function(t){return!t.endsWith("Color")}))},kdeCoords:{fn:$,properties:["coords"]}}}}]),v(ft)};var ht=function(t){u(n,d);var e=ct(n);function n(t,i){return r(this,n),e.call(this,t,w(i,ft))}return n}();ht.id=ft.id;var dt=function(t){u(n,ft);var e=ct(n);function n(){return r(this,n),e.apply(this,arguments)}return i(n,[{key:"getValueScaleId",value:function(){return this._cachedMeta.xAxisID}},{key:"getIndexScaleId",value:function(){return this._cachedMeta.yAxisID}}]),n}();dt.id="horizontalViolin",dt.register=function(){return dt.prototype.dataElementType=X.register(),dt.prototype.dataElementOptions=dt.prototype.dataElementOptions.concat(z),dt.defaults=b({},[p.horizontalBar,nt(z),{datasets:{points:100,animation:{numbers:{type:"number",properties:p.bar.datasets.animation.numbers.properties.concat(["q1","q3","min","max","median","maxEstimate"],z.filter(function(t){return!t.endsWith("Color")}))},kdeCoords:{fn:$,properties:["coords"]}}}}]),v(dt)};var pt=function(t){u(n,d);var e=ct(n);function n(t,i){return r(this,n),e.call(this,t,w(i,dt))}return n}();pt.id=dt.id,at.register(),st.register(),ft.register(),dt.register(),t.BoxAndWiskers=G,t.BoxPlotChart=ut,t.BoxPlotController=at,t.HorizontalBoxPlotChart=lt,t.HorizontalBoxPlotController=st,t.HorizontalViolinChart=pt,t.HorizontalViolinController=dt,t.ViolinChart=ht,t.ViolinController=ft,t.ViolinElement=X,t.boxOptionsKeys=Y,Object.defineProperty(t,"__esModule",{value:!0})}); |
{ | ||
"name": "@sgratzl/chartjs-chart-boxplot", | ||
"description": "Chart.js module for charting boxplots and violin charts", | ||
"version": "3.0.0-alpha.2", | ||
"version": "3.0.0-alpha.3", | ||
"publishConfig": { | ||
@@ -82,3 +82,4 @@ "access": "public" | ||
"release": "release-it --disable-metrics --npm.skipChecks", | ||
"release:pre": "release-it --disable-metrics --npm.skipChecks --preRelease=alpha --npm.tag=next" | ||
"release:pre": "release-it --disable-metrics --npm.skipChecks --preRelease=alpha --npm.tag=next", | ||
"sample": "cd sample_treeshake && rollup -c" | ||
}, | ||
@@ -85,0 +86,0 @@ "dependenciesMeta": { |
@@ -355,3 +355,2 @@ # Chart.js Box and Violin Plot | ||
```js | ||
import Chart from 'chart.js'; | ||
import { BoxPlotChart } from '@sgratzl/chartjs-chart-boxplot'; | ||
@@ -358,0 +357,0 @@ |
import ChartNS from 'chart.js'; | ||
export const Chart = ChartNS; | ||
export const plugins = ChartNS.plugins; | ||
export const controllers = ChartNS.controllers; | ||
// export const plugins = ChartNS.plugins; | ||
export const defaults = ChartNS.defaults; | ||
export const helpers = ChartNS.helpers; | ||
// export const scaleService = ChartNS.scaleService; | ||
// export const DataSetController = ChartNS.DataSetController; | ||
export const BarController = controllers.bar; | ||
export const HorizontalBarController = controllers.horizontalBar; | ||
// export const LineController = controllers.line; | ||
// export const PolarAreaController = controllers.polarArea; | ||
// export const ScatterController = controllers.scatter; | ||
export function registerScale(scale) { | ||
ChartNS.scaleService.registerScale(scale); | ||
return scale; | ||
} | ||
// export const Scale = ChartNS.Scale; | ||
// export const LinearScale = ChartNS.scaleService.getScaleConstructor('linear'); | ||
// export const LogarithmicScale = ChartNS.scaleService.getScaleConstructor('logarithmic'); | ||
// export const CategoryScale = ChartNS.scaleService.getScaleConstructor('category'); | ||
// export const DatasetController = ChartNS.DatasetController; | ||
export const BarController = ChartNS.controllers.bar; | ||
// export const BubbleController = ChartNS.controllers.bubble; | ||
export const HorizontalBarController = ChartNS.controllers.horizontalBar; | ||
// export const LineController = ChartNS.controllers.line; | ||
// export const PolarAreaController = ChartNS.controllers.polarArea; | ||
// export const ScatterController = ChartNS.controllers.scatter; | ||
export function registerController(controller) { | ||
ChartNS.controllers[controller.id] = controller; | ||
defaults.set(controller.id, controller.defaults); | ||
return controller; | ||
} | ||
export const Element = ChartNS.Element; | ||
@@ -21,4 +35,34 @@ // export const Rectangle = ChartNS.elements.Rectangle; | ||
// export const Line = ChartNS.elements.Line; | ||
// export const Arc = ChartNS.elements.Arc; | ||
export function registerElement(element) { | ||
defaults.set('elements', { | ||
[element.id]: element.defaults, | ||
}); | ||
return element; | ||
} | ||
export const merge = ChartNS.helpers.merge; | ||
export const drawPoint = ChartNS.helpers.canvas.drawPoint; | ||
// export const resolve = ChartNS.helpers.options.resolve; | ||
// export const color = ChartNS.helpers.color; | ||
// export const valueOrDefault = ChartNS.helpers.valueOrDefault; | ||
// export const clipArea = ChartNS.helpers.canvas.clipArea; | ||
// export const unclipArea = ChartNS.helpers.canvas.unclipArea; | ||
// export const _parseFont = ChartNS.helpers.options._parseFont; | ||
// export const splineCurve = ChartNS.helpers.curve.splineCurve; | ||
export function patchControllerConfig(config, controller) { | ||
controller.register(); | ||
config.type = controller.id; | ||
return config; | ||
} | ||
export function registerTooltipPositioner(positioner) { | ||
// register my position logic | ||
const tooltip = ChartNS.plugins.getAll().find((d) => d.id === 'tooltip'); | ||
if (tooltip) { | ||
tooltip.positioners[positioner.id] = positioner; | ||
} | ||
return positioner; | ||
} |
import { asBoxPlotStats } from '../data'; | ||
import { Chart, controllers, defaults, BarController, HorizontalBarController, merge } from '../chart'; | ||
import { | ||
Chart, | ||
patchControllerConfig, | ||
registerController, | ||
defaults, | ||
BarController, | ||
HorizontalBarController, | ||
merge, | ||
} from '../chart'; | ||
import { baseDefaults, StatsBase } from './base'; | ||
import { BoxAndWiskers, boxOptionsKeys } from '../elements'; | ||
import { patchControllerConfig } from './utils'; | ||
@@ -33,24 +40,20 @@ export class BoxPlotController extends StatsBase { | ||
defaults.set( | ||
BoxPlotController.id, | ||
merge({}, [ | ||
defaults.bar, | ||
baseDefaults(boxOptionsKeys), | ||
{ | ||
datasets: { | ||
animation: { | ||
numbers: { | ||
type: 'number', | ||
properties: defaults.bar.datasets.animation.numbers.properties.concat( | ||
['q1', 'q3', 'min', 'max', 'median', 'whiskerMin', 'whiskerMax'], | ||
boxOptionsKeys.filter((c) => !c.endsWith('Color')) | ||
), | ||
}, | ||
BoxPlotController.defaults = merge({}, [ | ||
defaults.bar, | ||
baseDefaults(boxOptionsKeys), | ||
{ | ||
datasets: { | ||
animation: { | ||
numbers: { | ||
type: 'number', | ||
properties: defaults.bar.datasets.animation.numbers.properties.concat( | ||
['q1', 'q3', 'min', 'max', 'median', 'whiskerMin', 'whiskerMax'], | ||
boxOptionsKeys.filter((c) => !c.endsWith('Color')) | ||
), | ||
}, | ||
}, | ||
}, | ||
]) | ||
); | ||
controllers[BoxPlotController.id] = BoxPlotController; | ||
return BoxPlotController; | ||
}, | ||
]); | ||
return registerController(BoxPlotController); | ||
}; | ||
@@ -81,24 +84,20 @@ | ||
defaults.set( | ||
HorizontalBoxPlotController.id, | ||
merge({}, [ | ||
defaults.horizontalBar, | ||
baseDefaults(boxOptionsKeys), | ||
{ | ||
datasets: { | ||
animation: { | ||
numbers: { | ||
type: 'number', | ||
properties: defaults.bar.datasets.animation.numbers.properties.concat( | ||
['q1', 'q3', 'min', 'max', 'median', 'whiskerMin', 'whiskerMax'], | ||
boxOptionsKeys.filter((c) => !c.endsWith('Color')) | ||
), | ||
}, | ||
HorizontalBoxPlotController.defaults = merge({}, [ | ||
defaults.horizontalBar, | ||
baseDefaults(boxOptionsKeys), | ||
{ | ||
datasets: { | ||
animation: { | ||
numbers: { | ||
type: 'number', | ||
properties: defaults.bar.datasets.animation.numbers.properties.concat( | ||
['q1', 'q3', 'min', 'max', 'median', 'whiskerMin', 'whiskerMax'], | ||
boxOptionsKeys.filter((c) => !c.endsWith('Color')) | ||
), | ||
}, | ||
}, | ||
}, | ||
]) | ||
); | ||
controllers[HorizontalBoxPlotController.id] = HorizontalBoxPlotController; | ||
return HorizontalBoxPlotController; | ||
}, | ||
]); | ||
return registerController(HorizontalBoxPlotController); | ||
}; | ||
@@ -105,0 +104,0 @@ |
import { asViolinStats } from '../data'; | ||
import { Chart, controllers, defaults, helpers, BarController, HorizontalBarController } from '../chart'; | ||
import { Chart, defaults, merge, BarController, registerController, patchControllerConfig } from '../chart'; | ||
import { StatsBase, baseDefaults } from './base'; | ||
@@ -7,3 +7,2 @@ import { baseOptionKeys } from '../elements/base'; | ||
import { interpolateKdeCoords } from '../animation'; | ||
import { patchControllerConfig } from './utils'; | ||
@@ -40,29 +39,25 @@ export class ViolinController extends StatsBase { | ||
defaults.set( | ||
ViolinController.id, | ||
helpers.merge({}, [ | ||
defaults.bar, | ||
baseDefaults(baseOptionKeys), | ||
{ | ||
datasets: { | ||
points: 100, | ||
animation: { | ||
numbers: { | ||
type: 'number', | ||
properties: defaults.bar.datasets.animation.numbers.properties.concat( | ||
['q1', 'q3', 'min', 'max', 'median', 'maxEstimate'], | ||
baseOptionKeys.filter((c) => !c.endsWith('Color')) | ||
), | ||
}, | ||
kdeCoords: { | ||
fn: interpolateKdeCoords, | ||
properties: ['coords'], | ||
}, | ||
ViolinController.defaults = merge({}, [ | ||
defaults.bar, | ||
baseDefaults(baseOptionKeys), | ||
{ | ||
datasets: { | ||
points: 100, | ||
animation: { | ||
numbers: { | ||
type: 'number', | ||
properties: defaults.bar.datasets.animation.numbers.properties.concat( | ||
['q1', 'q3', 'min', 'max', 'median', 'maxEstimate'], | ||
baseOptionKeys.filter((c) => !c.endsWith('Color')) | ||
), | ||
}, | ||
kdeCoords: { | ||
fn: interpolateKdeCoords, | ||
properties: ['coords'], | ||
}, | ||
}, | ||
}, | ||
]) | ||
); | ||
controllers[ViolinController.id] = ViolinController; | ||
return ViolinController; | ||
}, | ||
]); | ||
return registerController(ViolinController); | ||
}; | ||
@@ -93,29 +88,25 @@ | ||
defaults.set( | ||
HorizontalViolinController.id, | ||
helpers.merge({}, [ | ||
defaults.horizontalBar, | ||
baseDefaults(baseOptionKeys), | ||
{ | ||
datasets: { | ||
points: 100, | ||
animation: { | ||
numbers: { | ||
type: 'number', | ||
properties: defaults.bar.datasets.animation.numbers.properties.concat( | ||
['q1', 'q3', 'min', 'max', 'median', 'maxEstimate'], | ||
baseOptionKeys.filter((c) => !c.endsWith('Color')) | ||
), | ||
}, | ||
kdeCoords: { | ||
fn: interpolateKdeCoords, | ||
properties: ['coords'], | ||
}, | ||
HorizontalViolinController.defaults = merge({}, [ | ||
defaults.horizontalBar, | ||
baseDefaults(baseOptionKeys), | ||
{ | ||
datasets: { | ||
points: 100, | ||
animation: { | ||
numbers: { | ||
type: 'number', | ||
properties: defaults.bar.datasets.animation.numbers.properties.concat( | ||
['q1', 'q3', 'min', 'max', 'median', 'maxEstimate'], | ||
baseOptionKeys.filter((c) => !c.endsWith('Color')) | ||
), | ||
}, | ||
kdeCoords: { | ||
fn: interpolateKdeCoords, | ||
properties: ['coords'], | ||
}, | ||
}, | ||
}, | ||
]) | ||
); | ||
controllers[HorizontalViolinController.id] = HorizontalViolinController; | ||
return HorizontalViolinController; | ||
}, | ||
]); | ||
return registerController(HorizontalViolinController); | ||
}; | ||
@@ -122,0 +113,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { defaults } from '../chart'; | ||
import { defaults, registerElement } from '../chart'; | ||
import { StatsBase, baseDefaults, baseOptionKeys } from './base'; | ||
@@ -187,11 +187,7 @@ | ||
BoxAndWiskers._type = 'boxandwhiskers'; | ||
BoxAndWiskers.register = () => { | ||
defaults.set('elements', { | ||
[BoxAndWiskers._type]: Object.assign({}, defaults.elements.rectangle, baseDefaults, { | ||
medianColor: 'transparent', | ||
lowerBackgroundColor: 'transparent', | ||
}), | ||
}); | ||
return BoxAndWiskers; | ||
}; | ||
BoxAndWiskers.id = BoxAndWiskers._type = 'boxandwhiskers'; | ||
BoxAndWiskers.defaults = Object.assign({}, defaults.elements.rectangle, baseDefaults, { | ||
medianColor: 'transparent', | ||
lowerBackgroundColor: 'transparent', | ||
}); | ||
BoxAndWiskers.register = () => registerElement(BoxAndWiskers); |
@@ -1,2 +0,2 @@ | ||
import { defaults, drawPoint } from '../chart'; | ||
import { defaults, drawPoint, registerElement } from '../chart'; | ||
import { StatsBase, baseDefaults } from './base'; | ||
@@ -93,8 +93,4 @@ | ||
ViolinElement._type = 'violin'; | ||
ViolinElement.register = () => { | ||
defaults.set('elements', { | ||
[ViolinElement._type]: Object.assign({}, defaults.elements.rectangle, baseDefaults), | ||
}); | ||
return ViolinElement; | ||
}; | ||
ViolinElement.id = ViolinElement._type = 'violin'; | ||
ViolinElement.defaults = Object.assign({}, defaults.elements.rectangle, baseDefaults); | ||
ViolinElement.register = () => registerElement(ViolinElement); |
@@ -1,2 +0,2 @@ | ||
import { plugins } from './chart'; | ||
import { registerTooltipPositioner } from './chart'; | ||
@@ -35,7 +35,2 @@ export function patchInHoveredOutlier(item) { | ||
outlierPositioner.id = 'averageInstance'; | ||
outlierPositioner.register = () => { | ||
// register my position logic | ||
const tooltip = plugins.getAll().find((d) => d.id === 'tooltip'); | ||
tooltip.positioners[outlierPositioner.id] = outlierPositioner; | ||
return outlierPositioner; | ||
}; | ||
outlierPositioner.register = () => registerTooltipPositioner(outlierPositioner); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
169260
3962
21
392