Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sgratzl/chartjs-chart-boxplot

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sgratzl/chartjs-chart-boxplot - npm Package Compare versions

Comparing version 3.0.0-alpha.1 to 3.0.0-alpha.2

src/chart.js

202

build/Chart.BoxPlot.esm.js

@@ -1,3 +0,25 @@

import { defaults, Element, helpers, plugins, controllers } from 'chart.js';
import ChartNS from 'chart.js';
const Chart = ChartNS;
const plugins = ChartNS.plugins;
const controllers = ChartNS.controllers;
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;
const Element = ChartNS.Element;
// export const Rectangle = ChartNS.elements.Rectangle;
// export const Point = ChartNS.elements.Point;
// export const Line = ChartNS.elements.Line;
const merge = ChartNS.helpers.merge;
const drawPoint = ChartNS.helpers.canvas.drawPoint;
// See <http://en.wikipedia.org/wiki/Kernel_(statistics)>.

@@ -383,3 +405,3 @@

const baseDefaults = Object.assign({}, defaults.elements.rectangle, {
const baseDefaults = {
borderWidth: 1,

@@ -401,20 +423,6 @@

outlierHitRadius: 4,
});
};
const baseOptionKeys = [
'outlierStyle',
'outlierRadius',
'outlierBackgroundColor',
'outlierBorderColor',
'outlierBorderWidth',
'outlierHitRadius',
const baseOptionKeys = Object.keys(baseDefaults);
'itemStyle',
'itemRadius',
'itemBackgroundColor',
'itemBorderColor',
'itemBorderWidth',
'hitPadding',
];
class StatsBase extends Element {

@@ -449,7 +457,7 @@ isVertical() {

props.items.forEach((v) => {
helpers.canvas.drawPoint(ctx, pointOptions, props.x - props.width / 2 + random() * props.width, v);
drawPoint(ctx, pointOptions, props.x - props.width / 2 + random() * props.width, v);
});
} else {
props.items.forEach((v) => {
helpers.canvas.drawPoint(ctx, pointOptions, v, props.y - props.height / 2 + random() * props.height);
drawPoint(ctx, pointOptions, v, props.y - props.height / 2 + random() * props.height);
});

@@ -480,7 +488,7 @@ }

props.outliers.forEach((v) => {
helpers.canvas.drawPoint(ctx, pointOptions, props.x, v);
drawPoint(ctx, pointOptions, props.x, v);
});
} else {
props.outliers.forEach((v) => {
helpers.canvas.drawPoint(ctx, pointOptions, v, props.y);
drawPoint(ctx, pointOptions, v, props.y);
});

@@ -523,13 +531,2 @@ }

inLabelRange(mouseX, mouseY, useFinalPosition) {
if (Number.isNaN(this.x) && Number.isNaN(this.y)) {
return false;
}
const bounds = this._getHitBounds(useFinalPosition);
if (this.isVertical()) {
return mouseX >= bounds.left && mouseX <= bounds.right;
}
return mouseY >= bounds.top && mouseY <= bounds.bottom;
}
inXRange(mouseX, useFinalPosition) {

@@ -577,6 +574,2 @@ const bounds = this._getHitBounds(useFinalPosition);

getArea() {
return 0; // abstract
}
_getOutliers(useFinalPosition) {

@@ -798,16 +791,2 @@ const props = this.getProps(['outliers'], useFinalPosition);

}
// height(useFinalPosition) {
// const props = this.getProps(['base', 'q1', 'q3'], useFinalPosition);
// return props.base - Math.min(props.q1, props.q3);
// }
getArea(useFinalPosition) {
const props = this.getProps(['q3', 'q1', 'width', 'height'], useFinalPosition);
const iqr = Math.abs(props.q3 - props.q1);
if (this.isVertical()) {
return iqr * props.width;
}
return iqr * props.height;
}
}

@@ -818,3 +797,3 @@

defaults.set('elements', {
[BoxAndWiskers._type]: Object.assign({}, baseDefaults, {
[BoxAndWiskers._type]: Object.assign({}, defaults.elements.rectangle, baseDefaults, {
medianColor: 'transparent',

@@ -837,3 +816,3 @@ lowerBackgroundColor: 'transparent',

helpers.canvas.drawPoint(
drawPoint(
ctx,

@@ -915,11 +894,2 @@ {

}
getArea() {
const props = this.getProps(['min', 'max', 'height', 'width']);
const iqr = Math.abs(props.max - props.min);
if (this.isVertical()) {
return iqr * props.width;
}
return iqr * props.height;
}
}

@@ -930,3 +900,3 @@

defaults.set('elements', {
[ViolinElement._type]: baseDefaults,
[ViolinElement._type]: Object.assign({}, defaults.elements.rectangle, baseDefaults),
});

@@ -1053,3 +1023,3 @@ return ViolinElement;

class StatsBase$1 extends controllers.bar {
class StatsBase$1 extends BarController {
getMinMax(scale, canStack) {

@@ -1141,3 +1111,9 @@ const bak = scale.axis;

class BoxPlot extends StatsBase$1 {
function patchControllerConfig(config, controller) {
controller.register();
config.type = controller.id;
return config;
}
class BoxPlotController extends StatsBase$1 {
_parseStats(value, config) {

@@ -1163,10 +1139,10 @@ return asBoxPlotStats(value, config);

BoxPlot.id = 'boxplot';
BoxPlot.register = () => {
BoxPlot.prototype.dataElementType = BoxAndWiskers.register();
BoxPlot.prototype.dataElementOptions = controllers.bar.prototype.dataElementOptions.concat(boxOptionsKeys);
BoxPlotController.id = 'boxplot';
BoxPlotController.register = () => {
BoxPlotController.prototype.dataElementType = BoxAndWiskers.register();
BoxPlotController.prototype.dataElementOptions = BarController.prototype.dataElementOptions.concat(boxOptionsKeys);
defaults.set(
BoxPlot.id,
helpers.merge({}, [
BoxPlotController.id,
merge({}, [
defaults.bar,

@@ -1189,7 +1165,14 @@ baseDefaults$1(boxOptionsKeys),

);
controllers[BoxPlot.id] = BoxPlot;
return BoxPlot;
controllers[BoxPlotController.id] = BoxPlotController;
return BoxPlotController;
};
class HorizontalBoxPlot extends BoxPlot {
class BoxPlotChart extends Chart {
constructor(item, config) {
super(item, patchControllerConfig(config, BoxPlotController));
}
}
BoxPlotChart.id = BoxPlotController.id;
class HorizontalBoxPlotController extends BoxPlotController {
getValueScaleId() {

@@ -1203,6 +1186,6 @@ return this._cachedMeta.xAxisID;

HorizontalBoxPlot.id = 'horizontalBoxplot';
HorizontalBoxPlot.register = () => {
HorizontalBoxPlot.prototype.dataElementType = BoxAndWiskers.register();
HorizontalBoxPlot.prototype.dataElementOptions = controllers.horizontalBar.prototype.dataElementOptions.concat(
HorizontalBoxPlotController.id = 'horizontalBoxplot';
HorizontalBoxPlotController.register = () => {
HorizontalBoxPlotController.prototype.dataElementType = BoxAndWiskers.register();
HorizontalBoxPlotController.prototype.dataElementOptions = HorizontalBarController.prototype.dataElementOptions.concat(
boxOptionsKeys

@@ -1212,4 +1195,4 @@ );

defaults.set(
HorizontalBoxPlot.id,
helpers.merge({}, [
HorizontalBoxPlotController.id,
merge({}, [
defaults.horizontalBar,

@@ -1232,7 +1215,14 @@ baseDefaults$1(boxOptionsKeys),

);
controllers[HorizontalBoxPlot.id] = HorizontalBoxPlot;
return HorizontalBoxPlot;
controllers[HorizontalBoxPlotController.id] = HorizontalBoxPlotController;
return HorizontalBoxPlotController;
};
class Violin extends StatsBase$1 {
class HorizontalBoxPlotChart extends Chart {
constructor(item, config) {
super(item, patchControllerConfig(config, HorizontalBoxPlotController));
}
}
HorizontalBoxPlotChart.id = HorizontalBoxPlotController.id;
class ViolinController extends StatsBase$1 {
_parseStats(value, config) {

@@ -1262,9 +1252,9 @@ return asViolinStats(value, config);

Violin.id = 'violin';
Violin.register = () => {
Violin.prototype.dataElementType = ViolinElement.register();
Violin.prototype.dataElementOptions = controllers.bar.prototype.dataElementOptions.concat(baseOptionKeys);
ViolinController.id = 'violin';
ViolinController.register = () => {
ViolinController.prototype.dataElementType = ViolinElement.register();
ViolinController.prototype.dataElementOptions = BarController.prototype.dataElementOptions.concat(baseOptionKeys);
defaults.set(
Violin.id,
ViolinController.id,
helpers.merge({}, [

@@ -1293,7 +1283,14 @@ defaults.bar,

);
controllers[Violin.id] = Violin;
return Violin;
controllers[ViolinController.id] = ViolinController;
return ViolinController;
};
class HorizontalViolin extends Violin {
class ViolinChart extends Chart {
constructor(item, config) {
super(item, patchControllerConfig(config, ViolinController));
}
}
ViolinChart.id = ViolinController.id;
class HorizontalViolinController extends ViolinController {
getValueScaleId() {

@@ -1307,6 +1304,6 @@ return this._cachedMeta.xAxisID;

HorizontalViolin.id = 'horizontalViolin';
HorizontalViolin.register = () => {
HorizontalViolin.prototype.dataElementType = ViolinElement.register();
HorizontalViolin.prototype.dataElementOptions = controllers.horizontalBar.prototype.dataElementOptions.concat(
HorizontalViolinController.id = 'horizontalViolin';
HorizontalViolinController.register = () => {
HorizontalViolinController.prototype.dataElementType = ViolinElement.register();
HorizontalViolinController.prototype.dataElementOptions = HorizontalViolinController.prototype.dataElementOptions.concat(
baseOptionKeys

@@ -1316,3 +1313,3 @@ );

defaults.set(
HorizontalViolin.id,
HorizontalViolinController.id,
helpers.merge({}, [

@@ -1341,6 +1338,13 @@ defaults.horizontalBar,

);
controllers[HorizontalViolin.id] = HorizontalViolin;
return HorizontalViolin;
controllers[HorizontalViolinController.id] = HorizontalViolinController;
return HorizontalViolinController;
};
export { BoxAndWiskers, BoxPlot, HorizontalBoxPlot, HorizontalViolin, Violin, ViolinElement, boxOptionsKeys };
class HorizontalViolinChart extends Chart {
constructor(item, config) {
super(item, patchControllerConfig(config, HorizontalViolinController));
}
}
HorizontalViolinChart.id = HorizontalViolinController.id;
export { BoxAndWiskers, BoxPlotChart, BoxPlotController, HorizontalBoxPlotChart, HorizontalBoxPlotController, HorizontalViolinChart, HorizontalViolinController, ViolinChart, ViolinController, ViolinElement, boxOptionsKeys };

@@ -5,4 +5,6 @@ (function (global, factory) {

(global = global || self, factory(global.ChartBoxPlot = {}, global.Chart));
}(this, (function (exports, chart_js) { 'use strict';
}(this, (function (exports, ChartNS) { 'use strict';
ChartNS = ChartNS && Object.prototype.hasOwnProperty.call(ChartNS, 'default') ? ChartNS['default'] : ChartNS;
function _defineProperty(obj, key, value) {

@@ -136,2 +138,21 @@ if (key in obj) {

var Chart = ChartNS;
var plugins = ChartNS.plugins;
var controllers = ChartNS.controllers;
var defaults = ChartNS.defaults;
var helpers = ChartNS.helpers; // export const scaleService = ChartNS.scaleService;
// 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 Element = ChartNS.Element; // export const Rectangle = ChartNS.elements.Rectangle;
// export const Point = ChartNS.elements.Point;
// export const Line = ChartNS.elements.Line;
var merge = ChartNS.helpers.merge;
var drawPoint = ChartNS.helpers.canvas.drawPoint;
// See <http://en.wikipedia.org/wiki/Kernel_(statistics)>.

@@ -577,18 +598,18 @@ function gaussian(u) {

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
var baseDefaults = Object.assign({}, chart_js.defaults.elements.rectangle, {
var baseDefaults = {
borderWidth: 1,
outlierStyle: 'circle',
outlierRadius: 2,
outlierBackgroundColor: chart_js.defaults.elements.rectangle.backgroundColor,
outlierBorderColor: chart_js.defaults.elements.rectangle.borderColor,
outlierBackgroundColor: defaults.elements.rectangle.backgroundColor,
outlierBorderColor: defaults.elements.rectangle.borderColor,
outlierBorderWidth: 1,
itemStyle: 'circle',
itemRadius: 0,
itemBackgroundColor: chart_js.defaults.elements.rectangle.backgroundColor,
itemBorderColor: chart_js.defaults.elements.rectangle.borderColor,
itemBackgroundColor: defaults.elements.rectangle.backgroundColor,
itemBorderColor: defaults.elements.rectangle.borderColor,
itemBorderWidth: 0,
hitPadding: 2,
outlierHitRadius: 4
});
var baseOptionKeys = ['outlierStyle', 'outlierRadius', 'outlierBackgroundColor', 'outlierBorderColor', 'outlierBorderWidth', 'outlierHitRadius', 'itemStyle', 'itemRadius', 'itemBackgroundColor', 'itemBorderColor', 'itemBorderWidth', 'hitPadding'];
};
var baseOptionKeys = Object.keys(baseDefaults);
var StatsBase = /*#__PURE__*/function (_Element) {

@@ -636,7 +657,7 @@ inherits(StatsBase, _Element);

props.items.forEach(function (v) {
chart_js.helpers.canvas.drawPoint(ctx, pointOptions, props.x - props.width / 2 + random() * props.width, v);
drawPoint(ctx, pointOptions, props.x - props.width / 2 + random() * props.width, v);
});
} else {
props.items.forEach(function (v) {
chart_js.helpers.canvas.drawPoint(ctx, pointOptions, v, props.y - props.height / 2 + random() * props.height);
drawPoint(ctx, pointOptions, v, props.y - props.height / 2 + random() * props.height);
});

@@ -670,7 +691,7 @@ }

props.outliers.forEach(function (v) {
chart_js.helpers.canvas.drawPoint(ctx, pointOptions, props.x, v);
drawPoint(ctx, pointOptions, props.x, v);
});
} else {
props.outliers.forEach(function (v) {
chart_js.helpers.canvas.drawPoint(ctx, pointOptions, v, props.y);
drawPoint(ctx, pointOptions, v, props.y);
});

@@ -716,17 +737,2 @@ }

}, {
key: "inLabelRange",
value: function inLabelRange(mouseX, mouseY, useFinalPosition) {
if (Number.isNaN(this.x) && Number.isNaN(this.y)) {
return false;
}
var bounds = this._getHitBounds(useFinalPosition);
if (this.isVertical()) {
return mouseX >= bounds.left && mouseX <= bounds.right;
}
return mouseY >= bounds.top && mouseY <= bounds.bottom;
}
}, {
key: "inXRange",

@@ -786,7 +792,2 @@ value: function inXRange(mouseX, useFinalPosition) {

}, {
key: "getArea",
value: function getArea() {
return 0; // abstract
}
}, {
key: "_getOutliers",

@@ -835,3 +836,3 @@ value: function _getOutliers(useFinalPosition) {

return StatsBase;
}(chart_js.Element);
}(Element);

@@ -1043,18 +1044,2 @@ function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); 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); }; }

};
} // height(useFinalPosition) {
// const props = this.getProps(['base', 'q1', 'q3'], useFinalPosition);
// return props.base - Math.min(props.q1, props.q3);
// }
}, {
key: "getArea",
value: function getArea(useFinalPosition) {
var props = this.getProps(['q3', 'q1', 'width', 'height'], useFinalPosition);
var iqr = Math.abs(props.q3 - props.q1);
if (this.isVertical()) {
return iqr * props.width;
}
return iqr * props.height;
}

@@ -1068,3 +1053,3 @@ }]);

BoxAndWiskers.register = function () {
chart_js.defaults.set('elements', defineProperty({}, BoxAndWiskers._type, Object.assign({}, baseDefaults, {
defaults.set('elements', defineProperty({}, BoxAndWiskers._type, Object.assign({}, defaults.elements.rectangle, baseDefaults, {
medianColor: 'transparent',

@@ -1098,3 +1083,3 @@ lowerBackgroundColor: 'transparent'

var props = this.getProps(['x', 'y', 'width', 'height', 'min', 'max', 'coords', 'maxEstimate']);
chart_js.helpers.canvas.drawPoint(ctx, {
drawPoint(ctx, {
pointStyle: 'rectRot',

@@ -1189,14 +1174,2 @@ radius: 5,

}
}, {
key: "getArea",
value: function getArea() {
var props = this.getProps(['min', 'max', 'height', 'width']);
var iqr = Math.abs(props.max - props.min);
if (this.isVertical()) {
return iqr * props.width;
}
return iqr * props.height;
}
}]);

@@ -1209,3 +1182,3 @@

ViolinElement.register = function () {
chart_js.defaults.set('elements', defineProperty({}, ViolinElement._type, baseDefaults));
defaults.set('elements', defineProperty({}, ViolinElement._type, Object.assign({}, defaults.elements.rectangle, baseDefaults)));
return ViolinElement;

@@ -1330,3 +1303,3 @@ };

// register my position logic
var tooltip = chart_js.plugins.getAll().find(function (d) {
var tooltip = plugins.getAll().find(function (d) {
return d.id === 'tooltip';

@@ -1382,4 +1355,4 @@ });

}
var StatsBase$1 = /*#__PURE__*/function (_controllers$bar) {
inherits(StatsBase, _controllers$bar);
var StatsBase$1 = /*#__PURE__*/function (_BarController) {
inherits(StatsBase, _BarController);

@@ -1517,14 +1490,20 @@ var _super = _createSuper$3(StatsBase);

return StatsBase;
}(chart_js.controllers.bar);
}(BarController);
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); }; }
function _isNativeReflectConstruct$4() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
var BoxPlot = /*#__PURE__*/function (_StatsBase) {
inherits(BoxPlot, _StatsBase);
var BoxPlotController = /*#__PURE__*/function (_StatsBase) {
inherits(BoxPlotController, _StatsBase);
var _super = _createSuper$4(BoxPlot);
var _super = _createSuper$4(BoxPlotController);
function BoxPlot() {
classCallCheck(this, BoxPlot);
function BoxPlotController() {
classCallCheck(this, BoxPlotController);

@@ -1534,3 +1513,3 @@ return _super.apply(this, arguments);

createClass(BoxPlot, [{
createClass(BoxPlotController, [{
key: "_parseStats",

@@ -1563,10 +1542,10 @@ value: function _parseStats(value, config) {

return BoxPlot;
return BoxPlotController;
}(StatsBase$1);
BoxPlot.id = 'boxplot';
BoxPlotController.id = 'boxplot';
BoxPlot.register = function () {
BoxPlot.prototype.dataElementType = BoxAndWiskers.register();
BoxPlot.prototype.dataElementOptions = chart_js.controllers.bar.prototype.dataElementOptions.concat(boxOptionsKeys);
chart_js.defaults.set(BoxPlot.id, chart_js.helpers.merge({}, [chart_js.defaults.bar, baseDefaults$1(boxOptionsKeys), {
BoxPlotController.register = function () {
BoxPlotController.prototype.dataElementType = BoxAndWiskers.register();
BoxPlotController.prototype.dataElementOptions = BarController.prototype.dataElementOptions.concat(boxOptionsKeys);
defaults.set(BoxPlotController.id, merge({}, [defaults.bar, baseDefaults$1(boxOptionsKeys), {
datasets: {

@@ -1576,3 +1555,3 @@ animation: {

type: 'number',
properties: chart_js.defaults.bar.datasets.animation.numbers.properties.concat(['q1', 'q3', 'min', 'max', 'median', 'whiskerMin', 'whiskerMax'], boxOptionsKeys.filter(function (c) {
properties: defaults.bar.datasets.animation.numbers.properties.concat(['q1', 'q3', 'min', 'max', 'median', 'whiskerMin', 'whiskerMax'], boxOptionsKeys.filter(function (c) {
return !c.endsWith('Color');

@@ -1584,18 +1563,32 @@ }))

}]));
chart_js.controllers[BoxPlot.id] = BoxPlot;
return BoxPlot;
controllers[BoxPlotController.id] = BoxPlotController;
return BoxPlotController;
};
var HorizontalBoxPlot = /*#__PURE__*/function (_BoxPlot) {
inherits(HorizontalBoxPlot, _BoxPlot);
var BoxPlotChart = /*#__PURE__*/function (_Chart) {
inherits(BoxPlotChart, _Chart);
var _super2 = _createSuper$4(HorizontalBoxPlot);
var _super2 = _createSuper$4(BoxPlotChart);
function HorizontalBoxPlot() {
classCallCheck(this, HorizontalBoxPlot);
function BoxPlotChart(item, config) {
classCallCheck(this, BoxPlotChart);
return _super2.apply(this, arguments);
return _super2.call(this, item, patchControllerConfig(config, BoxPlotController));
}
createClass(HorizontalBoxPlot, [{
return BoxPlotChart;
}(Chart);
BoxPlotChart.id = BoxPlotController.id;
var HorizontalBoxPlotController = /*#__PURE__*/function (_BoxPlotController) {
inherits(HorizontalBoxPlotController, _BoxPlotController);
var _super3 = _createSuper$4(HorizontalBoxPlotController);
function HorizontalBoxPlotController() {
classCallCheck(this, HorizontalBoxPlotController);
return _super3.apply(this, arguments);
}
createClass(HorizontalBoxPlotController, [{
key: "getValueScaleId",

@@ -1612,10 +1605,10 @@ value: function getValueScaleId() {

return HorizontalBoxPlot;
}(BoxPlot);
HorizontalBoxPlot.id = 'horizontalBoxplot';
return HorizontalBoxPlotController;
}(BoxPlotController);
HorizontalBoxPlotController.id = 'horizontalBoxplot';
HorizontalBoxPlot.register = function () {
HorizontalBoxPlot.prototype.dataElementType = BoxAndWiskers.register();
HorizontalBoxPlot.prototype.dataElementOptions = chart_js.controllers.horizontalBar.prototype.dataElementOptions.concat(boxOptionsKeys);
chart_js.defaults.set(HorizontalBoxPlot.id, chart_js.helpers.merge({}, [chart_js.defaults.horizontalBar, baseDefaults$1(boxOptionsKeys), {
HorizontalBoxPlotController.register = function () {
HorizontalBoxPlotController.prototype.dataElementType = BoxAndWiskers.register();
HorizontalBoxPlotController.prototype.dataElementOptions = HorizontalBarController.prototype.dataElementOptions.concat(boxOptionsKeys);
defaults.set(HorizontalBoxPlotController.id, merge({}, [defaults.horizontalBar, baseDefaults$1(boxOptionsKeys), {
datasets: {

@@ -1625,3 +1618,3 @@ animation: {

type: 'number',
properties: chart_js.defaults.bar.datasets.animation.numbers.properties.concat(['q1', 'q3', 'min', 'max', 'median', 'whiskerMin', 'whiskerMax'], boxOptionsKeys.filter(function (c) {
properties: defaults.bar.datasets.animation.numbers.properties.concat(['q1', 'q3', 'min', 'max', 'median', 'whiskerMin', 'whiskerMax'], boxOptionsKeys.filter(function (c) {
return !c.endsWith('Color');

@@ -1633,16 +1626,31 @@ }))

}]));
chart_js.controllers[HorizontalBoxPlot.id] = HorizontalBoxPlot;
return HorizontalBoxPlot;
controllers[HorizontalBoxPlotController.id] = HorizontalBoxPlotController;
return HorizontalBoxPlotController;
};
var HorizontalBoxPlotChart = /*#__PURE__*/function (_Chart2) {
inherits(HorizontalBoxPlotChart, _Chart2);
var _super4 = _createSuper$4(HorizontalBoxPlotChart);
function HorizontalBoxPlotChart(item, config) {
classCallCheck(this, HorizontalBoxPlotChart);
return _super4.call(this, item, patchControllerConfig(config, HorizontalBoxPlotController));
}
return HorizontalBoxPlotChart;
}(Chart);
HorizontalBoxPlotChart.id = HorizontalBoxPlotController.id;
function _createSuper$5(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$5(); 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); }; }
function _isNativeReflectConstruct$5() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
var Violin = /*#__PURE__*/function (_StatsBase) {
inherits(Violin, _StatsBase);
var ViolinController = /*#__PURE__*/function (_StatsBase) {
inherits(ViolinController, _StatsBase);
var _super = _createSuper$5(Violin);
var _super = _createSuper$5(ViolinController);
function Violin() {
classCallCheck(this, Violin);
function ViolinController() {
classCallCheck(this, ViolinController);

@@ -1652,3 +1660,3 @@ return _super.apply(this, arguments);

createClass(Violin, [{
createClass(ViolinController, [{
key: "_parseStats",

@@ -1691,10 +1699,10 @@ value: function _parseStats(value, config) {

return Violin;
return ViolinController;
}(StatsBase$1);
Violin.id = 'violin';
ViolinController.id = 'violin';
Violin.register = function () {
Violin.prototype.dataElementType = ViolinElement.register();
Violin.prototype.dataElementOptions = chart_js.controllers.bar.prototype.dataElementOptions.concat(baseOptionKeys);
chart_js.defaults.set(Violin.id, chart_js.helpers.merge({}, [chart_js.defaults.bar, baseDefaults$1(baseOptionKeys), {
ViolinController.register = function () {
ViolinController.prototype.dataElementType = ViolinElement.register();
ViolinController.prototype.dataElementOptions = BarController.prototype.dataElementOptions.concat(baseOptionKeys);
defaults.set(ViolinController.id, helpers.merge({}, [defaults.bar, baseDefaults$1(baseOptionKeys), {
datasets: {

@@ -1705,3 +1713,3 @@ points: 100,

type: 'number',
properties: chart_js.defaults.bar.datasets.animation.numbers.properties.concat(['q1', 'q3', 'min', 'max', 'median', 'maxEstimate'], baseOptionKeys.filter(function (c) {
properties: defaults.bar.datasets.animation.numbers.properties.concat(['q1', 'q3', 'min', 'max', 'median', 'maxEstimate'], baseOptionKeys.filter(function (c) {
return !c.endsWith('Color');

@@ -1717,18 +1725,32 @@ }))

}]));
chart_js.controllers[Violin.id] = Violin;
return Violin;
controllers[ViolinController.id] = ViolinController;
return ViolinController;
};
var HorizontalViolin = /*#__PURE__*/function (_Violin) {
inherits(HorizontalViolin, _Violin);
var ViolinChart = /*#__PURE__*/function (_Chart) {
inherits(ViolinChart, _Chart);
var _super2 = _createSuper$5(HorizontalViolin);
var _super2 = _createSuper$5(ViolinChart);
function HorizontalViolin() {
classCallCheck(this, HorizontalViolin);
function ViolinChart(item, config) {
classCallCheck(this, ViolinChart);
return _super2.apply(this, arguments);
return _super2.call(this, item, patchControllerConfig(config, ViolinController));
}
createClass(HorizontalViolin, [{
return ViolinChart;
}(Chart);
ViolinChart.id = ViolinController.id;
var HorizontalViolinController = /*#__PURE__*/function (_ViolinController) {
inherits(HorizontalViolinController, _ViolinController);
var _super3 = _createSuper$5(HorizontalViolinController);
function HorizontalViolinController() {
classCallCheck(this, HorizontalViolinController);
return _super3.apply(this, arguments);
}
createClass(HorizontalViolinController, [{
key: "getValueScaleId",

@@ -1745,10 +1767,10 @@ value: function getValueScaleId() {

return HorizontalViolin;
}(Violin);
HorizontalViolin.id = 'horizontalViolin';
return HorizontalViolinController;
}(ViolinController);
HorizontalViolinController.id = 'horizontalViolin';
HorizontalViolin.register = function () {
HorizontalViolin.prototype.dataElementType = ViolinElement.register();
HorizontalViolin.prototype.dataElementOptions = chart_js.controllers.horizontalBar.prototype.dataElementOptions.concat(baseOptionKeys);
chart_js.defaults.set(HorizontalViolin.id, chart_js.helpers.merge({}, [chart_js.defaults.horizontalBar, baseDefaults$1(baseOptionKeys), {
HorizontalViolinController.register = function () {
HorizontalViolinController.prototype.dataElementType = ViolinElement.register();
HorizontalViolinController.prototype.dataElementOptions = HorizontalViolinController.prototype.dataElementOptions.concat(baseOptionKeys);
defaults.set(HorizontalViolinController.id, helpers.merge({}, [defaults.horizontalBar, baseDefaults$1(baseOptionKeys), {
datasets: {

@@ -1759,3 +1781,3 @@ points: 100,

type: 'number',
properties: chart_js.defaults.bar.datasets.animation.numbers.properties.concat(['q1', 'q3', 'min', 'max', 'median', 'maxEstimate'], baseOptionKeys.filter(function (c) {
properties: defaults.bar.datasets.animation.numbers.properties.concat(['q1', 'q3', 'min', 'max', 'median', 'maxEstimate'], baseOptionKeys.filter(function (c) {
return !c.endsWith('Color');

@@ -1771,16 +1793,35 @@ }))

}]));
chart_js.controllers[HorizontalViolin.id] = HorizontalViolin;
return HorizontalViolin;
controllers[HorizontalViolinController.id] = HorizontalViolinController;
return HorizontalViolinController;
};
BoxPlot.register();
HorizontalBoxPlot.register();
Violin.register();
HorizontalViolin.register();
var HorizontalViolinChart = /*#__PURE__*/function (_Chart2) {
inherits(HorizontalViolinChart, _Chart2);
var _super4 = _createSuper$5(HorizontalViolinChart);
function HorizontalViolinChart(item, config) {
classCallCheck(this, HorizontalViolinChart);
return _super4.call(this, item, patchControllerConfig(config, HorizontalViolinController));
}
return HorizontalViolinChart;
}(Chart);
HorizontalViolinChart.id = HorizontalViolinController.id;
BoxPlotController.register();
HorizontalBoxPlotController.register();
ViolinController.register();
HorizontalViolinController.register();
exports.BoxAndWiskers = BoxAndWiskers;
exports.BoxPlot = BoxPlot;
exports.HorizontalBoxPlot = HorizontalBoxPlot;
exports.HorizontalViolin = HorizontalViolin;
exports.Violin = Violin;
exports.BoxPlotChart = BoxPlotChart;
exports.BoxPlotController = BoxPlotController;
exports.HorizontalBoxPlotChart = HorizontalBoxPlotChart;
exports.HorizontalBoxPlotController = HorizontalBoxPlotController;
exports.HorizontalViolinChart = HorizontalViolinChart;
exports.HorizontalViolinController = HorizontalViolinController;
exports.ViolinChart = ViolinChart;
exports.ViolinController = ViolinController;
exports.ViolinElement = ViolinElement;

@@ -1787,0 +1828,0 @@ exports.boxOptionsKeys = boxOptionsKeys;

@@ -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";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 s=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 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&&s(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});function d(t){return 1/Math.sqrt(2*Math.PI)*Math.exp(-.5*t*t)}function p(t,e){return t-e}function m(t){var e=function(t,e){var r=(t=t.slice().sort(p)).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 y(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 v(t,e){var r=t.length-1,n=function(n){var i=n*r,o=Math.floor(i),a=i-o,s=t[o];return 0===a?s:e(s,t[Math.min(o+1,r)],a)};return{min:t[0],q1:n(.25),median:n(.5),q3:n(.75),max:t[r]}}function g(t){return v(t,function(t,e,r){return t+r*(e-t)})}function x(t){return v(t,function(t,e,r){return t+(e-t)*r})}function b(t){return v(t,function(t){return t})}function k(t){return v(t,function(t,e){return e})}function w(t){return v(t,function(t,e,r){return r<.5?t:e})}function q(t){return v(t,function(t,e){return.5*(t+e)})}function _(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 M(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 s=0;s<e.length;s++){var u=e[s];if(u>=o){o=u;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 P={coef:1.5,quantiles:7};function R(t){return{coef:null==t||"number"!=typeof t.coef?P.coef:t.coef,quantiles:function(t){return"function"==typeof t?t:{hinges:_,fivenum:_,7:g,quantiles:g,linear:x,lower:b,higher:k,nearest:w,midpoint:q}[t]||g}(null==t?null:t.quantiles)}}function S(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,R(e).quantiles)(t),n=function(){var t=d,e=[],r=y;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 B(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=R(e).coef,n=M(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=R(e),n=r.quantiles,i=r.coef,o=n(t),a=M(o,t,i),s=a.whiskerMin,u=a.whiskerMax;return o.outliers=t.filter(function(t){return t<s||t>u}),o.whiskerMin=s,o.whiskerMax=u,o.items=t,o}(t,e):void 0}function C(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 O=Object.assign({},e.defaults.elements.rectangle,{borderWidth:1,outlierStyle:"circle",outlierRadius:2,outlierBackgroundColor:e.defaults.elements.rectangle.backgroundColor,outlierBorderColor:e.defaults.elements.rectangle.borderColor,outlierBorderWidth:1,itemStyle:"circle",itemRadius:0,itemBackgroundColor:e.defaults.elements.rectangle.backgroundColor,itemBorderColor:e.defaults.elements.rectangle.borderColor,itemBorderWidth:0,hitPadding:2,outlierHitRadius:4}),N=["outlierStyle","outlierRadius","outlierBackgroundColor","outlierBorderColor","outlierBorderWidth","outlierHitRadius","itemStyle","itemRadius","itemBackgroundColor","itemBorderColor","itemBorderWidth","hitPadding"],T=function(t){u(i,t);var r=C(i);function i(){return n(this,i),r.apply(this,arguments)}return o(i,[{key:"isVertical",value:function(){return null==this.height}},{key:"_drawItems",value:function(t){var r=this.isVertical(),n=this.getProps(["x","y","items","width","height"]),i=this.options;if(!(i.itemRadius<=0||!n.items||n.items.length<=0)){t.save(),t.strokeStyle=i.itemBorderColor,t.fillStyle=i.itemBackgroundColor,t.lineWith=i.itemBorderWidth;var o,a=(void 0===(o=1e3*this._datasetIndex+this._index)&&(o=Date.now()),function(){return(o=(9301*o+49297)%233280)/233280}),s={pointStyle:i.itemStyle,radius:i.itemRadius,borderWidth:i.itemBorderWidth};r?n.items.forEach(function(r){e.helpers.canvas.drawPoint(t,s,n.x-n.width/2+a()*n.width,r)}):n.items.forEach(function(r){e.helpers.canvas.drawPoint(t,s,r,n.y-n.height/2+a()*n.height)}),t.restore()}}},{key:"_drawOutliers",value:function(t){var r=this.isVertical(),n=this.getProps(["x","y","outliers"]),i=this.options;if(!(i.outlierRadius<=0)&&n.outliers&&0!==n.outliers.length){t.save(),t.fillStyle=i.outlierBackgroundColor,t.strokeStyle=i.outlierBorderColor,t.lineWidth=i.outlierBorderWidth;var o={pointStyle:i.outlierStyle,radius:i.outlierRadius,borderWidth:i.outlierBorderWidth};r?n.outliers.forEach(function(r){e.helpers.canvas.drawPoint(t,o,n.x,r)}):n.outliers.forEach(function(r){e.helpers.canvas.drawPoint(t,o,r,n.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:"inLabelRange",value:function(t,e,r){if(Number.isNaN(this.x)&&Number.isNaN(this.y))return!1;var n=this._getHitBounds(r);return this.isVertical()?t>=n.left&&t<=n.right:e>=n.top&&e<=n.bottom}},{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 s=a?e:t,u=0;u<o.length;u++)if(Math.abs(o[u]-s)<=i)return u;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:"getArea",value:function(){return 0}},{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})}}]),i}(e.Element);function A(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 E=N.concat(["medianColor","lowerBackgroundColor"]),I=function(t){u(r,T);var e=A(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),s=a.y,u=a.height,l=a.whiskerMax,c=s-u/2;return{left:a.whiskerMin,top:c,right:l,bottom:c+u}}},{key:"getArea",value:function(t){var e=this.getProps(["q3","q1","width","height"],t),r=Math.abs(e.q3-e.q1);return this.isVertical()?r*e.width:r*e.height}}]),r}();function V(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)}}I._type="boxandwhiskers",I.register=function(){return e.defaults.set("elements",r({},I._type,Object.assign({},O,{medianColor:"transparent",lowerBackgroundColor:"transparent"}))),I};var W=function(t){u(i,T);var r=V(i);function i(){return n(this,i),r.apply(this,arguments)}return o(i,[{key:"draw",value:function(t){t.save(),t.fillStyle=this.options.backgroundColor,t.strokeStyle=this.options.borderColor,t.lineWidth=this.options.borderWidth;var r=this.getProps(["x","y","width","height","min","max","coords","maxEstimate"]);e.helpers.canvas.drawPoint(t,{pointStyle:"rectRot",radius:5,borderWidth:this.options.borderWidth},r.x,r.y),r.coords&&r.coords.length>0&&this._drawCoords(t,r),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),s=a.y,u=a.height,l=s-u/2;return{left:a.min,top:l,right:a.max,bottom:l+u}}},{key:"getArea",value:function(){var t=this.getProps(["min","max","height","width"]),e=Math.abs(t.max-t.min);return this.isVertical()?e*t.width:e*t.height}}]),i}();W._type="violin",W.register=function(){return e.defaults.set("elements",r({},W._type,O)),W};var D=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=h(t)););return t},j=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=D(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}),H={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?H.number(t,e,r):Array.isArray(t)&&Array.isArray(e)?e.map(function(e,n){return H.number(t[n],e,r)}):e}function L(t,e,r){return Array.isArray(t)&&Array.isArray(e)?e.map(function(e,n){return{v:H.number(t[n]?t[n].v:null,e.v,r),estimate:H.number(t[n]?t[n].estimate:null,e.estimate,r)}}):e}function F(t){var e=t.value;e&&null!=this._tooltipOutlier&&t.datasetIndex===this._tooltipOutlier.datasetIndex&&(e.hoveredOutlierIndex=this._tooltipOutlier.index)}function Y(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 s=t[r].element;if(s&&s.hasValue()){var u=s.tooltipPosition(e,this);i+=u.x,o+=u.y,++a}}return{x:i/a,y:o/a}}function G(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 K(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"},P),tooltips:{position:Y.register().id,callbacks:{beforeLabel:F}}}}Y.id="averageInstance",Y.register=function(){return e.plugins.getAll().find(function(t){return"tooltip"===t.id}).positioners[Y.id]=Y,Y};var X=function(t){u(r,t);var e=G(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=j(h(r.prototype),"getMinMax",this).call(this,t,e).min;t.axis=i.maxStats;var a=j(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(),s=[],u=0;u<n;u++){var l=u+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),s.push(c)}return s}},{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=j(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,s=this.getParsed(e),u=a.getBasePixel();n._datasetIndex=this.index,n._index=e,this._transformStats(n,s,function(t){return o?u:a.getPixelForValue(t)},i),j(h(r.prototype),"updateElement",this).call(this,t,e,n,i)}}]),r}(e.controllers.bar);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 Q=function(t){u(r,X);var e=J(r);function r(){return n(this,r),e.apply(this,arguments)}return o(r,[{key:"_parseStats",value:function(t,e){return B(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,s=["outliers","items"];a<s.length;a++){var u=s[a];Array.isArray(e[u])&&(t[u]=e[u].map(r))}}}]),r}();Q.id="boxplot",Q.register=function(){return Q.prototype.dataElementType=I.register(),Q.prototype.dataElementOptions=e.controllers.bar.prototype.dataElementOptions.concat(E),e.defaults.set(Q.id,e.helpers.merge({},[e.defaults.bar,K(E),{datasets:{animation:{numbers:{type:"number",properties:e.defaults.bar.datasets.animation.numbers.properties.concat(["q1","q3","min","max","median","whiskerMin","whiskerMax"],E.filter(function(t){return!t.endsWith("Color")}))}}}}])),e.controllers[Q.id]=Q,Q};var U=function(t){u(r,Q);var e=J(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}();function Z(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)}}U.id="horizontalBoxplot",U.register=function(){return U.prototype.dataElementType=I.register(),U.prototype.dataElementOptions=e.controllers.horizontalBar.prototype.dataElementOptions.concat(E),e.defaults.set(U.id,e.helpers.merge({},[e.defaults.horizontalBar,K(E),{datasets:{animation:{numbers:{type:"number",properties:e.defaults.bar.datasets.animation.numbers.properties.concat(["q1","q3","min","max","median","whiskerMin","whiskerMax"],E.filter(function(t){return!t.endsWith("Color")}))}}}}])),e.controllers[U.id]=U,U};var $=function(t){u(r,X);var e=Z(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)?S(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,s=["outliers","items"];a<s.length;a++){var u=s[a];Array.isArray(e[u])&&(t[u]=e[u].map(r))}Array.isArray(e.coords)&&(t.coords=e.coords.map(function(t){return Object.assign({},t,{v:r(t.v)})}))}}]),r}();$.id="violin",$.register=function(){return $.prototype.dataElementType=W.register(),$.prototype.dataElementOptions=e.controllers.bar.prototype.dataElementOptions.concat(N),e.defaults.set($.id,e.helpers.merge({},[e.defaults.bar,K(N),{datasets:{points:100,animation:{numbers:{type:"number",properties:e.defaults.bar.datasets.animation.numbers.properties.concat(["q1","q3","min","max","median","maxEstimate"],N.filter(function(t){return!t.endsWith("Color")}))},kdeCoords:{fn:L,properties:["coords"]}}}}])),e.controllers[$.id]=$,$};var tt=function(t){u(r,$);var e=Z(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}();tt.id="horizontalViolin",tt.register=function(){return tt.prototype.dataElementType=W.register(),tt.prototype.dataElementOptions=e.controllers.horizontalBar.prototype.dataElementOptions.concat(N),e.defaults.set(tt.id,e.helpers.merge({},[e.defaults.horizontalBar,K(N),{datasets:{points:100,animation:{numbers:{type:"number",properties:e.defaults.bar.datasets.animation.numbers.properties.concat(["q1","q3","min","max","median","maxEstimate"],N.filter(function(t){return!t.endsWith("Color")}))},kdeCoords:{fn:L,properties:["coords"]}}}}])),e.controllers[tt.id]=tt,tt},Q.register(),U.register(),$.register(),tt.register(),t.BoxAndWiskers=I,t.BoxPlot=Q,t.HorizontalBoxPlot=U,t.HorizontalViolin=tt,t.Violin=$,t.ViolinElement=W,t.boxOptionsKeys=E,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,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})});
{
"name": "@sgratzl/chartjs-chart-boxplot",
"description": "Chart.js module for charting boxplots and violin charts",
"version": "3.0.0-alpha.1",
"version": "3.0.0-alpha.2",
"publishConfig": {

@@ -89,2 +89,2 @@ "access": "public"

}
}
}

@@ -336,12 +336,14 @@ # Chart.js Box and Violin Plot

Variant A:
```js
import Chart from 'chart.js';
import { BoxPlot } from '@sgratzl/chartjs-chart-boxplot';
import { BoxPlotController } from '@sgratzl/chartjs-chart-boxplot';
// register controller in chart.js and ensure the defaults are set
BoxPlot.register();
BoxPlotController.register();
...
new Chart(ctx, {
type: BoxPlot.id,
type: BoxPlotController.id,
data: [...],

@@ -351,2 +353,13 @@ });

Variant B:
```js
import Chart from 'chart.js';
import { BoxPlotChart } from '@sgratzl/chartjs-chart-boxplot';
new BoxPlotChart(ctx, {
data: [...],
});
```
## Development Environment

@@ -353,0 +366,0 @@

export * from '.';
import { BoxPlot, HorizontalBoxPlot, Violin, HorizontalViolin } from './controllers';
import {
BoxPlotController,
HorizontalBoxPlotController,
ViolinController,
HorizontalViolinController,
} from './controllers';
BoxPlot.register();
HorizontalBoxPlot.register();
Violin.register();
HorizontalViolin.register();
BoxPlotController.register();
HorizontalBoxPlotController.register();
ViolinController.register();
HorizontalViolinController.register();
import { interpolateNumberArray } from '../animation';
import { outlierPositioner, patchInHoveredOutlier } from '../tooltip';
import { controllers } from 'chart.js';
import { BarController } from '../chart';
import { defaultStatsOptions } from '../data';

@@ -49,3 +49,3 @@

export class StatsBase extends controllers.bar {
export class StatsBase extends BarController {
getMinMax(scale, canStack) {

@@ -52,0 +52,0 @@ const bak = scale.axis;

import { asBoxPlotStats } from '../data';
import { controllers, helpers, defaults } from 'chart.js';
import { Chart, controllers, defaults, BarController, HorizontalBarController, merge } from '../chart';
import { baseDefaults, StatsBase } from './base';
import { BoxAndWiskers, boxOptionsKeys } from '../elements';
import { patchControllerConfig } from './utils';
export class BoxPlot extends StatsBase {
export class BoxPlotController extends StatsBase {
_parseStats(value, config) {

@@ -27,10 +28,10 @@ return asBoxPlotStats(value, config);

BoxPlot.id = 'boxplot';
BoxPlot.register = () => {
BoxPlot.prototype.dataElementType = BoxAndWiskers.register();
BoxPlot.prototype.dataElementOptions = controllers.bar.prototype.dataElementOptions.concat(boxOptionsKeys);
BoxPlotController.id = 'boxplot';
BoxPlotController.register = () => {
BoxPlotController.prototype.dataElementType = BoxAndWiskers.register();
BoxPlotController.prototype.dataElementOptions = BarController.prototype.dataElementOptions.concat(boxOptionsKeys);
defaults.set(
BoxPlot.id,
helpers.merge({}, [
BoxPlotController.id,
merge({}, [
defaults.bar,

@@ -53,7 +54,14 @@ baseDefaults(boxOptionsKeys),

);
controllers[BoxPlot.id] = BoxPlot;
return BoxPlot;
controllers[BoxPlotController.id] = BoxPlotController;
return BoxPlotController;
};
export class HorizontalBoxPlot extends BoxPlot {
export class BoxPlotChart extends Chart {
constructor(item, config) {
super(item, patchControllerConfig(config, BoxPlotController));
}
}
BoxPlotChart.id = BoxPlotController.id;
export class HorizontalBoxPlotController extends BoxPlotController {
getValueScaleId() {

@@ -67,6 +75,6 @@ return this._cachedMeta.xAxisID;

HorizontalBoxPlot.id = 'horizontalBoxplot';
HorizontalBoxPlot.register = () => {
HorizontalBoxPlot.prototype.dataElementType = BoxAndWiskers.register();
HorizontalBoxPlot.prototype.dataElementOptions = controllers.horizontalBar.prototype.dataElementOptions.concat(
HorizontalBoxPlotController.id = 'horizontalBoxplot';
HorizontalBoxPlotController.register = () => {
HorizontalBoxPlotController.prototype.dataElementType = BoxAndWiskers.register();
HorizontalBoxPlotController.prototype.dataElementOptions = HorizontalBarController.prototype.dataElementOptions.concat(
boxOptionsKeys

@@ -76,4 +84,4 @@ );

defaults.set(
HorizontalBoxPlot.id,
helpers.merge({}, [
HorizontalBoxPlotController.id,
merge({}, [
defaults.horizontalBar,

@@ -96,4 +104,11 @@ baseDefaults(boxOptionsKeys),

);
controllers[HorizontalBoxPlot.id] = HorizontalBoxPlot;
return HorizontalBoxPlot;
controllers[HorizontalBoxPlotController.id] = HorizontalBoxPlotController;
return HorizontalBoxPlotController;
};
export class HorizontalBoxPlotChart extends Chart {
constructor(item, config) {
super(item, patchControllerConfig(config, HorizontalBoxPlotController));
}
}
HorizontalBoxPlotChart.id = HorizontalBoxPlotController.id;
import { asViolinStats } from '../data';
import { controllers, defaults, helpers } from 'chart.js';
import { Chart, controllers, defaults, helpers, BarController, HorizontalBarController } from '../chart';
import { StatsBase, baseDefaults } from './base';

@@ -7,4 +7,5 @@ import { baseOptionKeys } from '../elements/base';

import { interpolateKdeCoords } from '../animation';
import { patchControllerConfig } from './utils';
export class Violin extends StatsBase {
export class ViolinController extends StatsBase {
_parseStats(value, config) {

@@ -34,9 +35,9 @@ return asViolinStats(value, config);

Violin.id = 'violin';
Violin.register = () => {
Violin.prototype.dataElementType = ViolinElement.register();
Violin.prototype.dataElementOptions = controllers.bar.prototype.dataElementOptions.concat(baseOptionKeys);
ViolinController.id = 'violin';
ViolinController.register = () => {
ViolinController.prototype.dataElementType = ViolinElement.register();
ViolinController.prototype.dataElementOptions = BarController.prototype.dataElementOptions.concat(baseOptionKeys);
defaults.set(
Violin.id,
ViolinController.id,
helpers.merge({}, [

@@ -65,7 +66,14 @@ defaults.bar,

);
controllers[Violin.id] = Violin;
return Violin;
controllers[ViolinController.id] = ViolinController;
return ViolinController;
};
export class HorizontalViolin extends Violin {
export class ViolinChart extends Chart {
constructor(item, config) {
super(item, patchControllerConfig(config, ViolinController));
}
}
ViolinChart.id = ViolinController.id;
export class HorizontalViolinController extends ViolinController {
getValueScaleId() {

@@ -79,6 +87,6 @@ return this._cachedMeta.xAxisID;

HorizontalViolin.id = 'horizontalViolin';
HorizontalViolin.register = () => {
HorizontalViolin.prototype.dataElementType = ViolinElement.register();
HorizontalViolin.prototype.dataElementOptions = controllers.horizontalBar.prototype.dataElementOptions.concat(
HorizontalViolinController.id = 'horizontalViolin';
HorizontalViolinController.register = () => {
HorizontalViolinController.prototype.dataElementType = ViolinElement.register();
HorizontalViolinController.prototype.dataElementOptions = HorizontalViolinController.prototype.dataElementOptions.concat(
baseOptionKeys

@@ -88,3 +96,3 @@ );

defaults.set(
HorizontalViolin.id,
HorizontalViolinController.id,
helpers.merge({}, [

@@ -113,4 +121,11 @@ defaults.horizontalBar,

);
controllers[HorizontalViolin.id] = HorizontalViolin;
return HorizontalViolin;
controllers[HorizontalViolinController.id] = HorizontalViolinController;
return HorizontalViolinController;
};
export class HorizontalViolinChart extends Chart {
constructor(item, config) {
super(item, patchControllerConfig(config, HorizontalViolinController));
}
}
HorizontalViolinChart.id = HorizontalViolinController.id;

@@ -1,5 +0,5 @@

import { defaults, Element, helpers } from 'chart.js';
import { defaults, Element, drawPoint } from '../chart';
import { rnd } from '../data';
export const baseDefaults = Object.assign({}, defaults.elements.rectangle, {
export const baseDefaults = {
borderWidth: 1,

@@ -21,20 +21,6 @@

outlierHitRadius: 4,
});
};
export const baseOptionKeys = [
'outlierStyle',
'outlierRadius',
'outlierBackgroundColor',
'outlierBorderColor',
'outlierBorderWidth',
'outlierHitRadius',
export const baseOptionKeys = Object.keys(baseDefaults);
'itemStyle',
'itemRadius',
'itemBackgroundColor',
'itemBorderColor',
'itemBorderWidth',
'hitPadding',
];
export class StatsBase extends Element {

@@ -69,7 +55,7 @@ isVertical() {

props.items.forEach((v) => {
helpers.canvas.drawPoint(ctx, pointOptions, props.x - props.width / 2 + random() * props.width, v);
drawPoint(ctx, pointOptions, props.x - props.width / 2 + random() * props.width, v);
});
} else {
props.items.forEach((v) => {
helpers.canvas.drawPoint(ctx, pointOptions, v, props.y - props.height / 2 + random() * props.height);
drawPoint(ctx, pointOptions, v, props.y - props.height / 2 + random() * props.height);
});

@@ -100,7 +86,7 @@ }

props.outliers.forEach((v) => {
helpers.canvas.drawPoint(ctx, pointOptions, props.x, v);
drawPoint(ctx, pointOptions, props.x, v);
});
} else {
props.outliers.forEach((v) => {
helpers.canvas.drawPoint(ctx, pointOptions, v, props.y);
drawPoint(ctx, pointOptions, v, props.y);
});

@@ -143,13 +129,2 @@ }

inLabelRange(mouseX, mouseY, useFinalPosition) {
if (Number.isNaN(this.x) && Number.isNaN(this.y)) {
return false;
}
const bounds = this._getHitBounds(useFinalPosition);
if (this.isVertical()) {
return mouseX >= bounds.left && mouseX <= bounds.right;
}
return mouseY >= bounds.top && mouseY <= bounds.bottom;
}
inXRange(mouseX, useFinalPosition) {

@@ -197,6 +172,2 @@ const bounds = this._getHitBounds(useFinalPosition);

getArea() {
return 0; // abstract
}
_getOutliers(useFinalPosition) {

@@ -203,0 +174,0 @@ const props = this.getProps(['outliers'], useFinalPosition);

@@ -1,2 +0,2 @@

import { defaults } from 'chart.js';
import { defaults } from '../chart';
import { StatsBase, baseDefaults, baseOptionKeys } from './base';

@@ -185,16 +185,2 @@

}
// height(useFinalPosition) {
// const props = this.getProps(['base', 'q1', 'q3'], useFinalPosition);
// return props.base - Math.min(props.q1, props.q3);
// }
getArea(useFinalPosition) {
const props = this.getProps(['q3', 'q1', 'width', 'height'], useFinalPosition);
const iqr = Math.abs(props.q3 - props.q1);
if (this.isVertical()) {
return iqr * props.width;
}
return iqr * props.height;
}
}

@@ -205,3 +191,3 @@

defaults.set('elements', {
[BoxAndWiskers._type]: Object.assign({}, baseDefaults, {
[BoxAndWiskers._type]: Object.assign({}, defaults.elements.rectangle, baseDefaults, {
medianColor: 'transparent',

@@ -208,0 +194,0 @@ lowerBackgroundColor: 'transparent',

@@ -1,2 +0,2 @@

import { helpers, defaults } from 'chart.js';
import { defaults, drawPoint } from '../chart';
import { StatsBase, baseDefaults } from './base';

@@ -14,3 +14,3 @@

helpers.canvas.drawPoint(
drawPoint(
ctx,

@@ -92,11 +92,2 @@ {

}
getArea() {
const props = this.getProps(['min', 'max', 'height', 'width']);
const iqr = Math.abs(props.max - props.min);
if (this.isVertical()) {
return iqr * props.width;
}
return iqr * props.height;
}
}

@@ -107,5 +98,5 @@

defaults.set('elements', {
[ViolinElement._type]: baseDefaults,
[ViolinElement._type]: Object.assign({}, defaults.elements.rectangle, baseDefaults),
});
return ViolinElement;
};

@@ -1,2 +0,2 @@

import { plugins } from 'chart.js';
import { plugins } from './chart';

@@ -3,0 +3,0 @@ export function patchInHoveredOutlier(item) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc