chartjs-chart-error-bars
Advanced tools
Comparing version 3.0.0-alpha.2 to 3.0.0-alpha.20
@@ -1,43 +0,3 @@ | ||
import ChartNS from 'chart.js'; | ||
import { Rectangle, Point, Arc, Tooltip, PolarAreaController, color, registry, BarController, merge, Chart, LinearScale, CategoryScale, LineController, ScatterController, resolve, RadialLinearScale } from '@sgratzl/chartjs-esm-facade'; | ||
const Chart = ChartNS; | ||
const defaults = ChartNS.defaults; | ||
// export const DatasetController = ChartNS.DatasetController; | ||
const BarController = ChartNS.controllers.bar; | ||
const HorizontalBarController = ChartNS.controllers.horizontalBar; | ||
const LineController = ChartNS.controllers.line; | ||
const PolarAreaController = ChartNS.controllers.polarArea; | ||
const ScatterController = ChartNS.controllers.scatter; | ||
function registerController(controller) { | ||
ChartNS.controllers[controller.id] = controller; | ||
ChartNS.defaults.set(controller.id, controller.defaults); | ||
return controller; | ||
} | ||
// export const Element = ChartNS.Element; | ||
const Rectangle = ChartNS.elements.Rectangle; | ||
const Point = ChartNS.elements.Point; | ||
// export const Line = ChartNS.elements.Line; | ||
const Arc = ChartNS.elements.Arc; | ||
function registerElement(element) { | ||
ChartNS.defaults.set('elements', { | ||
[element.id]: element.defaults, | ||
}); | ||
return element; | ||
} | ||
const merge = ChartNS.helpers.merge; | ||
// export const drawPoint = ChartNS.helpers.canvas.drawPoint; | ||
const resolve = ChartNS.helpers.options.resolve; | ||
const color = ChartNS.helpers.color; | ||
function patchControllerConfig(config, controller) { | ||
controller.register(); | ||
config.type = controller.id; | ||
return config; | ||
} | ||
const allModelKeys = ['xMin', 'xMax', 'yMin', 'yMax']; | ||
@@ -296,5 +256,5 @@ | ||
} | ||
RectangleWithErrorBar.id = RectangleWithErrorBar._type = 'rectangleWithErrorBar'; | ||
RectangleWithErrorBar.defaults = Object.assign({}, defaults.elements.rectangle, errorBarDefaults); | ||
RectangleWithErrorBar.register = () => registerElement(RectangleWithErrorBar); | ||
RectangleWithErrorBar.id = 'rectangleWithErrorBar'; | ||
RectangleWithErrorBar.defaults = /*#__PURE__*/ Object.assign({}, Rectangle.defaults, errorBarDefaults); | ||
RectangleWithErrorBar.defaultRoutes = Rectangle.defaultRoutes; | ||
@@ -308,5 +268,5 @@ class PointWithErrorBar extends Point { | ||
} | ||
PointWithErrorBar.id = PointWithErrorBar._type = 'pointWithErrorBar'; | ||
PointWithErrorBar.defaults = Object.assign({}, defaults.elements.point, errorBarDefaults); | ||
PointWithErrorBar.register = () => registerElement(PointWithErrorBar); | ||
PointWithErrorBar.id = 'pointWithErrorBar'; | ||
PointWithErrorBar.defaults = /*#__PURE__*/ Object.assign({}, Point.defaults, errorBarDefaults); | ||
PointWithErrorBar.defaultRoutes = Point.defaultRoutes; | ||
@@ -320,5 +280,5 @@ class ArcWithErrorBar extends Arc { | ||
} | ||
ArcWithErrorBar.id = ArcWithErrorBar._type = 'arcWithErrorBar'; | ||
ArcWithErrorBar.defaults = Object.assign({}, defaults.elements.arc, errorBarDefaults); | ||
ArcWithErrorBar.register = () => registerElement(ArcWithErrorBar); | ||
ArcWithErrorBar.id = 'arcWithErrorBar'; | ||
ArcWithErrorBar.defaults = /*#__PURE__*/ Object.assign({}, Arc.defaults, errorBarDefaults); | ||
ArcWithErrorBar.defaultRoutes = Arc.defaultRoutes; | ||
@@ -329,33 +289,15 @@ function reverseOrder(v) { | ||
function generateTooltip(horizontal) { | ||
const keys = modelKeys(horizontal); | ||
return (item, data) => { | ||
const base = defaults.tooltips.callbacks.label.call(this, item, data); | ||
const v = data.datasets[item.datasetIndex].data[item.index]; | ||
if (v == null || keys.every((k) => v[k] == null)) { | ||
return base; | ||
} | ||
return `${base} (${reverseOrder(v[keys[0]])} .. ${v[keys[1]]})`; | ||
}; | ||
function generateBarTooltip(item) { | ||
const keys = modelKeys(item.element.horizontal); | ||
const base = Tooltip.defaults.callbacks.label.call(this, item); | ||
const v = item.chart.data.datasets[item.datasetIndex].data[item.dataIndex]; | ||
if (v == null || keys.every((k) => v[k] == null)) { | ||
return base; | ||
} | ||
return `${base} (${reverseOrder(v[keys[0]])} .. ${v[keys[1]]})`; | ||
} | ||
const verticalTooltipDefaults = { | ||
tooltips: { | ||
callbacks: { | ||
label: generateTooltip(false), | ||
}, | ||
}, | ||
}; | ||
function generateTooltipScatter(item) { | ||
const v = item.chart.data.datasets[item.datasetIndex].data[item.dataIndex]; | ||
const horizontalTooltipDefaults = { | ||
tooltips: { | ||
callbacks: { | ||
label: generateTooltip(true), | ||
}, | ||
}, | ||
}; | ||
function generateTooltipScatter(item, data) { | ||
const v = data.datasets[item.datasetIndex].data[item.index]; | ||
const subLabel = (base, horizontal) => { | ||
@@ -372,5 +314,5 @@ const keys = modelKeys(horizontal); | ||
function generateTooltipPolar(item, data) { | ||
const base = defaults.polarArea.tooltips.callbacks.label.call(this, item, data); | ||
const v = data.datasets[item.datasetIndex].data[item.index]; | ||
function generateTooltipPolar(item) { | ||
const base = PolarAreaController.defaults.tooltips.callbacks.label.call(this, item); | ||
const v = item.chart.data.datasets[item.datasetIndex].data[item.dataIndex]; | ||
@@ -487,2 +429,10 @@ const keys = ['rMin', 'rMax']; | ||
function patchController(config, controller, elements = [], scales = []) { | ||
registry.addControllers(controller); | ||
registry.addElements(elements); | ||
registry.addScales(scales); | ||
config.type = controller.id; | ||
return config; | ||
} | ||
class BarWithErrorBarsController extends BarController { | ||
@@ -506,14 +456,23 @@ getMinMax(scale, canStack) { | ||
} | ||
BarWithErrorBarsController.prototype.dataElementOptions = BarController.prototype.dataElementOptions.concat(styleKeys); | ||
BarWithErrorBarsController.id = 'barWithErrorBars'; | ||
BarWithErrorBarsController.register = () => { | ||
BarWithErrorBarsController.prototype.dataElementType = RectangleWithErrorBar.register(); | ||
BarWithErrorBarsController.defaults = merge({}, [defaults.bar, verticalTooltipDefaults, animationHints]); | ||
return registerController(BarWithErrorBarsController); | ||
}; | ||
BarWithErrorBarsController.defaults = /*#__PURE__*/ merge({}, [ | ||
BarController.defaults, | ||
animationHints, | ||
{ | ||
tooltips: { | ||
callbacks: { | ||
label: generateBarTooltip, | ||
}, | ||
}, | ||
dataElementOptions: BarController.defaults.dataElementOptions.concat(styleKeys), | ||
dataElementType: RectangleWithErrorBar.id, | ||
}, | ||
]); | ||
class BarWithErrorBarsChart extends Chart { | ||
constructor(item, config) { | ||
super(item, patchControllerConfig(config, BarWithErrorBarsController)); | ||
super( | ||
item, | ||
patchController(config, BarWithErrorBarsController, RectangleWithErrorBar, [LinearScale, CategoryScale]) | ||
); | ||
} | ||
@@ -523,42 +482,2 @@ } | ||
class HorizontalBarWithErrorBarsController extends HorizontalBarController { | ||
getMinMax(scale, canStack) { | ||
return getMinMax(scale, canStack, (scale, canStack) => super.getMinMax(scale, canStack)); | ||
} | ||
parseObjectData(meta, data, start, count) { | ||
const parsed = super.parseObjectData(meta, data, start, count); | ||
parseErrorNumberData(parsed, meta.vScale, data, start, count); | ||
parseErrorLabelData(parsed, meta.iScale, start, count); | ||
return parsed; | ||
} | ||
updateElement(element, index, properties, mode) { | ||
// inject the other error bar related properties | ||
calculateScale(properties, this.getParsed(index), this._cachedMeta.vScale, mode === 'reset'); | ||
super.updateElement(element, index, properties, mode); | ||
} | ||
} | ||
HorizontalBarWithErrorBarsController.prototype.dataElementOptions = HorizontalBarController.prototype.dataElementOptions.concat( | ||
styleKeys | ||
); | ||
HorizontalBarWithErrorBarsController.id = 'horizontalBarWithErrorBars'; | ||
HorizontalBarWithErrorBarsController.register = () => { | ||
HorizontalBarWithErrorBarsController.prototype.dataElementType = RectangleWithErrorBar.register(); | ||
HorizontalBarWithErrorBarsController.defaults = merge({}, [ | ||
defaults.horizontalBar, | ||
horizontalTooltipDefaults, | ||
animationHints, | ||
]); | ||
return registerController(HorizontalBarWithErrorBarsController); | ||
}; | ||
class HorizontalBarWithErrorBarsChart extends Chart { | ||
constructor(item, config) { | ||
super(item, patchControllerConfig(config, HorizontalBarWithErrorBarsController)); | ||
} | ||
} | ||
HorizontalBarWithErrorBarsChart.id = HorizontalBarWithErrorBarsController.id; | ||
class LineWithErrorBarsController extends LineController { | ||
@@ -585,18 +504,19 @@ getMinMax(scale, canStack) { | ||
LineWithErrorBarsController.prototype.dataElementOptions = Object.assign( | ||
{}, | ||
LineController.prototype.dataElementOptions, | ||
styleObjectKeys | ||
); | ||
LineWithErrorBarsController.id = 'lineWithErrorBars'; | ||
LineWithErrorBarsController.register = () => { | ||
LineWithErrorBarsController.prototype.dataElementType = PointWithErrorBar.register(); | ||
LineWithErrorBarsController.defaults = merge({}, [defaults.line, verticalTooltipDefaults, animationHints]); | ||
return registerController(LineWithErrorBarsController); | ||
}; | ||
LineWithErrorBarsController.defaults = /*#__PURE__*/ merge({}, [ | ||
LineController.defaults, | ||
animationHints, | ||
{ | ||
tooltips: { | ||
callbacks: { | ||
label: generateBarTooltip, | ||
}, | ||
}, | ||
dataElementType: PointWithErrorBar.id, | ||
dataElementOptions: Object.assign({}, LineController.defaults.dataElementOptions, styleObjectKeys), | ||
}, | ||
]); | ||
class LineWithErrorBarsChart extends Chart { | ||
constructor(item, config) { | ||
super(item, patchControllerConfig(config, LineWithErrorBarsController)); | ||
super(item, patchController(config, LineWithErrorBarsController, PointWithErrorBar, LinearScale)); | ||
} | ||
@@ -606,10 +526,2 @@ } | ||
const tooltipDefaults = { | ||
tooltips: { | ||
callbacks: { | ||
label: generateTooltipScatter, | ||
}, | ||
}, | ||
}; | ||
class ScatterWithErrorBarsController extends ScatterController { | ||
@@ -636,18 +548,21 @@ getMinMax(scale, canStack) { | ||
} | ||
ScatterWithErrorBarsController.prototype.dataElementOptions = Object.assign( | ||
{}, | ||
ScatterController.prototype.dataElementOptions, | ||
styleObjectKeys | ||
); | ||
ScatterWithErrorBarsController.id = 'scatterWithErrorBars'; | ||
ScatterWithErrorBarsController.register = () => { | ||
ScatterWithErrorBarsController.prototype.dataElementType = PointWithErrorBar.register(); | ||
ScatterWithErrorBarsController.defaults = merge({}, [defaults.scatter, tooltipDefaults, animationHints]); | ||
return registerController(ScatterWithErrorBarsController); | ||
}; | ||
ScatterWithErrorBarsController.defaults = /*#__PURE__*/ merge({}, [ | ||
ScatterController.defaults, | ||
animationHints, | ||
{ | ||
tooltips: { | ||
callbacks: { | ||
label: generateTooltipScatter, | ||
}, | ||
}, | ||
dataElementType: PointWithErrorBar.id, | ||
dataElementOptions: Object.assign({}, LineController.defaults.dataElementOptions, styleObjectKeys), | ||
}, | ||
]); | ||
class ScatterWithErrorBarsChart extends Chart { | ||
constructor(item, config) { | ||
super(item, patchControllerConfig(config, ScatterWithErrorBarsController)); | ||
super(item, patchController(config, ScatterWithErrorBarsController, PointWithErrorBar, LinearScale)); | ||
} | ||
@@ -657,10 +572,2 @@ } | ||
const tooltipDefaults$1 = { | ||
tooltips: { | ||
callbacks: { | ||
label: generateTooltipPolar, | ||
}, | ||
}, | ||
}; | ||
class PolarAreaWithErrorBarsController extends PolarAreaController { | ||
@@ -695,8 +602,9 @@ getMinMax(scale, canStack) { | ||
const parsed = new Array(count); | ||
const scale = meta.rScale; | ||
for (let i = 0; i < count; ++i) { | ||
const index = i + start; | ||
const item = data[index]; | ||
const v = meta.rScale.parseObject(item, 'r', index); | ||
const v = scale.parse(item[scale.axis], index); | ||
parsed[i] = { | ||
[meta.rScale.axis]: v, | ||
[scale.axis]: v, | ||
}; | ||
@@ -734,18 +642,20 @@ } | ||
PolarAreaWithErrorBarsController.prototype.dataElementOptions = Object.assign( | ||
{}, | ||
PolarAreaController.prototype.dataElementOptions, | ||
styleObjectKeys | ||
); | ||
PolarAreaWithErrorBarsController.id = 'polarAreaWithErrorBars'; | ||
PolarAreaWithErrorBarsController.register = () => { | ||
PolarAreaWithErrorBarsController.prototype.dataElementType = ArcWithErrorBar.register(); | ||
PolarAreaWithErrorBarsController.defaults = merge({}, [defaults.polarArea, tooltipDefaults$1, animationHints]); | ||
return registerController(PolarAreaWithErrorBarsController); | ||
}; | ||
PolarAreaWithErrorBarsController.defaults = /*#__PURE__*/ merge({}, [ | ||
PolarAreaController.defaults, | ||
animationHints, | ||
{ | ||
tooltips: { | ||
callbacks: { | ||
label: generateTooltipPolar, | ||
}, | ||
}, | ||
dataElementType: ArcWithErrorBar.id, | ||
dataElementOptions: PolarAreaController.defaults.dataElementOptions.concat(styleKeys), | ||
}, | ||
]); | ||
class PolarAreaWithErrorBarsChart extends Chart { | ||
constructor(item, config) { | ||
super(item, patchControllerConfig(config, PolarAreaWithErrorBarsController)); | ||
super(item, patchController(config, PolarAreaWithErrorBarsController, ArcWithErrorBar, RadialLinearScale)); | ||
} | ||
@@ -755,2 +665,2 @@ } | ||
export { ArcWithErrorBar, BarWithErrorBarsChart, BarWithErrorBarsController, HorizontalBarWithErrorBarsChart, HorizontalBarWithErrorBarsController, LineWithErrorBarsChart, LineWithErrorBarsController, PointWithErrorBar, PolarAreaWithErrorBarsChart, PolarAreaWithErrorBarsController, RectangleWithErrorBar, ScatterWithErrorBarsChart, ScatterWithErrorBarsController }; | ||
export { ArcWithErrorBar, BarWithErrorBarsChart, BarWithErrorBarsController, LineWithErrorBarsChart, LineWithErrorBarsController, PointWithErrorBar, PolarAreaWithErrorBarsChart, PolarAreaWithErrorBarsController, RectangleWithErrorBar, ScatterWithErrorBarsChart, ScatterWithErrorBarsController }; |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('chart.js')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'chart.js'], factory) : | ||
(global = global || self, factory(global.ChartErrorBars = {}, global.Chart)); | ||
}(this, (function (exports, ChartNS) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@sgratzl/chartjs-esm-facade')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@sgratzl/chartjs-esm-facade'], factory) : | ||
(global = global || self, factory(global.ChartErrorBars = {}, global.ChartESMFacade)); | ||
}(this, (function (exports, chartjsEsmFacade) { 'use strict'; | ||
ChartNS = ChartNS && Object.prototype.hasOwnProperty.call(ChartNS, 'default') ? ChartNS['default'] : ChartNS; | ||
function _classCallCheck(instance, Constructor) { | ||
@@ -35,6 +33,16 @@ if (!(instance instanceof Constructor)) { | ||
function createCommonjsModule(fn, module) { | ||
return module = { exports: {} }, fn(module, module.exports), module.exports; | ||
function createCommonjsModule(fn, basedir, module) { | ||
return module = { | ||
path: basedir, | ||
exports: {}, | ||
require: function (path, base) { | ||
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base); | ||
} | ||
}, fn(module, module.exports), module.exports; | ||
} | ||
function commonjsRequire () { | ||
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs'); | ||
} | ||
var getPrototypeOf = createCommonjsModule(function (module) { | ||
@@ -156,51 +164,2 @@ function _getPrototypeOf(o) { | ||
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; | ||
var defaults = ChartNS.defaults; // export const DatasetController = ChartNS.DatasetController; | ||
var BarController = ChartNS.controllers.bar; | ||
var HorizontalBarController = ChartNS.controllers.horizontalBar; | ||
var LineController = ChartNS.controllers.line; | ||
var PolarAreaController = ChartNS.controllers.polarArea; | ||
var ScatterController = ChartNS.controllers.scatter; | ||
function registerController(controller) { | ||
ChartNS.controllers[controller.id] = controller; | ||
ChartNS.defaults.set(controller.id, controller.defaults); | ||
return controller; | ||
} // export const Element = ChartNS.Element; | ||
var Rectangle = ChartNS.elements.Rectangle; | ||
var Point = ChartNS.elements.Point; // export const Line = ChartNS.elements.Line; | ||
var Arc = ChartNS.elements.Arc; | ||
function registerElement(element) { | ||
ChartNS.defaults.set('elements', defineProperty({}, element.id, element.defaults)); | ||
return element; | ||
} | ||
var merge = ChartNS.helpers.merge; // export const drawPoint = ChartNS.helpers.canvas.drawPoint; | ||
var resolve = ChartNS.helpers.options.resolve; | ||
var color = ChartNS.helpers.color; | ||
function patchControllerConfig(config, controller) { | ||
controller.register(); | ||
config.type = controller.id; | ||
return config; | ||
} | ||
function _arrayWithHoles(arr) { | ||
@@ -551,3 +510,3 @@ if (Array.isArray(arr)) return arr; | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); 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 _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { 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); }; } | ||
@@ -576,12 +535,9 @@ 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; } } | ||
return RectangleWithErrorBar; | ||
}(Rectangle); | ||
RectangleWithErrorBar.id = RectangleWithErrorBar._type = 'rectangleWithErrorBar'; | ||
RectangleWithErrorBar.defaults = Object.assign({}, defaults.elements.rectangle, errorBarDefaults); | ||
}(chartjsEsmFacade.Rectangle); | ||
RectangleWithErrorBar.id = 'rectangleWithErrorBar'; | ||
RectangleWithErrorBar.defaults = /*#__PURE__*/Object.assign({}, chartjsEsmFacade.Rectangle.defaults, errorBarDefaults); | ||
RectangleWithErrorBar.defaultRoutes = chartjsEsmFacade.Rectangle.defaultRoutes; | ||
RectangleWithErrorBar.register = function () { | ||
return registerElement(RectangleWithErrorBar); | ||
}; | ||
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { 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 _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); }; } | ||
function _isNativeReflectConstruct$1() { 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; } } | ||
@@ -609,12 +565,9 @@ var PointWithErrorBar = /*#__PURE__*/function (_Point) { | ||
return PointWithErrorBar; | ||
}(Point); | ||
PointWithErrorBar.id = PointWithErrorBar._type = 'pointWithErrorBar'; | ||
PointWithErrorBar.defaults = Object.assign({}, defaults.elements.point, errorBarDefaults); | ||
}(chartjsEsmFacade.Point); | ||
PointWithErrorBar.id = 'pointWithErrorBar'; | ||
PointWithErrorBar.defaults = /*#__PURE__*/Object.assign({}, chartjsEsmFacade.Point.defaults, errorBarDefaults); | ||
PointWithErrorBar.defaultRoutes = chartjsEsmFacade.Point.defaultRoutes; | ||
PointWithErrorBar.register = function () { | ||
return registerElement(PointWithErrorBar); | ||
}; | ||
function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { 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 _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); 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$2() { 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; } } | ||
@@ -642,10 +595,7 @@ var ArcWithErrorBar = /*#__PURE__*/function (_Arc) { | ||
return ArcWithErrorBar; | ||
}(Arc); | ||
ArcWithErrorBar.id = ArcWithErrorBar._type = 'arcWithErrorBar'; | ||
ArcWithErrorBar.defaults = Object.assign({}, defaults.elements.arc, errorBarDefaults); | ||
}(chartjsEsmFacade.Arc); | ||
ArcWithErrorBar.id = 'arcWithErrorBar'; | ||
ArcWithErrorBar.defaults = /*#__PURE__*/Object.assign({}, chartjsEsmFacade.Arc.defaults, errorBarDefaults); | ||
ArcWithErrorBar.defaultRoutes = chartjsEsmFacade.Arc.defaultRoutes; | ||
ArcWithErrorBar.register = function () { | ||
return registerElement(ArcWithErrorBar); | ||
}; | ||
function reverseOrder(v) { | ||
@@ -655,37 +605,18 @@ return Array.isArray(v) ? v.slice().reverse() : v; | ||
function generateTooltip(horizontal) { | ||
var _this = this; | ||
function generateBarTooltip(item) { | ||
var keys = modelKeys(item.element.horizontal); | ||
var base = chartjsEsmFacade.Tooltip.defaults.callbacks.label.call(this, item); | ||
var v = item.chart.data.datasets[item.datasetIndex].data[item.dataIndex]; | ||
var keys = modelKeys(horizontal); | ||
return function (item, data) { | ||
var base = defaults.tooltips.callbacks.label.call(_this, item, data); | ||
var v = data.datasets[item.datasetIndex].data[item.index]; | ||
if (v == null || keys.every(function (k) { | ||
return v[k] == null; | ||
})) { | ||
return base; | ||
} | ||
if (v == null || keys.every(function (k) { | ||
return v[k] == null; | ||
})) { | ||
return base; | ||
} | ||
return "".concat(base, " (").concat(reverseOrder(v[keys[0]]), " .. ").concat(v[keys[1]], ")"); | ||
}; | ||
return "".concat(base, " (").concat(reverseOrder(v[keys[0]]), " .. ").concat(v[keys[1]], ")"); | ||
} | ||
function generateTooltipScatter(item) { | ||
var v = item.chart.data.datasets[item.datasetIndex].data[item.dataIndex]; | ||
var verticalTooltipDefaults = { | ||
tooltips: { | ||
callbacks: { | ||
label: generateTooltip(false) | ||
} | ||
} | ||
}; | ||
var horizontalTooltipDefaults = { | ||
tooltips: { | ||
callbacks: { | ||
label: generateTooltip(true) | ||
} | ||
} | ||
}; | ||
function generateTooltipScatter(item, data) { | ||
var v = data.datasets[item.datasetIndex].data[item.index]; | ||
var subLabel = function subLabel(base, horizontal) { | ||
@@ -705,5 +636,5 @@ var keys = modelKeys(horizontal); | ||
} | ||
function generateTooltipPolar(item, data) { | ||
var base = defaults.polarArea.tooltips.callbacks.label.call(this, item, data); | ||
var v = data.datasets[item.datasetIndex].data[item.index]; | ||
function generateTooltipPolar(item) { | ||
var base = chartjsEsmFacade.PolarAreaController.defaults.tooltips.callbacks.label.call(this, item); | ||
var v = item.chart.data.datasets[item.datasetIndex].data[item.dataIndex]; | ||
var keys = ['rMin', 'rMax']; | ||
@@ -721,3 +652,3 @@ | ||
var interpolators = { | ||
color: function color$1(from, to, factor) { | ||
color: function color(from, to, factor) { | ||
var f = from || transparent; | ||
@@ -730,5 +661,5 @@ var t = to || transparent; | ||
var c0 = color(f); | ||
var c0 = chartjsEsmFacade.color(f); | ||
var c1 = c0.valid && color(t); | ||
var c1 = c0.valid && chartjsEsmFacade.color(t); | ||
@@ -869,4 +800,14 @@ return c1 && c1.valid ? c1.mix(c0, factor).hexString() : to; | ||
function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); 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 patchController(config, controller) { | ||
var elements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
var scales = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
chartjsEsmFacade.registry.addControllers(controller); | ||
chartjsEsmFacade.registry.addElements(elements); | ||
chartjsEsmFacade.registry.addScales(scales); | ||
config.type = controller.id; | ||
return config; | ||
} | ||
function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); return function _createSuperInternal() { 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$3() { 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; } } | ||
@@ -913,12 +854,13 @@ var BarWithErrorBarsController = /*#__PURE__*/function (_BarController) { | ||
return BarWithErrorBarsController; | ||
}(BarController); | ||
BarWithErrorBarsController.prototype.dataElementOptions = BarController.prototype.dataElementOptions.concat(styleKeys); | ||
}(chartjsEsmFacade.BarController); | ||
BarWithErrorBarsController.id = 'barWithErrorBars'; | ||
BarWithErrorBarsController.register = function () { | ||
BarWithErrorBarsController.prototype.dataElementType = RectangleWithErrorBar.register(); | ||
BarWithErrorBarsController.defaults = merge({}, [defaults.bar, verticalTooltipDefaults, animationHints]); | ||
return registerController(BarWithErrorBarsController); | ||
}; | ||
BarWithErrorBarsController.defaults = /*#__PURE__*/chartjsEsmFacade.merge({}, [chartjsEsmFacade.BarController.defaults, animationHints, { | ||
tooltips: { | ||
callbacks: { | ||
label: generateBarTooltip | ||
} | ||
}, | ||
dataElementOptions: chartjsEsmFacade.BarController.defaults.dataElementOptions.concat(styleKeys), | ||
dataElementType: RectangleWithErrorBar.id | ||
}]); | ||
var BarWithErrorBarsChart = /*#__PURE__*/function (_Chart) { | ||
@@ -932,75 +874,11 @@ inherits(BarWithErrorBarsChart, _Chart); | ||
return _super2.call(this, item, patchControllerConfig(config, BarWithErrorBarsController)); | ||
return _super2.call(this, item, patchController(config, BarWithErrorBarsController, RectangleWithErrorBar, [chartjsEsmFacade.LinearScale, chartjsEsmFacade.CategoryScale])); | ||
} | ||
return BarWithErrorBarsChart; | ||
}(Chart); | ||
}(chartjsEsmFacade.Chart); | ||
BarWithErrorBarsChart.id = BarWithErrorBarsController.id; | ||
var HorizontalBarWithErrorBarsController = /*#__PURE__*/function (_HorizontalBarControl) { | ||
inherits(HorizontalBarWithErrorBarsController, _HorizontalBarControl); | ||
var _super3 = _createSuper$3(HorizontalBarWithErrorBarsController); | ||
function _createSuper$4(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$4(); return function _createSuperInternal() { 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 HorizontalBarWithErrorBarsController() { | ||
classCallCheck(this, HorizontalBarWithErrorBarsController); | ||
return _super3.apply(this, arguments); | ||
} | ||
createClass(HorizontalBarWithErrorBarsController, [{ | ||
key: "getMinMax", | ||
value: function getMinMax$1(scale, canStack) { | ||
var _this2 = this; | ||
return getMinMax(scale, canStack, function (scale, canStack) { | ||
return get(getPrototypeOf(HorizontalBarWithErrorBarsController.prototype), "getMinMax", _this2).call(_this2, scale, canStack); | ||
}); | ||
} | ||
}, { | ||
key: "parseObjectData", | ||
value: function parseObjectData(meta, data, start, count) { | ||
var parsed = get(getPrototypeOf(HorizontalBarWithErrorBarsController.prototype), "parseObjectData", this).call(this, meta, data, start, count); | ||
parseErrorNumberData(parsed, meta.vScale, data, start, count); | ||
parseErrorLabelData(parsed, meta.iScale, start, count); | ||
return parsed; | ||
} | ||
}, { | ||
key: "updateElement", | ||
value: function updateElement(element, index, properties, mode) { | ||
// inject the other error bar related properties | ||
calculateScale(properties, this.getParsed(index), this._cachedMeta.vScale, mode === 'reset'); | ||
get(getPrototypeOf(HorizontalBarWithErrorBarsController.prototype), "updateElement", this).call(this, element, index, properties, mode); | ||
} | ||
}]); | ||
return HorizontalBarWithErrorBarsController; | ||
}(HorizontalBarController); | ||
HorizontalBarWithErrorBarsController.prototype.dataElementOptions = HorizontalBarController.prototype.dataElementOptions.concat(styleKeys); | ||
HorizontalBarWithErrorBarsController.id = 'horizontalBarWithErrorBars'; | ||
HorizontalBarWithErrorBarsController.register = function () { | ||
HorizontalBarWithErrorBarsController.prototype.dataElementType = RectangleWithErrorBar.register(); | ||
HorizontalBarWithErrorBarsController.defaults = merge({}, [defaults.horizontalBar, horizontalTooltipDefaults, animationHints]); | ||
return registerController(HorizontalBarWithErrorBarsController); | ||
}; | ||
var HorizontalBarWithErrorBarsChart = /*#__PURE__*/function (_Chart2) { | ||
inherits(HorizontalBarWithErrorBarsChart, _Chart2); | ||
var _super4 = _createSuper$3(HorizontalBarWithErrorBarsChart); | ||
function HorizontalBarWithErrorBarsChart(item, config) { | ||
classCallCheck(this, HorizontalBarWithErrorBarsChart); | ||
return _super4.call(this, item, patchControllerConfig(config, HorizontalBarWithErrorBarsController)); | ||
} | ||
return HorizontalBarWithErrorBarsChart; | ||
}(Chart); | ||
HorizontalBarWithErrorBarsChart.id = HorizontalBarWithErrorBarsController.id; | ||
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; } } | ||
@@ -1049,12 +927,13 @@ var LineWithErrorBarsController = /*#__PURE__*/function (_LineController) { | ||
return LineWithErrorBarsController; | ||
}(LineController); | ||
LineWithErrorBarsController.prototype.dataElementOptions = Object.assign({}, LineController.prototype.dataElementOptions, styleObjectKeys); | ||
}(chartjsEsmFacade.LineController); | ||
LineWithErrorBarsController.id = 'lineWithErrorBars'; | ||
LineWithErrorBarsController.register = function () { | ||
LineWithErrorBarsController.prototype.dataElementType = PointWithErrorBar.register(); | ||
LineWithErrorBarsController.defaults = merge({}, [defaults.line, verticalTooltipDefaults, animationHints]); | ||
return registerController(LineWithErrorBarsController); | ||
}; | ||
LineWithErrorBarsController.defaults = /*#__PURE__*/chartjsEsmFacade.merge({}, [chartjsEsmFacade.LineController.defaults, animationHints, { | ||
tooltips: { | ||
callbacks: { | ||
label: generateBarTooltip | ||
} | ||
}, | ||
dataElementType: PointWithErrorBar.id, | ||
dataElementOptions: Object.assign({}, chartjsEsmFacade.LineController.defaults.dataElementOptions, styleObjectKeys) | ||
}]); | ||
var LineWithErrorBarsChart = /*#__PURE__*/function (_Chart) { | ||
@@ -1068,19 +947,12 @@ inherits(LineWithErrorBarsChart, _Chart); | ||
return _super2.call(this, item, patchControllerConfig(config, LineWithErrorBarsController)); | ||
return _super2.call(this, item, patchController(config, LineWithErrorBarsController, PointWithErrorBar, chartjsEsmFacade.LinearScale)); | ||
} | ||
return LineWithErrorBarsChart; | ||
}(Chart); | ||
}(chartjsEsmFacade.Chart); | ||
LineWithErrorBarsChart.id = LineWithErrorBarsController.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 _createSuper$5(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$5(); return function _createSuperInternal() { 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 tooltipDefaults = { | ||
tooltips: { | ||
callbacks: { | ||
label: generateTooltipScatter | ||
} | ||
} | ||
}; | ||
var ScatterWithErrorBarsController = /*#__PURE__*/function (_ScatterController) { | ||
@@ -1129,12 +1001,13 @@ inherits(ScatterWithErrorBarsController, _ScatterController); | ||
return ScatterWithErrorBarsController; | ||
}(ScatterController); | ||
ScatterWithErrorBarsController.prototype.dataElementOptions = Object.assign({}, ScatterController.prototype.dataElementOptions, styleObjectKeys); | ||
}(chartjsEsmFacade.ScatterController); | ||
ScatterWithErrorBarsController.id = 'scatterWithErrorBars'; | ||
ScatterWithErrorBarsController.register = function () { | ||
ScatterWithErrorBarsController.prototype.dataElementType = PointWithErrorBar.register(); | ||
ScatterWithErrorBarsController.defaults = merge({}, [defaults.scatter, tooltipDefaults, animationHints]); | ||
return registerController(ScatterWithErrorBarsController); | ||
}; | ||
ScatterWithErrorBarsController.defaults = /*#__PURE__*/chartjsEsmFacade.merge({}, [chartjsEsmFacade.ScatterController.defaults, animationHints, { | ||
tooltips: { | ||
callbacks: { | ||
label: generateTooltipScatter | ||
} | ||
}, | ||
dataElementType: PointWithErrorBar.id, | ||
dataElementOptions: Object.assign({}, chartjsEsmFacade.LineController.defaults.dataElementOptions, styleObjectKeys) | ||
}]); | ||
var ScatterWithErrorBarsChart = /*#__PURE__*/function (_Chart) { | ||
@@ -1148,19 +1021,29 @@ inherits(ScatterWithErrorBarsChart, _Chart); | ||
return _super2.call(this, item, patchControllerConfig(config, ScatterWithErrorBarsController)); | ||
return _super2.call(this, item, patchController(config, ScatterWithErrorBarsController, PointWithErrorBar, chartjsEsmFacade.LinearScale)); | ||
} | ||
return ScatterWithErrorBarsChart; | ||
}(Chart); | ||
}(chartjsEsmFacade.Chart); | ||
ScatterWithErrorBarsChart.id = ScatterWithErrorBarsController.id; | ||
function _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$6(); 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 _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 _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$6(); return function _createSuperInternal() { 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$6() { 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 tooltipDefaults$1 = { | ||
tooltips: { | ||
callbacks: { | ||
label: generateTooltipPolar | ||
} | ||
} | ||
}; | ||
var PolarAreaWithErrorBarsController = /*#__PURE__*/function (_PolarAreaController) { | ||
@@ -1213,3 +1096,3 @@ inherits(PolarAreaWithErrorBarsController, _PolarAreaController); | ||
return resolve([this.chart.options.elements.arc.angle, 2 * Math.PI / count], context, index); | ||
return chartjsEsmFacade.resolve([this.chart.options.elements.arc.angle, 2 * Math.PI / count], context, index); | ||
} | ||
@@ -1220,2 +1103,3 @@ }, { | ||
var parsed = new Array(count); | ||
var scale = meta.rScale; | ||
@@ -1225,4 +1109,4 @@ for (var i = 0; i < count; ++i) { | ||
var item = data[index]; | ||
var v = meta.rScale.parseObject(item, 'r', index); | ||
parsed[i] = defineProperty({}, meta.rScale.axis, v); | ||
var v = scale.parse(item[scale.axis], index); | ||
parsed[i] = defineProperty({}, scale.axis, v); | ||
} | ||
@@ -1261,12 +1145,13 @@ | ||
return PolarAreaWithErrorBarsController; | ||
}(PolarAreaController); | ||
PolarAreaWithErrorBarsController.prototype.dataElementOptions = Object.assign({}, PolarAreaController.prototype.dataElementOptions, styleObjectKeys); | ||
}(chartjsEsmFacade.PolarAreaController); | ||
PolarAreaWithErrorBarsController.id = 'polarAreaWithErrorBars'; | ||
PolarAreaWithErrorBarsController.register = function () { | ||
PolarAreaWithErrorBarsController.prototype.dataElementType = ArcWithErrorBar.register(); | ||
PolarAreaWithErrorBarsController.defaults = merge({}, [defaults.polarArea, tooltipDefaults$1, animationHints]); | ||
return registerController(PolarAreaWithErrorBarsController); | ||
}; | ||
PolarAreaWithErrorBarsController.defaults = /*#__PURE__*/chartjsEsmFacade.merge({}, [chartjsEsmFacade.PolarAreaController.defaults, animationHints, { | ||
tooltips: { | ||
callbacks: { | ||
label: generateTooltipPolar | ||
} | ||
}, | ||
dataElementType: ArcWithErrorBar.id, | ||
dataElementOptions: chartjsEsmFacade.PolarAreaController.defaults.dataElementOptions.concat(styleKeys) | ||
}]); | ||
var PolarAreaWithErrorBarsChart = /*#__PURE__*/function (_Chart) { | ||
@@ -1280,14 +1165,11 @@ inherits(PolarAreaWithErrorBarsChart, _Chart); | ||
return _super2.call(this, item, patchControllerConfig(config, PolarAreaWithErrorBarsController)); | ||
return _super2.call(this, item, patchController(config, PolarAreaWithErrorBarsController, ArcWithErrorBar, chartjsEsmFacade.RadialLinearScale)); | ||
} | ||
return PolarAreaWithErrorBarsChart; | ||
}(Chart); | ||
}(chartjsEsmFacade.Chart); | ||
PolarAreaWithErrorBarsChart.id = PolarAreaWithErrorBarsController.id; | ||
BarWithErrorBarsController.register(); | ||
HorizontalBarWithErrorBarsController.register(); | ||
LineWithErrorBarsController.register(); | ||
PolarAreaWithErrorBarsController.register(); | ||
ScatterWithErrorBarsController.register(); | ||
chartjsEsmFacade.registry.addControllers(BarWithErrorBarsController, LineWithErrorBarsController, PolarAreaWithErrorBarsController, ScatterWithErrorBarsController); | ||
chartjsEsmFacade.registry.addElements(RectangleWithErrorBar, ArcWithErrorBar, LineWithErrorBarsController, PointWithErrorBar); | ||
@@ -1297,4 +1179,2 @@ exports.ArcWithErrorBar = ArcWithErrorBar; | ||
exports.BarWithErrorBarsController = BarWithErrorBarsController; | ||
exports.HorizontalBarWithErrorBarsChart = HorizontalBarWithErrorBarsChart; | ||
exports.HorizontalBarWithErrorBarsController = HorizontalBarWithErrorBarsController; | ||
exports.LineWithErrorBarsChart = LineWithErrorBarsChart; | ||
@@ -1301,0 +1181,0 @@ exports.LineWithErrorBarsController = LineWithErrorBarsController; |
@@ -1,1 +0,1 @@ | ||
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("chart.js")):"function"==typeof define&&define.amd?define(["exports","chart.js"],r):r((t=t||self).ChartErrorBars={},t.Chart)}(this,function(t,r){"use strict";r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r;var e=function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")};function n(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var a=function(t,r,e){return r&&n(t.prototype,r),e&&n(t,e),t};function o(t,r){return t(r={exports:{}},r.exports),r.exports}var i=o(function(t){function r(e){return t.exports=r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},r(e)}t.exports=r});var c=function(t,r){for(;!Object.prototype.hasOwnProperty.call(t,r)&&null!==(t=i(t)););return t},u=o(function(t){function r(e,n,a){return"undefined"!=typeof Reflect&&Reflect.get?t.exports=r=Reflect.get:t.exports=r=function(t,r,e){var n=c(t,r);if(n){var a=Object.getOwnPropertyDescriptor(n,r);return a.get?a.get.call(e):a.value}},r(e,n,a||e)}t.exports=r}),l=o(function(t){function r(e,n){return t.exports=r=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t},r(e,n)}t.exports=r});var s=function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),r&&l(t,r)},f=o(function(t){function r(e){"@babel/helpers - typeof";return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=r=function(t){return typeof t}:t.exports=r=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(e)}t.exports=r});var p=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t};var h=function(t,r){return!r||"object"!==f(r)&&"function"!=typeof r?p(t):r};var y=function(t,r,e){return r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t},v=r,d=r.defaults,m=r.controllers.bar,g=r.controllers.horizontalBar,b=r.controllers.line,x=r.controllers.polarArea,M=r.controllers.scatter;function E(t){return r.controllers[t.id]=t,r.defaults.set(t.id,t.defaults),t}var k=r.elements.Rectangle,S=r.elements.Point,B=r.elements.Arc;function O(t){return r.defaults.set("elements",y({},t.id,t.defaults)),t}var W=r.helpers.merge,A=r.helpers.options.resolve,R=r.helpers.color;function P(t,r){return r.register(),t.type=r.id,t}var j=function(t){if(Array.isArray(t))return t};var D=function(t,r){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var e=[],n=!0,a=!1,o=void 0;try{for(var i,c=t[Symbol.iterator]();!(n=(i=c.next()).done)&&(e.push(i.value),!r||e.length!==r);n=!0);}catch(t){a=!0,o=t}finally{try{n||null==c.return||c.return()}finally{if(a)throw o}}return e}};var C=function(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n};var w=function(t,r){if(t){if("string"==typeof t)return C(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?C(t,r):void 0}};var T=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")};var _=function(t,r){return j(t)||D(t,r)||w(t,r)||T()},L=["xMin","xMax","yMin","yMax"];function F(t){return t?L.slice(0,2):L.slice(2)}function I(t,r,e,n){for(var a=["".concat(e.axis,"Min"),"".concat(e.axis,"Max")],o=e.getBasePixel(),i=0,c=a;i<c.length;i++){var u=c[i],l=r[u];Array.isArray(l)?t[u]=l.map(function(t){return n?o:e.getPixelForValue(t)}):"number"==typeof l&&(t[u]=n?o:e.getPixelForValue(l))}}var V={errorBarLineWidth:{v:[1,3]},errorBarColor:{v:["#2c2c2c","#1f1f1f"]},errorBarWhiskerLineWidth:{v:[1,3]},errorBarWhiskerRatio:{v:[.2,.25]},errorBarWhiskerSize:{v:[20,24]},errorBarWhiskerColor:{v:["#2c2c2c","#1f1f1f"]}},z=Object.keys(V),N={};function q(t,r){var e=Array.isArray(t)?t:[t],n=Array.isArray(r)?r:[r];if(e.length===n.length)return e.map(function(t,r){return[t,n[r]]});var a=Math.max(e.length,n.length);return Array(a).map(function(t,r){return[e[r%e.length],n[r%n.length]]})}function H(t,r){if("string"==typeof t||"number"==typeof t)return t;var e=Array.isArray(t)?t:t.v;return e[r%e.length]}function U(t,r,e){var n=H(r.errorBarWhiskerRatio,e);return null!=t&&n>0?t*n*.5:.5*H(r.errorBarWhiskerSize,e)}function $(t,r){var e=t.getProps(["x","y","width","height"].concat(L));null==e.xMin&&null==e.xMax||function(t,r,e,n,a){a.save(),a.translate(0,t.y),null==r&&(r=t.x),null==e&&(e=t.x);var o=q(r,e);o.reverse().forEach(function(r,e){var i=_(r,2),c=i[0],u=i[1],l=o.length-e-1,s=U(t.height,n,l);a.lineWidth=H(n.errorBarLineWidth,l),a.strokeStyle=H(n.errorBarColor,l),a.beginPath(),a.moveTo(c,0),a.lineTo(u,0),a.stroke(),a.lineWidth=H(n.errorBarWhiskerLineWidth,l),a.strokeStyle=H(n.errorBarWhiskerColor,l),a.beginPath(),a.moveTo(c,-s),a.lineTo(c,s),a.moveTo(u,-s),a.lineTo(u,s),a.stroke()}),a.restore()}(e,e.xMin,e.xMax,t.options,r),null==e.yMin&&null==e.yMax||function(t,r,e,n,a){a.save(),a.translate(t.x,0),null==r&&(r=t.y),null==e&&(e=t.y);var o=q(r,e);o.reverse().forEach(function(r,e){var i=_(r,2),c=i[0],u=i[1],l=o.length-e-1,s=U(t.width,n,l);a.lineWidth=H(n.errorBarLineWidth,l),a.strokeStyle=H(n.errorBarColor,l),a.beginPath(),a.moveTo(0,c),a.lineTo(0,u),a.stroke(),a.lineWidth=H(n.errorBarWhiskerLineWidth,l),a.strokeStyle=H(n.errorBarWhiskerColor,l),a.beginPath(),a.moveTo(-s,c),a.lineTo(s,c),a.moveTo(-s,u),a.lineTo(s,u),a.stroke()}),a.restore()}(e,e.yMin,e.yMax,t.options,r)}function G(t,r){var e=t.getProps(["x","y","startAngle","endAngle","rMin","rMax","outerRadius"]);null==e.rMin&&null==e.rMax||function(t,r,e,n,a){a.save(),a.translate(t.x,t.y),null==r&&(r=t.outerRadius),null==e&&(e=t.outerRadius);var o=(t.startAngle+t.endAngle)/2,i=Math.cos(o),c=Math.sin(o),u={x:-c,y:i},l=Math.sqrt(u.x*u.x+u.y*u.y);u.x/=l,u.y/=l;var s=q(r,e);s.reverse().forEach(function(t,r){var e=_(t,2),o=e[0],l=e[1],f=s.length-r-1,p=o*i,h=o*c,y=l*i,v=l*c,d=U(null,n,f),m=u.x*d,g=u.y*d;a.lineWidth=H(n.errorBarLineWidth,f),a.strokeStyle=H(n.errorBarColor,f),a.beginPath(),a.moveTo(p,h),a.lineTo(y,v),a.stroke(),a.lineWidth=H(n.errorBarWhiskerLineWidth,f),a.strokeStyle=H(n.errorBarWhiskerColor,f),a.beginPath(),a.moveTo(p+m,h+g),a.lineTo(p-m,h-g),a.moveTo(y+m,v+g),a.lineTo(y-m,v-g),a.stroke()}),a.restore()}(e,e.rMin,e.rMax,t.options,r)}function J(t){var r=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 e,n=i(t);if(r){var a=i(this).constructor;e=Reflect.construct(n,arguments,a)}else e=n.apply(this,arguments);return h(this,e)}}z.forEach(function(t){return N[t]=t});var K=function(t){s(n,k);var r=J(n);function n(){return e(this,n),r.apply(this,arguments)}return a(n,[{key:"draw",value:function(t){u(i(n.prototype),"draw",this).call(this,t),$(this,t)}}]),n}();function Q(t){var r=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 e,n=i(t);if(r){var a=i(this).constructor;e=Reflect.construct(n,arguments,a)}else e=n.apply(this,arguments);return h(this,e)}}K.id=K._type="rectangleWithErrorBar",K.defaults=Object.assign({},d.elements.rectangle,V),K.register=function(){return O(K)};var X=function(t){s(n,S);var r=Q(n);function n(){return e(this,n),r.apply(this,arguments)}return a(n,[{key:"draw",value:function(t){u(i(n.prototype),"draw",this).call(this,t),$(this,t)}}]),n}();function Y(t){var r=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 e,n=i(t);if(r){var a=i(this).constructor;e=Reflect.construct(n,arguments,a)}else e=n.apply(this,arguments);return h(this,e)}}X.id=X._type="pointWithErrorBar",X.defaults=Object.assign({},d.elements.point,V),X.register=function(){return O(X)};var Z=function(t){s(n,B);var r=Y(n);function n(){return e(this,n),r.apply(this,arguments)}return a(n,[{key:"draw",value:function(t){u(i(n.prototype),"draw",this).call(this,t),G(this,t)}}]),n}();function tt(t){return Array.isArray(t)?t.slice().reverse():t}function rt(t){var r=this,e=F(t);return function(t,n){var a=d.tooltips.callbacks.label.call(r,t,n),o=n.datasets[t.datasetIndex].data[t.index];return null==o||e.every(function(t){return null==o[t]})?a:"".concat(a," (").concat(tt(o[e[0]])," .. ").concat(o[e[1]],")")}}Z.id=Z._type="arcWithErrorBar",Z.defaults=Object.assign({},d.elements.arc,V),Z.register=function(){return O(Z)};var et={tooltips:{callbacks:{label:rt(!1)}}},nt={tooltips:{callbacks:{label:rt(!0)}}};var at={color:function(t,r,e){var n=t||transparent,a=r||transparent;if(n===a)return r;var o=R(n),i=o.valid&&R(a);return i&&i.valid?i.mix(o,e).hexString():r},number:function(t,r,e){return t===r?r:t+(r-t)*e}};function ot(t,r,e,n,a){return f(t)===n&&f(r)===n?a(t,r,e):Array.isArray(t)&&Array.isArray(r)?t.map(function(t,n){return a(t,r[n],e)}):t&&Array.isArray(t.v)&&r&&Array.isArray(r.v)?t.v.map(function(t,n){return a(t,r.v[n],e)}):r}var it={datasets:{animation:{numberArray:{fn:function(t,r,e){return ot(t,r,e,"number",at.number)},properties:L.concat(z.filter(function(t){return!t.endsWith("Color")}),["rMin","rMax"])},colorArray:{fn:function(t,r,e){return ot(t,r,e,"string",at.color)},properties:L.concat(z.filter(function(t){return t.endsWith("Color")}))}}}};var ct=function(t){if(Array.isArray(t))return C(t)};var ut=function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)};var lt=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")};var st=function(t){return ct(t)||ut(t)||w(t)||lt()};function ft(t,r,e){var n=t.axis;t.axis="".concat(n,"MinMin");var a=e(t,r).min;t.axis="".concat(n,"MaxMax");var o=e(t,r).max;return t.axis=n,{min:a,max:o}}function pt(t,r,e){return Array.isArray(r)?e.apply(void 0,st(r)):"number"==typeof r?r:t}function ht(t,r,e,n,a){for(var o="string"==typeof r?r:r.axis,i="".concat(o,"Min"),c="".concat(o,"Max"),u="".concat(o,"MinMin"),l="".concat(o,"MaxMax"),s=0;s<a;s++){var f=s+n,p=t[s];p[i]=e[f][i],p[c]=e[f][c],p[u]=pt(p[o],p[i],Math.min),p[l]=pt(p[o],p[c],Math.max)}}function yt(t,r,e,n){for(var a=r.axis,o=r.getLabels(),i=0;i<n;i++){var c=i+e;t[i][a]=r.parse(o[c],c)}}function vt(t){var r=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 e,n=i(t);if(r){var a=i(this).constructor;e=Reflect.construct(n,arguments,a)}else e=n.apply(this,arguments);return h(this,e)}}var dt=function(t){s(n,m);var r=vt(n);function n(){return e(this,n),r.apply(this,arguments)}return a(n,[{key:"getMinMax",value:function(t,r){var e=this;return ft(t,r,function(t,r){return u(i(n.prototype),"getMinMax",e).call(e,t,r)})}},{key:"parseObjectData",value:function(t,r,e,a){var o=u(i(n.prototype),"parseObjectData",this).call(this,t,r,e,a);return ht(o,t.vScale,r,e,a),yt(o,t.iScale,e,a),o}},{key:"updateElement",value:function(t,r,e,a){I(e,this.getParsed(r),this._cachedMeta.vScale,"reset"===a),u(i(n.prototype),"updateElement",this).call(this,t,r,e,a)}}]),n}();dt.prototype.dataElementOptions=m.prototype.dataElementOptions.concat(z),dt.id="barWithErrorBars",dt.register=function(){return dt.prototype.dataElementType=K.register(),dt.defaults=W({},[d.bar,et,it]),E(dt)};var mt=function(t){s(n,v);var r=vt(n);function n(t,a){return e(this,n),r.call(this,t,P(a,dt))}return n}();mt.id=dt.id;var gt=function(t){s(n,g);var r=vt(n);function n(){return e(this,n),r.apply(this,arguments)}return a(n,[{key:"getMinMax",value:function(t,r){var e=this;return ft(t,r,function(t,r){return u(i(n.prototype),"getMinMax",e).call(e,t,r)})}},{key:"parseObjectData",value:function(t,r,e,a){var o=u(i(n.prototype),"parseObjectData",this).call(this,t,r,e,a);return ht(o,t.vScale,r,e,a),yt(o,t.iScale,e,a),o}},{key:"updateElement",value:function(t,r,e,a){I(e,this.getParsed(r),this._cachedMeta.vScale,"reset"===a),u(i(n.prototype),"updateElement",this).call(this,t,r,e,a)}}]),n}();gt.prototype.dataElementOptions=g.prototype.dataElementOptions.concat(z),gt.id="horizontalBarWithErrorBars",gt.register=function(){return gt.prototype.dataElementType=K.register(),gt.defaults=W({},[d.horizontalBar,nt,it]),E(gt)};var bt=function(t){s(n,v);var r=vt(n);function n(t,a){return e(this,n),r.call(this,t,P(a,gt))}return n}();function xt(t){var r=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 e,n=i(t);if(r){var a=i(this).constructor;e=Reflect.construct(n,arguments,a)}else e=n.apply(this,arguments);return h(this,e)}}bt.id=gt.id;var Mt=function(t){s(n,b);var r=xt(n);function n(){return e(this,n),r.apply(this,arguments)}return a(n,[{key:"getMinMax",value:function(t,r){var e=this;return ft(t,r,function(t,r){return u(i(n.prototype),"getMinMax",e).call(e,t,r)})}},{key:"parseObjectData",value:function(t,r,e,a){var o=u(i(n.prototype),"parseObjectData",this).call(this,t,r,e,a);return ht(o,t.vScale,r,e,a),yt(o,t.iScale,e,a),o}},{key:"updateElement",value:function(t,r,e,a){t instanceof X&&I(e,this.getParsed(r),this._cachedMeta.vScale,"reset"===a),u(i(n.prototype),"updateElement",this).call(this,t,r,e,a)}}]),n}();Mt.prototype.dataElementOptions=Object.assign({},b.prototype.dataElementOptions,N),Mt.id="lineWithErrorBars",Mt.register=function(){return Mt.prototype.dataElementType=X.register(),Mt.defaults=W({},[d.line,et,it]),E(Mt)};var Et=function(t){s(n,v);var r=xt(n);function n(t,a){return e(this,n),r.call(this,t,P(a,Mt))}return n}();function kt(t){var r=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 e,n=i(t);if(r){var a=i(this).constructor;e=Reflect.construct(n,arguments,a)}else e=n.apply(this,arguments);return h(this,e)}}Et.id=Mt.id;var St={tooltips:{callbacks:{label:function(t,r){var e=r.datasets[t.datasetIndex].data[t.index],n=function(t,r){var n=F(r);return null==e||n.every(function(t){return null==e[t]})?t:"".concat(t," [").concat(tt(e[n[0]])," .. ").concat(e[n[1]],"]")};return"(".concat(n(t.label,!0),", ").concat(n(t.value,!1),")")}}}},Bt=function(t){s(n,M);var r=kt(n);function n(){return e(this,n),r.apply(this,arguments)}return a(n,[{key:"getMinMax",value:function(t,r){var e=this;return ft(t,r,function(t,r){return u(i(n.prototype),"getMinMax",e).call(e,t,r)})}},{key:"parseObjectData",value:function(t,r,e,a){var o=u(i(n.prototype),"parseObjectData",this).call(this,t,r,e,a);return ht(o,t.xScale,r,e,a),ht(o,t.yScale,r,e,a),o}},{key:"updateElement",value:function(t,r,e,a){t instanceof X&&(I(e,this.getParsed(r),this._cachedMeta.xScale,"reset"===a),I(e,this.getParsed(r),this._cachedMeta.yScale,"reset"===a)),u(i(n.prototype),"updateElement",this).call(this,t,r,e,a)}}]),n}();Bt.prototype.dataElementOptions=Object.assign({},M.prototype.dataElementOptions,N),Bt.id="scatterWithErrorBars",Bt.register=function(){return Bt.prototype.dataElementType=X.register(),Bt.defaults=W({},[d.scatter,St,it]),E(Bt)};var Ot=function(t){s(n,v);var r=kt(n);function n(t,a){return e(this,n),r.call(this,t,P(a,Bt))}return n}();function Wt(t){var r=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 e,n=i(t);if(r){var a=i(this).constructor;e=Reflect.construct(n,arguments,a)}else e=n.apply(this,arguments);return h(this,e)}}Ot.id=Bt.id;var At={tooltips:{callbacks:{label:function(t,r){var e=d.polarArea.tooltips.callbacks.label.call(this,t,r),n=r.datasets[t.datasetIndex].data[t.index],a=["rMin","rMax"];return null==n||a.every(function(t){return null==n[t]})?e:"".concat(e," [").concat(tt(n[a[0]])," .. ").concat(n[a[1]],"]")}}}},Rt=function(t){s(n,x);var r=Wt(n);function n(){return e(this,n),r.apply(this,arguments)}return a(n,[{key:"getMinMax",value:function(t,r){var e=this;return ft(t,r,function(t,r){return u(i(n.prototype),"getMinMax",e).call(e,t,r)})}},{key:"countVisibleElements",value:function(){var t=this,r=this._cachedMeta;return r.data.reduce(function(e,n,a){return!Number.isNaN(r._parsed[a].r)&&t.chart.getDataVisibility(a)?e+1:e},0)}},{key:"_computeAngle",value:function(t){var r=this._cachedMeta,e=r.count;if(Number.isNaN(r._parsed[t].r)||!this.chart.getDataVisibility(t))return 0;var n=this._getContext(t,!0);return A([this.chart.options.elements.arc.angle,2*Math.PI/e],n,t)}},{key:"parseObjectData",value:function(t,r,e,n){for(var a=new Array(n),o=0;o<n;++o){var i=o+e,c=r[i],u=t.rScale.parseObject(c,"r",i);a[o]=y({},t.rScale.axis,u)}return ht(a,t.rScale,r,e,n),a}},{key:"updateElement",value:function(t,r,e,a){!function(t,r,e,n,a,o){for(var i=o.animation,c=function(t){var r=n.getDistanceFromCenterForValue(t),e=i.animateScale?0:r;return a?e:r},u=0,l=["".concat(n.axis,"Min"),"".concat(n.axis,"Max")];u<l.length;u++){var s=l[u],f=e[s];Array.isArray(f)?r[s]=f.map(c):"number"==typeof f&&(r[s]=c(f))}}(0,e,this.getParsed(r),this._cachedMeta.rScale,"reset"===a,this.chart.options),u(i(n.prototype),"updateElement",this).call(this,t,r,e,a)}},{key:"updateElements",value:function(t,r,e){var a=this.chart.scales.r,o=a.getDistanceFromCenterForValue;a.getDistanceFromCenterForValue=function(t){return"number"==typeof t?o.call(this,t):o.call(this,t.r)},u(i(n.prototype),"updateElements",this).call(this,t,r,e),a.getDistanceFromCenterForValue=o}}]),n}();Rt.prototype.dataElementOptions=Object.assign({},x.prototype.dataElementOptions,N),Rt.id="polarAreaWithErrorBars",Rt.register=function(){return Rt.prototype.dataElementType=Z.register(),Rt.defaults=W({},[d.polarArea,At,it]),E(Rt)};var Pt=function(t){s(n,v);var r=Wt(n);function n(t,a){return e(this,n),r.call(this,t,P(a,Rt))}return n}();Pt.id=Rt.id,dt.register(),gt.register(),Mt.register(),Rt.register(),Bt.register(),t.ArcWithErrorBar=Z,t.BarWithErrorBarsChart=mt,t.BarWithErrorBarsController=dt,t.HorizontalBarWithErrorBarsChart=bt,t.HorizontalBarWithErrorBarsController=gt,t.LineWithErrorBarsChart=Et,t.LineWithErrorBarsController=Mt,t.PointWithErrorBar=X,t.PolarAreaWithErrorBarsChart=Pt,t.PolarAreaWithErrorBarsController=Rt,t.RectangleWithErrorBar=K,t.ScatterWithErrorBarsChart=Ot,t.ScatterWithErrorBarsController=Bt,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@sgratzl/chartjs-esm-facade")):"function"==typeof define&&define.amd?define(["exports","@sgratzl/chartjs-esm-facade"],r):r((t=t||self).ChartErrorBars={},t.ChartESMFacade)}(this,function(t,r){"use strict";var e=function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")};function n(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var a=function(t,r,e){return r&&n(t.prototype,r),e&&n(t,e),t};function o(t,r,e){return t(e={path:r,exports:{},require:function(t,r){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==r&&e.path)}},e.exports),e.exports}var i=o(function(t){function r(e){return t.exports=r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},r(e)}t.exports=r});var c=function(t,r){for(;!Object.prototype.hasOwnProperty.call(t,r)&&null!==(t=i(t)););return t},u=o(function(t){function r(e,n,a){return"undefined"!=typeof Reflect&&Reflect.get?t.exports=r=Reflect.get:t.exports=r=function(t,r,e){var n=c(t,r);if(n){var a=Object.getOwnPropertyDescriptor(n,r);return a.get?a.get.call(e):a.value}},r(e,n,a||e)}t.exports=r}),l=o(function(t){function r(e,n){return t.exports=r=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t},r(e,n)}t.exports=r});var s=function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),r&&l(t,r)},f=o(function(t){function r(e){"@babel/helpers - typeof";return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=r=function(t){return typeof t}:t.exports=r=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(e)}t.exports=r});var h=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t};var p=function(t,r){return!r||"object"!==f(r)&&"function"!=typeof r?h(t):r};var y=function(t){if(Array.isArray(t))return t};var d=function(t,r){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var e=[],n=!0,a=!1,o=void 0;try{for(var i,c=t[Symbol.iterator]();!(n=(i=c.next()).done)&&(e.push(i.value),!r||e.length!==r);n=!0);}catch(t){a=!0,o=t}finally{try{n||null==c.return||c.return()}finally{if(a)throw o}}return e}};var v=function(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n};var m=function(t,r){if(t){if("string"==typeof t)return v(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?v(t,r):void 0}};var g=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")};var b=function(t,r){return y(t)||d(t,r)||m(t,r)||g()},x=["xMin","xMax","yMin","yMax"];function M(t){return t?x.slice(0,2):x.slice(2)}function S(t,r,e,n){for(var a=["".concat(e.axis,"Min"),"".concat(e.axis,"Max")],o=e.getBasePixel(),i=0,c=a;i<c.length;i++){var u=c[i],l=r[u];Array.isArray(l)?t[u]=l.map(function(t){return n?o:e.getPixelForValue(t)}):"number"==typeof l&&(t[u]=n?o:e.getPixelForValue(l))}}var E={errorBarLineWidth:{v:[1,3]},errorBarColor:{v:["#2c2c2c","#1f1f1f"]},errorBarWhiskerLineWidth:{v:[1,3]},errorBarWhiskerRatio:{v:[.2,.25]},errorBarWhiskerSize:{v:[20,24]},errorBarWhiskerColor:{v:["#2c2c2c","#1f1f1f"]}},R=Object.keys(E),A={};function k(t,r){var e=Array.isArray(t)?t:[t],n=Array.isArray(r)?r:[r];if(e.length===n.length)return e.map(function(t,r){return[t,n[r]]});var a=Math.max(e.length,n.length);return Array(a).map(function(t,r){return[e[r%e.length],n[r%n.length]]})}function C(t,r){if("string"==typeof t||"number"==typeof t)return t;var e=Array.isArray(t)?t:t.v;return e[r%e.length]}function W(t,r,e){var n=C(r.errorBarWhiskerRatio,e);return null!=t&&n>0?t*n*.5:.5*C(r.errorBarWhiskerSize,e)}function B(t,r){var e=t.getProps(["x","y","width","height"].concat(x));null==e.xMin&&null==e.xMax||function(t,r,e,n,a){a.save(),a.translate(0,t.y),null==r&&(r=t.x),null==e&&(e=t.x);var o=k(r,e);o.reverse().forEach(function(r,e){var i=b(r,2),c=i[0],u=i[1],l=o.length-e-1,s=W(t.height,n,l);a.lineWidth=C(n.errorBarLineWidth,l),a.strokeStyle=C(n.errorBarColor,l),a.beginPath(),a.moveTo(c,0),a.lineTo(u,0),a.stroke(),a.lineWidth=C(n.errorBarWhiskerLineWidth,l),a.strokeStyle=C(n.errorBarWhiskerColor,l),a.beginPath(),a.moveTo(c,-s),a.lineTo(c,s),a.moveTo(u,-s),a.lineTo(u,s),a.stroke()}),a.restore()}(e,e.xMin,e.xMax,t.options,r),null==e.yMin&&null==e.yMax||function(t,r,e,n,a){a.save(),a.translate(t.x,0),null==r&&(r=t.y),null==e&&(e=t.y);var o=k(r,e);o.reverse().forEach(function(r,e){var i=b(r,2),c=i[0],u=i[1],l=o.length-e-1,s=W(t.width,n,l);a.lineWidth=C(n.errorBarLineWidth,l),a.strokeStyle=C(n.errorBarColor,l),a.beginPath(),a.moveTo(0,c),a.lineTo(0,u),a.stroke(),a.lineWidth=C(n.errorBarWhiskerLineWidth,l),a.strokeStyle=C(n.errorBarWhiskerColor,l),a.beginPath(),a.moveTo(-s,c),a.lineTo(s,c),a.moveTo(-s,u),a.lineTo(s,u),a.stroke()}),a.restore()}(e,e.yMin,e.yMax,t.options,r)}function P(t,r){var e=t.getProps(["x","y","startAngle","endAngle","rMin","rMax","outerRadius"]);null==e.rMin&&null==e.rMax||function(t,r,e,n,a){a.save(),a.translate(t.x,t.y),null==r&&(r=t.outerRadius),null==e&&(e=t.outerRadius);var o=(t.startAngle+t.endAngle)/2,i=Math.cos(o),c=Math.sin(o),u={x:-c,y:i},l=Math.sqrt(u.x*u.x+u.y*u.y);u.x/=l,u.y/=l;var s=k(r,e);s.reverse().forEach(function(t,r){var e=b(t,2),o=e[0],l=e[1],f=s.length-r-1,h=o*i,p=o*c,y=l*i,d=l*c,v=W(null,n,f),m=u.x*v,g=u.y*v;a.lineWidth=C(n.errorBarLineWidth,f),a.strokeStyle=C(n.errorBarColor,f),a.beginPath(),a.moveTo(h,p),a.lineTo(y,d),a.stroke(),a.lineWidth=C(n.errorBarWhiskerLineWidth,f),a.strokeStyle=C(n.errorBarWhiskerColor,f),a.beginPath(),a.moveTo(h+m,p+g),a.lineTo(h-m,p-g),a.moveTo(y+m,d+g),a.lineTo(y-m,d-g),a.stroke()}),a.restore()}(e,e.rMin,e.rMax,t.options,r)}function O(t){var r=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 e,n=i(t);if(r){var a=i(this).constructor;e=Reflect.construct(n,arguments,a)}else e=n.apply(this,arguments);return p(this,e)}}R.forEach(function(t){return A[t]=t});var j=function(t){s(n,t);var r=O(n);function n(){return e(this,n),r.apply(this,arguments)}return a(n,[{key:"draw",value:function(t){u(i(n.prototype),"draw",this).call(this,t),B(this,t)}}]),n}(r.Rectangle);function D(t){var r=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 e,n=i(t);if(r){var a=i(this).constructor;e=Reflect.construct(n,arguments,a)}else e=n.apply(this,arguments);return p(this,e)}}j.id="rectangleWithErrorBar",j.defaults=Object.assign({},r.Rectangle.defaults,E),j.defaultRoutes=r.Rectangle.defaultRoutes;var w=function(t){s(n,t);var r=D(n);function n(){return e(this,n),r.apply(this,arguments)}return a(n,[{key:"draw",value:function(t){u(i(n.prototype),"draw",this).call(this,t),B(this,t)}}]),n}(r.Point);function T(t){var r=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 e,n=i(t);if(r){var a=i(this).constructor;e=Reflect.construct(n,arguments,a)}else e=n.apply(this,arguments);return p(this,e)}}w.id="pointWithErrorBar",w.defaults=Object.assign({},r.Point.defaults,E),w.defaultRoutes=r.Point.defaultRoutes;var _=function(t){s(n,t);var r=T(n);function n(){return e(this,n),r.apply(this,arguments)}return a(n,[{key:"draw",value:function(t){u(i(n.prototype),"draw",this).call(this,t),P(this,t)}}]),n}(r.Arc);function L(t){return Array.isArray(t)?t.slice().reverse():t}function I(t){var e=M(t.element.horizontal),n=r.Tooltip.defaults.callbacks.label.call(this,t),a=t.chart.data.datasets[t.datasetIndex].data[t.dataIndex];return null==a||e.every(function(t){return null==a[t]})?n:"".concat(n," (").concat(L(a[e[0]])," .. ").concat(a[e[1]],")")}_.id="arcWithErrorBar",_.defaults=Object.assign({},r.Arc.defaults,E),_.defaultRoutes=r.Arc.defaultRoutes;var F={color:function(t,e,n){var a=t||transparent,o=e||transparent;if(a===o)return e;var i=r.color(a),c=i.valid&&r.color(o);return c&&c.valid?c.mix(i,n).hexString():e},number:function(t,r,e){return t===r?r:t+(r-t)*e}};function V(t,r,e,n,a){return f(t)===n&&f(r)===n?a(t,r,e):Array.isArray(t)&&Array.isArray(r)?t.map(function(t,n){return a(t,r[n],e)}):t&&Array.isArray(t.v)&&r&&Array.isArray(r.v)?t.v.map(function(t,n){return a(t,r.v[n],e)}):r}var N={datasets:{animation:{numberArray:{fn:function(t,r,e){return V(t,r,e,"number",F.number)},properties:x.concat(R.filter(function(t){return!t.endsWith("Color")}),["rMin","rMax"])},colorArray:{fn:function(t,r,e){return V(t,r,e,"string",F.color)},properties:x.concat(R.filter(function(t){return t.endsWith("Color")}))}}}};var z=function(t){if(Array.isArray(t))return v(t)};var q=function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)};var U=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")};var $=function(t){return z(t)||q(t)||m(t)||U()};function G(t,r,e){var n=t.axis;t.axis="".concat(n,"MinMin");var a=e(t,r).min;t.axis="".concat(n,"MaxMax");var o=e(t,r).max;return t.axis=n,{min:a,max:o}}function H(t,r,e){return Array.isArray(r)?e.apply(void 0,$(r)):"number"==typeof r?r:t}function J(t,r,e,n,a){for(var o="string"==typeof r?r:r.axis,i="".concat(o,"Min"),c="".concat(o,"Max"),u="".concat(o,"MinMin"),l="".concat(o,"MaxMax"),s=0;s<a;s++){var f=s+n,h=t[s];h[i]=e[f][i],h[c]=e[f][c],h[u]=H(h[o],h[i],Math.min),h[l]=H(h[o],h[c],Math.max)}}function K(t,r,e,n){for(var a=r.axis,o=r.getLabels(),i=0;i<n;i++){var c=i+e;t[i][a]=r.parse(o[c],c)}}function Q(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];return r.registry.addControllers(e),r.registry.addElements(n),r.registry.addScales(a),t.type=e.id,t}function X(t){var r=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 e,n=i(t);if(r){var a=i(this).constructor;e=Reflect.construct(n,arguments,a)}else e=n.apply(this,arguments);return p(this,e)}}var Y=function(t){s(n,t);var r=X(n);function n(){return e(this,n),r.apply(this,arguments)}return a(n,[{key:"getMinMax",value:function(t,r){var e=this;return G(t,r,function(t,r){return u(i(n.prototype),"getMinMax",e).call(e,t,r)})}},{key:"parseObjectData",value:function(t,r,e,a){var o=u(i(n.prototype),"parseObjectData",this).call(this,t,r,e,a);return J(o,t.vScale,r,e,a),K(o,t.iScale,e,a),o}},{key:"updateElement",value:function(t,r,e,a){S(e,this.getParsed(r),this._cachedMeta.vScale,"reset"===a),u(i(n.prototype),"updateElement",this).call(this,t,r,e,a)}}]),n}(r.BarController);Y.id="barWithErrorBars",Y.defaults=r.merge({},[r.BarController.defaults,N,{tooltips:{callbacks:{label:I}},dataElementOptions:r.BarController.defaults.dataElementOptions.concat(R),dataElementType:j.id}]);var Z=function(t){s(a,t);var n=X(a);function a(t,o){return e(this,a),n.call(this,t,Q(o,Y,j,[r.LinearScale,r.CategoryScale]))}return a}(r.Chart);function tt(t){var r=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 e,n=i(t);if(r){var a=i(this).constructor;e=Reflect.construct(n,arguments,a)}else e=n.apply(this,arguments);return p(this,e)}}Z.id=Y.id;var rt=function(t){s(n,t);var r=tt(n);function n(){return e(this,n),r.apply(this,arguments)}return a(n,[{key:"getMinMax",value:function(t,r){var e=this;return G(t,r,function(t,r){return u(i(n.prototype),"getMinMax",e).call(e,t,r)})}},{key:"parseObjectData",value:function(t,r,e,a){var o=u(i(n.prototype),"parseObjectData",this).call(this,t,r,e,a);return J(o,t.vScale,r,e,a),K(o,t.iScale,e,a),o}},{key:"updateElement",value:function(t,r,e,a){t instanceof w&&S(e,this.getParsed(r),this._cachedMeta.vScale,"reset"===a),u(i(n.prototype),"updateElement",this).call(this,t,r,e,a)}}]),n}(r.LineController);rt.id="lineWithErrorBars",rt.defaults=r.merge({},[r.LineController.defaults,N,{tooltips:{callbacks:{label:I}},dataElementType:w.id,dataElementOptions:Object.assign({},r.LineController.defaults.dataElementOptions,A)}]);var et=function(t){s(a,t);var n=tt(a);function a(t,o){return e(this,a),n.call(this,t,Q(o,rt,w,r.LinearScale))}return a}(r.Chart);function nt(t){var r=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 e,n=i(t);if(r){var a=i(this).constructor;e=Reflect.construct(n,arguments,a)}else e=n.apply(this,arguments);return p(this,e)}}et.id=rt.id;var at=function(t){s(n,t);var r=nt(n);function n(){return e(this,n),r.apply(this,arguments)}return a(n,[{key:"getMinMax",value:function(t,r){var e=this;return G(t,r,function(t,r){return u(i(n.prototype),"getMinMax",e).call(e,t,r)})}},{key:"parseObjectData",value:function(t,r,e,a){var o=u(i(n.prototype),"parseObjectData",this).call(this,t,r,e,a);return J(o,t.xScale,r,e,a),J(o,t.yScale,r,e,a),o}},{key:"updateElement",value:function(t,r,e,a){t instanceof w&&(S(e,this.getParsed(r),this._cachedMeta.xScale,"reset"===a),S(e,this.getParsed(r),this._cachedMeta.yScale,"reset"===a)),u(i(n.prototype),"updateElement",this).call(this,t,r,e,a)}}]),n}(r.ScatterController);at.id="scatterWithErrorBars",at.defaults=r.merge({},[r.ScatterController.defaults,N,{tooltips:{callbacks:{label:function(t){var r=t.chart.data.datasets[t.datasetIndex].data[t.dataIndex],e=function(t,e){var n=M(e);return null==r||n.every(function(t){return null==r[t]})?t:"".concat(t," [").concat(L(r[n[0]])," .. ").concat(r[n[1]],"]")};return"(".concat(e(t.label,!0),", ").concat(e(t.value,!1),")")}}},dataElementType:w.id,dataElementOptions:Object.assign({},r.LineController.defaults.dataElementOptions,A)}]);var ot=function(t){s(a,t);var n=nt(a);function a(t,o){return e(this,a),n.call(this,t,Q(o,at,w,r.LinearScale))}return a}(r.Chart);ot.id=at.id;var it=function(t,r,e){return r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t};function ct(t){var r=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 e,n=i(t);if(r){var a=i(this).constructor;e=Reflect.construct(n,arguments,a)}else e=n.apply(this,arguments);return p(this,e)}}var ut=function(t){s(o,t);var n=ct(o);function o(){return e(this,o),n.apply(this,arguments)}return a(o,[{key:"getMinMax",value:function(t,r){var e=this;return G(t,r,function(t,r){return u(i(o.prototype),"getMinMax",e).call(e,t,r)})}},{key:"countVisibleElements",value:function(){var t=this,r=this._cachedMeta;return r.data.reduce(function(e,n,a){return!Number.isNaN(r._parsed[a].r)&&t.chart.getDataVisibility(a)?e+1:e},0)}},{key:"_computeAngle",value:function(t){var e=this._cachedMeta,n=e.count;if(Number.isNaN(e._parsed[t].r)||!this.chart.getDataVisibility(t))return 0;var a=this._getContext(t,!0);return r.resolve([this.chart.options.elements.arc.angle,2*Math.PI/n],a,t)}},{key:"parseObjectData",value:function(t,r,e,n){for(var a=new Array(n),o=t.rScale,i=0;i<n;++i){var c=i+e,u=r[c],l=o.parse(u[o.axis],c);a[i]=it({},o.axis,l)}return J(a,t.rScale,r,e,n),a}},{key:"updateElement",value:function(t,r,e,n){!function(t,r,e,n,a,o){for(var i=o.animation,c=function(t){var r=n.getDistanceFromCenterForValue(t),e=i.animateScale?0:r;return a?e:r},u=0,l=["".concat(n.axis,"Min"),"".concat(n.axis,"Max")];u<l.length;u++){var s=l[u],f=e[s];Array.isArray(f)?r[s]=f.map(c):"number"==typeof f&&(r[s]=c(f))}}(0,e,this.getParsed(r),this._cachedMeta.rScale,"reset"===n,this.chart.options),u(i(o.prototype),"updateElement",this).call(this,t,r,e,n)}},{key:"updateElements",value:function(t,r,e){var n=this.chart.scales.r,a=n.getDistanceFromCenterForValue;n.getDistanceFromCenterForValue=function(t){return"number"==typeof t?a.call(this,t):a.call(this,t.r)},u(i(o.prototype),"updateElements",this).call(this,t,r,e),n.getDistanceFromCenterForValue=a}}]),o}(r.PolarAreaController);ut.id="polarAreaWithErrorBars",ut.defaults=r.merge({},[r.PolarAreaController.defaults,N,{tooltips:{callbacks:{label:function(t){var e=r.PolarAreaController.defaults.tooltips.callbacks.label.call(this,t),n=t.chart.data.datasets[t.datasetIndex].data[t.dataIndex],a=["rMin","rMax"];return null==n||a.every(function(t){return null==n[t]})?e:"".concat(e," [").concat(L(n[a[0]])," .. ").concat(n[a[1]],"]")}}},dataElementType:_.id,dataElementOptions:r.PolarAreaController.defaults.dataElementOptions.concat(R)}]);var lt=function(t){s(a,t);var n=ct(a);function a(t,o){return e(this,a),n.call(this,t,Q(o,ut,_,r.RadialLinearScale))}return a}(r.Chart);lt.id=ut.id,r.registry.addControllers(Y,rt,ut,at),r.registry.addElements(j,_,rt,w),t.ArcWithErrorBar=_,t.BarWithErrorBarsChart=Z,t.BarWithErrorBarsController=Y,t.LineWithErrorBarsChart=et,t.LineWithErrorBarsController=rt,t.PointWithErrorBar=w,t.PolarAreaWithErrorBarsChart=lt,t.PolarAreaWithErrorBarsController=ut,t.RectangleWithErrorBar=j,t.ScatterWithErrorBarsChart=ot,t.ScatterWithErrorBarsController=at,Object.defineProperty(t,"__esModule",{value:!0})}); |
{ | ||
"name": "chartjs-chart-error-bars", | ||
"description": "Chart.js module for charting error bars", | ||
"version": "3.0.0-alpha.2", | ||
"version": "3.0.0-alpha.20", | ||
"author": { | ||
@@ -24,25 +24,30 @@ "name": "Samuel Gratzl", | ||
"peerDependencies": { | ||
"chart.js": "^3.0.0-alpha" | ||
"@sgratzl/chartjs-esm-facade": "^3.0.0-alpha.2", | ||
"chart.js": "^3.0.0-alpha.2" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.9.6" | ||
"@babel/runtime": "^7.10.5" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.9.6", | ||
"@babel/plugin-transform-runtime": "^7.9.6", | ||
"@babel/preset-env": "^7.9.6", | ||
"@rollup/plugin-babel": "^5.0.0", | ||
"@rollup/plugin-commonjs": "^11.1.0", | ||
"@rollup/plugin-node-resolve": "^7.1.3", | ||
"@yarnpkg/pnpify": "^2.0.0-rc.22", | ||
"babel-jest": "^26.0.1", | ||
"chart.js": "^3.0.0-alpha", | ||
"eslint": "^7.0.0", | ||
"@babel/core": "^7.10.5", | ||
"@babel/plugin-transform-runtime": "^7.10.5", | ||
"@babel/preset-env": "^7.10.4", | ||
"@rollup/plugin-alias": "^3.1.1", | ||
"@rollup/plugin-babel": "^5.1.0", | ||
"@rollup/plugin-commonjs": "^14.0.0", | ||
"@rollup/plugin-node-resolve": "^8.4.0", | ||
"@sgratzl/chartjs-esm-facade": "^3.0.0-alpha.2", | ||
"@yarnpkg/pnpify": "^2.1.0", | ||
"babel-jest": "^26.1.0", | ||
"canvas": "^2.6.1", | ||
"chart.js": "^3.0.0-alpha.2", | ||
"eslint": "^7.4.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-prettier": "^3.1.3", | ||
"jest": "^26.0.1", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"jest": "^26.1.0", | ||
"jest-image-snapshot": "^4.0.2", | ||
"prettier": "^2.0.5", | ||
"release-it": "^13.6.0", | ||
"release-it": "^13.6.5", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.10.2", | ||
"rollup": "^2.22.0", | ||
"rollup-plugin-pnp-resolve": "^2.0.0", | ||
@@ -68,8 +73,3 @@ "uglify-es": "^3.3.9" | ||
"release:pre": "release-it --disable-metrics --npm.skipChecks --preRelease=alpha --npm.tag=next" | ||
}, | ||
"dependenciesMeta": { | ||
"chart.js": { | ||
"unplugged": true | ||
} | ||
} | ||
} |
@@ -6,3 +6,3 @@ # Chart.js Error Bars | ||
Chart.js module for charting error bars plots. This plugin extends the several char types (`bar`, `horizontalBar`, `line`, `scatter`, `polarArea`) | ||
with their error bar equivalent (`barWithErrorBars`, `horizontalBarWithErrorBars`, `lineWithErrorBars`, `scatterWithErrorBars`, `polarAreaWithErrorBars`). | ||
with their error bar equivalent (`barWithErrorBars`, `lineWithErrorBars`, `scatterWithErrorBars`, `polarAreaWithErrorBars`). | ||
@@ -34,3 +34,3 @@ **Works only with Chart.js >= 3.0.0** | ||
```bash | ||
npm install --save chart.js chartjs-chart-error-bars | ||
npm install --save chart.js@next @sgratzl/chartjs-esm-facade@next chartjs-chart-error-bars@next | ||
``` | ||
@@ -48,3 +48,3 @@ | ||
```typescript | ||
```ts | ||
interface IErrorBarStyling { | ||
@@ -96,3 +96,3 @@ /** | ||
```typescript | ||
```ts | ||
interface IErrorBarItem { | ||
@@ -114,5 +114,5 @@ /** | ||
### Chart type: `horizontalBar` | ||
### Chart type: `bar` with `indexAxis: 'y'` | ||
```typescript | ||
```ts | ||
interface IErrorBarItem { | ||
@@ -136,3 +136,3 @@ /** | ||
```typescript | ||
```ts | ||
interface IErrorBarItem { | ||
@@ -168,3 +168,3 @@ /** | ||
```typescript | ||
```ts | ||
interface IErrorBarItem { | ||
@@ -198,3 +198,3 @@ /** | ||
```typescript | ||
```ts | ||
interface IErrorBarStyling { | ||
@@ -246,3 +246,3 @@ /** | ||
```typescript | ||
```ts | ||
{ | ||
@@ -263,6 +263,6 @@ y: 4, | ||
import Chart from 'chart.js'; | ||
import { BarWithErrorBarsController } from 'chartjs-chart-error-bars'; | ||
import { BarWithErrorBarsController, RectangleWithErrorBar } from 'chartjs-chart-error-bars'; | ||
// register controller in chart.js and ensure the defaults are set | ||
BarWithErrorBarsController.register(); | ||
Chart.register(BarWithErrorBarsController, RectangleWithErrorBar); | ||
@@ -311,3 +311,3 @@ const chart = new Chart(document.getElementById('canvas').getContext('2d'), { | ||
yarn | ||
yarn pnpify --sdk | ||
yarn pnpify --sdk vscode | ||
``` | ||
@@ -314,0 +314,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { color } from './chart'; | ||
import { color } from '@sgratzl/chartjs-esm-facade'; | ||
import { styleKeys } from './elements/render'; | ||
@@ -3,0 +3,0 @@ import { allModelKeys } from './controllers/utils'; |
@@ -1,4 +0,4 @@ | ||
export * from './bar'; | ||
export * from './line'; | ||
export * from './scatter'; | ||
export * from './polarArea'; | ||
export * from './BarWithErrorBarsController'; | ||
export * from './LineWithErrorBarsController'; | ||
export * from './ScatterWithErrorBarsController'; | ||
export * from './PolarAreaWithErrorBarsController'; |
import { modelKeys } from './utils'; | ||
import { defaults } from '../chart'; | ||
import { Tooltip, PolarAreaController } from '@sgratzl/chartjs-esm-facade'; | ||
@@ -8,33 +8,15 @@ function reverseOrder(v) { | ||
function generateTooltip(horizontal) { | ||
const keys = modelKeys(horizontal); | ||
return (item, data) => { | ||
const base = defaults.tooltips.callbacks.label.call(this, item, data); | ||
const v = data.datasets[item.datasetIndex].data[item.index]; | ||
if (v == null || keys.every((k) => v[k] == null)) { | ||
return base; | ||
} | ||
return `${base} (${reverseOrder(v[keys[0]])} .. ${v[keys[1]]})`; | ||
}; | ||
export function generateBarTooltip(item) { | ||
const keys = modelKeys(item.element.horizontal); | ||
const base = Tooltip.defaults.callbacks.label.call(this, item); | ||
const v = item.chart.data.datasets[item.datasetIndex].data[item.dataIndex]; | ||
if (v == null || keys.every((k) => v[k] == null)) { | ||
return base; | ||
} | ||
return `${base} (${reverseOrder(v[keys[0]])} .. ${v[keys[1]]})`; | ||
} | ||
export const verticalTooltipDefaults = { | ||
tooltips: { | ||
callbacks: { | ||
label: generateTooltip(false), | ||
}, | ||
}, | ||
}; | ||
export function generateTooltipScatter(item) { | ||
const v = item.chart.data.datasets[item.datasetIndex].data[item.dataIndex]; | ||
export const horizontalTooltipDefaults = { | ||
tooltips: { | ||
callbacks: { | ||
label: generateTooltip(true), | ||
}, | ||
}, | ||
}; | ||
export function generateTooltipScatter(item, data) { | ||
const v = data.datasets[item.datasetIndex].data[item.index]; | ||
const subLabel = (base, horizontal) => { | ||
@@ -51,5 +33,5 @@ const keys = modelKeys(horizontal); | ||
export function generateTooltipPolar(item, data) { | ||
const base = defaults.polarArea.tooltips.callbacks.label.call(this, item, data); | ||
const v = data.datasets[item.datasetIndex].data[item.index]; | ||
export function generateTooltipPolar(item) { | ||
const base = PolarAreaController.defaults.tooltips.callbacks.label.call(this, item); | ||
const v = item.chart.data.datasets[item.datasetIndex].data[item.dataIndex]; | ||
@@ -56,0 +38,0 @@ const keys = ['rMin', 'rMax']; |
@@ -1,3 +0,3 @@ | ||
export * from './rectangle'; | ||
export * from './point'; | ||
export * from './arc'; | ||
export * from './RectangleWithErrorBar'; | ||
export * from './PointWithErrorBar'; | ||
export * from './ArcWithErrorBar'; |
28
120524
3
23
2383
+ Added@sgratzl/chartjs-esm-facade@3.0.0-alpha.21(transitive)
Updated@babel/runtime@^7.10.5