chartjs-chart-error-bars
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -442,3 +442,3 @@ import { defaults as defaults$5, elements, helpers, controllers, scaleService } from 'chart.js'; | ||
}; | ||
var length = Math.hypot(v.x, v.y); | ||
var length = Math.sqrt(v.x * v.x + v.y * v.y); | ||
v.x /= length; | ||
@@ -821,3 +821,3 @@ v.y /= length; | ||
var dataset = superClass.getDataset.call(this); | ||
return Object.assign({}, dataset, { | ||
return _objectSpread2({}, dataset, { | ||
// inline d.v | ||
@@ -824,0 +824,0 @@ data: dataset.data.map(function (d) { |
@@ -446,3 +446,3 @@ (function (global, factory) { | ||
}; | ||
var length = Math.hypot(v.x, v.y); | ||
var length = Math.sqrt(v.x * v.x + v.y * v.y); | ||
v.x /= length; | ||
@@ -825,3 +825,3 @@ v.y /= length; | ||
var dataset = superClass.getDataset.call(this); | ||
return Object.assign({}, dataset, { | ||
return _objectSpread2({}, dataset, { | ||
// inline d.v | ||
@@ -828,0 +828,0 @@ data: dataset.data.map(function (d) { |
@@ -1,1 +0,1 @@ | ||
!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("chart.js")):"function"==typeof define&&define.amd?define(["exports","chart.js"],t):t((r=r||self).ChartErrorBars={},r.Chart)}(this,function(r,t){"use strict";function e(r,t,e){return t in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function a(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})),e.push.apply(e,a)}return e}function n(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(n,!0).forEach(function(t){e(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):a(n).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))})}return r}function i(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,t){if(!(Symbol.iterator in Object(r)||"[object Arguments]"===Object.prototype.toString.call(r)))return;var e=[],a=!0,n=!1,i=void 0;try{for(var l,o=r[Symbol.iterator]();!(a=(l=o.next()).done)&&(e.push(l.value),!t||e.length!==t);a=!0);}catch(r){n=!0,i=r}finally{try{a||null==o.return||o.return()}finally{if(n)throw i}}return e}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var l=["xMin","xMax","yMin","yMax"];function o(r){return r?l.slice(0,2):l.slice(2)}function s(r,t,e){var a=this,n=this.chart;this.min=null,this.max=null;var l=i(o(r),2),s=l[0],c=l[1];n.data.datasets.forEach(function(i,l){var o=n.getDatasetMeta(l);n.isDatasetVisible(l)&&(e||function(t){return r?t.xAxisID===a.id:t.yAxisID===a.id}(o))&&i.data.forEach(function(e,n){var i=a.getRightValue(e);if(!isNaN(i)&&!o.data[n].hidden){var l=e[s];Array.isArray(l)?l=l.reduce(function(r,t){return Math.min(r,t)},i):"number"!=typeof l&&(l=i),!isNaN(l)&&(null===a.min||l<a.min)&&(a.min=l);var u=e[c];Array.isArray(u)?u=u.reduce(function(r,t){return Math.max(r,t)},i):"number"!=typeof l&&(u=i),!isNaN(u)&&(null===a.max||u>a.max)&&(a.max=u),t&&t(e,r)}})}),null==this.min&&(this.min=0),null==this.max&&(this.max=0)}var c={errorBarLineWidth:[[1,3]],errorBarColor:[["#2c2c2c","#1f1f1f"]],errorBarWhiskerLineWidth:[[1,3]],errorBarWhiskerRatio:[[.2,.25]],errorBarWhiskerSize:[[20,24]],errorBarWhiskerColor:[["#2c2c2c","#1f1f1f"]]},u=Object.keys(c);function h(r){if(!r)return{};var t={};return l.forEach(function(e){t[e]=r[e]}),t}function f(r,t,e,a,n){l.forEach(function(i){var l=a[i];if(Array.isArray(l))if(e.hasOwnProperty(i)){var o=e[i];t.hasOwnProperty(i)||(r[i]=o.slice());var s=r[i];if(u=l,(c=s).length!==u.length||!c.every(function(r,t){return r===u[t]})){var c,u,h=Math.min(l.length,s.length);o=e[i]=new Array(h);for(var f=0;f<h;++f)o[f]=s[f]+(l[f]-s[f])*n}}else e[i]=l.slice()})}function d(r,t,e){var a=r.getDataset(),n=t.custom||{},i=r._elementOptions(),l={chart:r.chart,dataIndex:e,dataset:a,datasetIndex:r.index};u.forEach(function(r){t._model[r]=function(r,t,e){for(var a=0;a<r.length;++a){var n=r[a];if(void 0!==n&&(void 0!==t&&"function"==typeof n&&(n=n(t)),void 0!==e&&Array.isArray(n)&&(n=n[e%n.length]),void 0!==n))return n}}([n[r],a[r],i[r]],l,e)})}function g(r,t){var e=Array.isArray(r)?r:[r],a=Array.isArray(t)?t:[t];if(e.length===a.length)return e.map(function(r,t){return[r,a[t]]});var n=Math.max(e.length,a.length);return Array(n).map(function(r,t){return[e[t%e.length],a[t%a.length]]})}function y(r,t){return Array.isArray(r)?r[t%r.length]:r}function p(r,t,e){var a=y(t.errorBarWhiskerRatio,e);return null!=r&&a>0?r*a*.5:.5*y(t.errorBarWhiskerSize,e)}function m(r,t){null==r.xMin&&null==r.xMax||function(r,t,e,a){a.save(),a.translate(0,r.y),null==t&&(t=r.x),null==e&&(e=r.x);var n=g(t,e);n.reverse().forEach(function(t,e){var l=i(t,2),o=l[0],s=l[1],c=n.length-e-1,u=p(r.height,r,c);a.lineWidth=y(r.errorBarLineWidth,c),a.strokeStyle=y(r.errorBarColor,c),a.beginPath(),a.moveTo(o,0),a.lineTo(s,0),a.stroke(),a.lineWidth=y(r.errorBarWhiskerLineWidth,c),a.strokeStyle=y(r.errorBarWhiskerColor,c),a.beginPath(),a.moveTo(o,-u),a.lineTo(o,u),a.moveTo(s,-u),a.lineTo(s,u),a.stroke()}),a.restore()}(r,r.xMin,r.xMax,t),null==r.yMin&&null==r.yMax||function(r,t,e,a){a.save(),a.translate(r.x,0),null==t&&(t=r.y),null==e&&(e=r.y);var n=g(t,e);n.reverse().forEach(function(t,e){var l=i(t,2),o=l[0],s=l[1],c=n.length-e-1,u=p(r.width,r,c);a.lineWidth=y(r.errorBarLineWidth,c),a.strokeStyle=y(r.errorBarColor,c),a.beginPath(),a.moveTo(0,o),a.lineTo(0,s),a.stroke(),a.lineWidth=y(r.errorBarWhiskerLineWidth,c),a.strokeStyle=y(r.errorBarWhiskerColor,c),a.beginPath(),a.moveTo(-u,o),a.lineTo(u,o),a.moveTo(-u,s),a.lineTo(u,s),a.stroke()}),a.restore()}(r,r.yMin,r.yMax,t)}function v(r,t){null==r.yMin&&null==r.yMax||function(r,t,e,a){a.save(),a.translate(r.x,r.y),null==t&&(t=r.outerRadius),null==e&&(e=r.outerRadius);var n=(r.startAngle+r.endAngle)/2,l=Math.cos(n),o=Math.sin(n),s={x:-o,y:l},c=Math.hypot(s.x,s.y);s.x/=c,s.y/=c;var u=g(t,e);u.reverse().forEach(function(t,e){var n=i(t,2),c=n[0],h=n[1],f=u.length-e-1,d=c*l,g=c*o,m=h*l,v=h*o,b=p(null,r,f),B=s.x*b,x=s.y*b;a.lineWidth=y(r.errorBarLineWidth,f),a.strokeStyle=y(r.errorBarColor,f),a.beginPath(),a.moveTo(d,g),a.lineTo(m,v),a.stroke(),a.lineWidth=y(r.errorBarWhiskerLineWidth,f),a.strokeStyle=y(r.errorBarWhiskerColor,f),a.beginPath(),a.moveTo(d+B,g+x),a.lineTo(d-B,g-x),a.moveTo(m+B,v+x),a.lineTo(m-B,v-x),a.stroke()}),a.restore()}(r,r.yMin,r.yMax,t)}t.defaults.global.elements.rectangleWithErrorBar=n({},t.defaults.global.elements.rectangle,{},c);var b=t.elements.RectangleWithErrorBar=t.elements.Rectangle.extend({transition:function(r){var e=h(this._start),a=t.elements.Rectangle.prototype.transition.call(this,r),n=this._model,i=this._start,l=this._view;return n&&1!==r?(f(i,e,l,n,r),a):a},draw:function(){t.elements.Rectangle.prototype.draw.call(this),m(this._view,this._chart.ctx)}});t.defaults.global.elements.pointWithErrorBar=n({},t.defaults.global.elements.point,{},c);var B=t.elements.PointWithErrorBar=t.elements.Point.extend({transition:function(r){var e=h(this._start),a=t.elements.Point.prototype.transition.call(this,r),n=this._model,i=this._start,l=this._view;return n&&1!==r?(f(i,e,l,n,r),a):a},draw:function(){t.elements.Point.prototype.draw.call(this),m(this._view,this._chart.ctx)}});t.defaults.global.elements.arcWithErrorBar=n({},t.defaults.global.elements.arc,{},c);var x=t.elements.ArcWithErrorBar=t.elements.Arc.extend({transition:function(r){var e=h(this._start),a=t.elements.Arc.prototype.transition.call(this,r),n=this._model,i=this._start,l=this._view;return n&&1!==r?(f(i,e,l,n,r),a):a},draw:function(){t.elements.Arc.prototype.draw.call(this),v(this._view,this._chart.ctx)}});function E(r,t,e,a,n){var i=o(a),l=e.getBasePixel();i.forEach(function(a){var i=t[a];Array.isArray(i)?r[a]=i.map(function(r){return n?l:e.getPixelForValue(r)}):"number"==typeof i&&(r[a]=n?l:e.getPixelForValue(i))})}function W(r){return Array.isArray(r)?r.slice().reverse():r}function A(r){var e=this,a=o(r);return function(r,n){var i=t.defaults.global.tooltips.callbacks.label.call(e,r,n),l=n.datasets[r.datasetIndex].data[r.index];return null==l||a.every(function(r){return null==l[r]})?i:"".concat(i," (").concat(W(l[a[0]])," .. ").concat(l[a[1]],")")}}var S={scales:{yAxes:[{type:"linearWithErrorBars"}]},tooltips:{callbacks:{label:A(!1)}}},_={scales:{xAxes:[{type:"linearWithErrorBars"}]},tooltips:{callbacks:{label:A(!0)}}};t.defaults.barWithErrorBars=t.helpers.configMerge(t.defaults.bar,S),t.defaults.horizontalBarWithErrorBars=t.helpers.configMerge(t.defaults.horizontalBar,_),t.defaults.global.datasets&&t.defaults.global.datasets.bar&&(t.defaults.global.datasets.barWithErrorBars=n({},t.defaults.global.datasets.bar)),t.defaults.global.datasets&&t.defaults.global.datasets.horizontalBar&&(t.defaults.global.datasets.horizontalBarWithErrorBars=n({},t.defaults.global.datasets.horizontalBar));var k={dataElementType:t.elements.RectangleWithErrorBar,_elementOptions:function(){return this.chart.options.elements.rectangleWithErrorBar},_updateElementGeometry:function(r,e,a){var n;d(this,r,e);for(var i=arguments.length,l=new Array(i>3?i-3:0),o=3;o<i;o++)l[o-3]=arguments[o];(n=t.controllers.bar.prototype._updateElementGeometry).call.apply(n,[this,r,e,a].concat(l)),function(r,t,e,a){var n=r.getDataset().data[e];if(n){var i=r._getValueScale();E(t,n,i,i.isHorizontal(),a)}}(this,r._model,e,a)}},P=t.controllers.barWithErrorBars=t.controllers.bar.extend(k),w=t.controllers.horizontalBarWithErrorBars=t.controllers.horizontalBar.extend(k),M={scales:{yAxes:[{type:"linearWithErrorBars"}]},tooltips:{callbacks:{label:A(!1)}}};t.defaults.lineWithErrorBars=t.helpers.configMerge(t.defaults.line,M),t.defaults.global.datasets&&t.defaults.global.datasets.line&&(t.defaults.global.datasets.lineWithErrorBars=n({},t.defaults.global.datasets.line));var O={dataElementType:t.elements.PointWithErrorBar,_elementOptions:function(){return this.chart.options.elements.pointWithErrorBar},updateElement:function(r,e,a){for(var n,i=arguments.length,l=new Array(i>3?i-3:0),o=3;o<i;o++)l[o-3]=arguments[o];(n=t.controllers.line.prototype.updateElement).call.apply(n,[this,r,e,a].concat(l)),d(this,r,e),function(r,t,e,a){var n=r.getDataset().data[e];if(n){var i=r.getMeta();E(t,n,r.getScaleForId(i.xAxisID),!0,a),E(t,n,r.getScaleForId(i.yAxisID),!1,a)}}(this,r._model,e,a)}},T=t.controllers.lineWithErrorBars=t.controllers.line.extend(O),D={scales:{xAxes:[{type:"linearWithErrorBars"}],yAxes:[{type:"linearWithErrorBars"}]},tooltips:{callbacks:{label:function(r,t){var e=t.datasets[r.datasetIndex].data[r.index],a=function(r,t){var a=o(t);return null==e||a.every(function(r){return null==e[r]})?r:"".concat(r," [").concat(W(e[a[0]])," .. ").concat(e[a[1]],"]")};return"(".concat(a(r.xLabel,!0),", ").concat(a(r.yLabel,!1),")")}}}};t.defaults.scatterWithErrorBars=t.helpers.configMerge(t.defaults.scatter,D),t.defaults.global.datasets&&t.defaults.global.datasets.scatter&&(t.defaults.global.datasets.scatterWithErrorBars=n({},t.defaults.global.datasets.scatter));var L=t.controllers.scatterWithErrorBars=T,j={scale:{type:"radialLinearWithErrorBars"},tooltips:{callbacks:{label:function(r,e){var a=t.defaults.polarArea.tooltips.callbacks.label.call(this,r,e),n=e.datasets[r.datasetIndex].data[r.index],i=o(!1);return null==n||i.every(function(r){return null==n[r]})?a:"".concat(a," [").concat(W(n[i[0]])," .. ").concat(n[i[1]],"]")}}}};t.defaults.polarAreaWithErrorBars=t.helpers.configMerge(t.defaults.polarArea,j),t.defaults.global.datasets&&t.defaults.global.datasets.polarArea&&(t.defaults.global.datasets.polarAreaWithErrorBars=n({},t.defaults.global.datasets.polarArea));var R=t.controllers.polarArea.prototype,C={dataElementType:t.elements.ArcWithErrorBar,_elementOptions:function(){return this.chart.options.elements.arcWithErrorBar},_getPatchedDataset:function(){var r=R.getDataset.call(this);return Object.assign({},r,{data:r.data.map(function(r){return null!=r&&"number"==typeof r.y?r.y:r})})},_withPatching:function(r){try{return this.getDataset=this._getPatchedDataset.bind(this),r()}finally{delete this.getDataset}},updateElement:function(r,t,e){for(var a=this,n=arguments.length,i=new Array(n>3?n-3:0),l=3;l<n;l++)i[l-3]=arguments[l];this._withPatching(function(){var n;return(n=R.updateElement).call.apply(n,[a,r,t,e].concat(i))}),d(this,r,t),function(r,t,e,a,n){var i=r.getDataset().data[a];if(i){var l=r.chart,s=l.scale,c=l.options.animation,u=function(r){var e=s.getDistanceFromCenterForValue(r),a=c.animateScale?0:e;return n?a:t.hidden?0:e};o(!1).forEach(function(r){var t=i[r];Array.isArray(t)?e[r]=t.map(u):"number"==typeof t&&(e[r]=u(t))})}}(this,r,r._model,t,e)},countVisibleElements:function(){var r=this;return this._withPatching(function(){return R.countVisibleElements.call(r)})},_computeAngle:function(r){var t=this;return this._withPatching(function(){return R._computeAngle.call(t,r)})}},z=t.controllers.polarAreaWithErrorBars=t.controllers.polarArea.extend(C),I=t.helpers.merge({},[t.scaleService.getScaleDefaults("linear")]),N=t.scaleService.getScaleConstructor("linear").extend({determineDataLimits:function(){s.call(this,this.isHorizontal()),this.handleTickRangeOptions()}});t.scaleService.registerScaleType("linearWithErrorBars",N,I);var V=t.helpers.merge({},[t.scaleService.getScaleDefaults("logarithmic")]),F=t.scaleService.getScaleConstructor("logarithmic").extend({determineDataLimits:function(){var r=this;this.minNotZero=null,s.call(this,this.isHorizontal(),function(t,e){var a=e?t.xMin:t.yMin;"number"==typeof a&&0!==a&&(null===r.minNotZero||a<r.minNotZero)&&(r.minNotZero=a)}),this.handleTickRangeOptions()}});t.scaleService.registerScaleType("logarithmicWithErrorBars",F,V);var H=t.helpers.merge({},[t.scaleService.getScaleDefaults("radialLinear")]),Z=t.scaleService.getScaleConstructor("radialLinear").extend({determineDataLimits:function(){s.call(this,!1,null,!0),this.handleTickRangeOptions()}});t.scaleService.registerScaleType("radialLinearWithErrorBars",Z,H),r.ArcWithErrorBar=x,r.BarWithErrorBars=P,r.HorizontalBarWithErrorBars=w,r.LineWithErrorBars=T,r.LinearWithErrorBarsScale=N,r.LogarithmicWithErrorBarsScale=F,r.PointWithErrorBar=B,r.PolarAreaWithErrorBars=z,r.RadialLinearWithErrorBarsScale=Z,r.RectangleWithErrorBar=b,r.ScatterithErrorBars=L,Object.defineProperty(r,"__esModule",{value:!0})}); | ||
!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("chart.js")):"function"==typeof define&&define.amd?define(["exports","chart.js"],t):t((r=r||self).ChartErrorBars={},r.Chart)}(this,function(r,t){"use strict";function e(r,t,e){return t in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function a(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})),e.push.apply(e,a)}return e}function n(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(n,!0).forEach(function(t){e(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):a(n).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))})}return r}function i(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,t){if(!(Symbol.iterator in Object(r)||"[object Arguments]"===Object.prototype.toString.call(r)))return;var e=[],a=!0,n=!1,i=void 0;try{for(var l,o=r[Symbol.iterator]();!(a=(l=o.next()).done)&&(e.push(l.value),!t||e.length!==t);a=!0);}catch(r){n=!0,i=r}finally{try{a||null==o.return||o.return()}finally{if(n)throw i}}return e}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var l=["xMin","xMax","yMin","yMax"];function o(r){return r?l.slice(0,2):l.slice(2)}function s(r,t,e){var a=this,n=this.chart;this.min=null,this.max=null;var l=i(o(r),2),s=l[0],c=l[1];n.data.datasets.forEach(function(i,l){var o=n.getDatasetMeta(l);n.isDatasetVisible(l)&&(e||function(t){return r?t.xAxisID===a.id:t.yAxisID===a.id}(o))&&i.data.forEach(function(e,n){var i=a.getRightValue(e);if(!isNaN(i)&&!o.data[n].hidden){var l=e[s];Array.isArray(l)?l=l.reduce(function(r,t){return Math.min(r,t)},i):"number"!=typeof l&&(l=i),!isNaN(l)&&(null===a.min||l<a.min)&&(a.min=l);var u=e[c];Array.isArray(u)?u=u.reduce(function(r,t){return Math.max(r,t)},i):"number"!=typeof l&&(u=i),!isNaN(u)&&(null===a.max||u>a.max)&&(a.max=u),t&&t(e,r)}})}),null==this.min&&(this.min=0),null==this.max&&(this.max=0)}var c={errorBarLineWidth:[[1,3]],errorBarColor:[["#2c2c2c","#1f1f1f"]],errorBarWhiskerLineWidth:[[1,3]],errorBarWhiskerRatio:[[.2,.25]],errorBarWhiskerSize:[[20,24]],errorBarWhiskerColor:[["#2c2c2c","#1f1f1f"]]},u=Object.keys(c);function h(r){if(!r)return{};var t={};return l.forEach(function(e){t[e]=r[e]}),t}function f(r,t,e,a,n){l.forEach(function(i){var l=a[i];if(Array.isArray(l))if(e.hasOwnProperty(i)){var o=e[i];t.hasOwnProperty(i)||(r[i]=o.slice());var s=r[i];if(u=l,(c=s).length!==u.length||!c.every(function(r,t){return r===u[t]})){var c,u,h=Math.min(l.length,s.length);o=e[i]=new Array(h);for(var f=0;f<h;++f)o[f]=s[f]+(l[f]-s[f])*n}}else e[i]=l.slice()})}function d(r,t,e){var a=r.getDataset(),n=t.custom||{},i=r._elementOptions(),l={chart:r.chart,dataIndex:e,dataset:a,datasetIndex:r.index};u.forEach(function(r){t._model[r]=function(r,t,e){for(var a=0;a<r.length;++a){var n=r[a];if(void 0!==n&&(void 0!==t&&"function"==typeof n&&(n=n(t)),void 0!==e&&Array.isArray(n)&&(n=n[e%n.length]),void 0!==n))return n}}([n[r],a[r],i[r]],l,e)})}function g(r,t){var e=Array.isArray(r)?r:[r],a=Array.isArray(t)?t:[t];if(e.length===a.length)return e.map(function(r,t){return[r,a[t]]});var n=Math.max(e.length,a.length);return Array(n).map(function(r,t){return[e[t%e.length],a[t%a.length]]})}function y(r,t){return Array.isArray(r)?r[t%r.length]:r}function p(r,t,e){var a=y(t.errorBarWhiskerRatio,e);return null!=r&&a>0?r*a*.5:.5*y(t.errorBarWhiskerSize,e)}function m(r,t){null==r.xMin&&null==r.xMax||function(r,t,e,a){a.save(),a.translate(0,r.y),null==t&&(t=r.x),null==e&&(e=r.x);var n=g(t,e);n.reverse().forEach(function(t,e){var l=i(t,2),o=l[0],s=l[1],c=n.length-e-1,u=p(r.height,r,c);a.lineWidth=y(r.errorBarLineWidth,c),a.strokeStyle=y(r.errorBarColor,c),a.beginPath(),a.moveTo(o,0),a.lineTo(s,0),a.stroke(),a.lineWidth=y(r.errorBarWhiskerLineWidth,c),a.strokeStyle=y(r.errorBarWhiskerColor,c),a.beginPath(),a.moveTo(o,-u),a.lineTo(o,u),a.moveTo(s,-u),a.lineTo(s,u),a.stroke()}),a.restore()}(r,r.xMin,r.xMax,t),null==r.yMin&&null==r.yMax||function(r,t,e,a){a.save(),a.translate(r.x,0),null==t&&(t=r.y),null==e&&(e=r.y);var n=g(t,e);n.reverse().forEach(function(t,e){var l=i(t,2),o=l[0],s=l[1],c=n.length-e-1,u=p(r.width,r,c);a.lineWidth=y(r.errorBarLineWidth,c),a.strokeStyle=y(r.errorBarColor,c),a.beginPath(),a.moveTo(0,o),a.lineTo(0,s),a.stroke(),a.lineWidth=y(r.errorBarWhiskerLineWidth,c),a.strokeStyle=y(r.errorBarWhiskerColor,c),a.beginPath(),a.moveTo(-u,o),a.lineTo(u,o),a.moveTo(-u,s),a.lineTo(u,s),a.stroke()}),a.restore()}(r,r.yMin,r.yMax,t)}function v(r,t){null==r.yMin&&null==r.yMax||function(r,t,e,a){a.save(),a.translate(r.x,r.y),null==t&&(t=r.outerRadius),null==e&&(e=r.outerRadius);var n=(r.startAngle+r.endAngle)/2,l=Math.cos(n),o=Math.sin(n),s={x:-o,y:l},c=Math.sqrt(s.x*s.x+s.y*s.y);s.x/=c,s.y/=c;var u=g(t,e);u.reverse().forEach(function(t,e){var n=i(t,2),c=n[0],h=n[1],f=u.length-e-1,d=c*l,g=c*o,m=h*l,v=h*o,b=p(null,r,f),B=s.x*b,x=s.y*b;a.lineWidth=y(r.errorBarLineWidth,f),a.strokeStyle=y(r.errorBarColor,f),a.beginPath(),a.moveTo(d,g),a.lineTo(m,v),a.stroke(),a.lineWidth=y(r.errorBarWhiskerLineWidth,f),a.strokeStyle=y(r.errorBarWhiskerColor,f),a.beginPath(),a.moveTo(d+B,g+x),a.lineTo(d-B,g-x),a.moveTo(m+B,v+x),a.lineTo(m-B,v-x),a.stroke()}),a.restore()}(r,r.yMin,r.yMax,t)}t.defaults.global.elements.rectangleWithErrorBar=n({},t.defaults.global.elements.rectangle,{},c);var b=t.elements.RectangleWithErrorBar=t.elements.Rectangle.extend({transition:function(r){var e=h(this._start),a=t.elements.Rectangle.prototype.transition.call(this,r),n=this._model,i=this._start,l=this._view;return n&&1!==r?(f(i,e,l,n,r),a):a},draw:function(){t.elements.Rectangle.prototype.draw.call(this),m(this._view,this._chart.ctx)}});t.defaults.global.elements.pointWithErrorBar=n({},t.defaults.global.elements.point,{},c);var B=t.elements.PointWithErrorBar=t.elements.Point.extend({transition:function(r){var e=h(this._start),a=t.elements.Point.prototype.transition.call(this,r),n=this._model,i=this._start,l=this._view;return n&&1!==r?(f(i,e,l,n,r),a):a},draw:function(){t.elements.Point.prototype.draw.call(this),m(this._view,this._chart.ctx)}});t.defaults.global.elements.arcWithErrorBar=n({},t.defaults.global.elements.arc,{},c);var x=t.elements.ArcWithErrorBar=t.elements.Arc.extend({transition:function(r){var e=h(this._start),a=t.elements.Arc.prototype.transition.call(this,r),n=this._model,i=this._start,l=this._view;return n&&1!==r?(f(i,e,l,n,r),a):a},draw:function(){t.elements.Arc.prototype.draw.call(this),v(this._view,this._chart.ctx)}});function E(r,t,e,a,n){var i=o(a),l=e.getBasePixel();i.forEach(function(a){var i=t[a];Array.isArray(i)?r[a]=i.map(function(r){return n?l:e.getPixelForValue(r)}):"number"==typeof i&&(r[a]=n?l:e.getPixelForValue(i))})}function W(r){return Array.isArray(r)?r.slice().reverse():r}function A(r){var e=this,a=o(r);return function(r,n){var i=t.defaults.global.tooltips.callbacks.label.call(e,r,n),l=n.datasets[r.datasetIndex].data[r.index];return null==l||a.every(function(r){return null==l[r]})?i:"".concat(i," (").concat(W(l[a[0]])," .. ").concat(l[a[1]],")")}}var S={scales:{yAxes:[{type:"linearWithErrorBars"}]},tooltips:{callbacks:{label:A(!1)}}},_={scales:{xAxes:[{type:"linearWithErrorBars"}]},tooltips:{callbacks:{label:A(!0)}}};t.defaults.barWithErrorBars=t.helpers.configMerge(t.defaults.bar,S),t.defaults.horizontalBarWithErrorBars=t.helpers.configMerge(t.defaults.horizontalBar,_),t.defaults.global.datasets&&t.defaults.global.datasets.bar&&(t.defaults.global.datasets.barWithErrorBars=n({},t.defaults.global.datasets.bar)),t.defaults.global.datasets&&t.defaults.global.datasets.horizontalBar&&(t.defaults.global.datasets.horizontalBarWithErrorBars=n({},t.defaults.global.datasets.horizontalBar));var k={dataElementType:t.elements.RectangleWithErrorBar,_elementOptions:function(){return this.chart.options.elements.rectangleWithErrorBar},_updateElementGeometry:function(r,e,a){var n;d(this,r,e);for(var i=arguments.length,l=new Array(i>3?i-3:0),o=3;o<i;o++)l[o-3]=arguments[o];(n=t.controllers.bar.prototype._updateElementGeometry).call.apply(n,[this,r,e,a].concat(l)),function(r,t,e,a){var n=r.getDataset().data[e];if(n){var i=r._getValueScale();E(t,n,i,i.isHorizontal(),a)}}(this,r._model,e,a)}},P=t.controllers.barWithErrorBars=t.controllers.bar.extend(k),w=t.controllers.horizontalBarWithErrorBars=t.controllers.horizontalBar.extend(k),M={scales:{yAxes:[{type:"linearWithErrorBars"}]},tooltips:{callbacks:{label:A(!1)}}};t.defaults.lineWithErrorBars=t.helpers.configMerge(t.defaults.line,M),t.defaults.global.datasets&&t.defaults.global.datasets.line&&(t.defaults.global.datasets.lineWithErrorBars=n({},t.defaults.global.datasets.line));var O={dataElementType:t.elements.PointWithErrorBar,_elementOptions:function(){return this.chart.options.elements.pointWithErrorBar},updateElement:function(r,e,a){for(var n,i=arguments.length,l=new Array(i>3?i-3:0),o=3;o<i;o++)l[o-3]=arguments[o];(n=t.controllers.line.prototype.updateElement).call.apply(n,[this,r,e,a].concat(l)),d(this,r,e),function(r,t,e,a){var n=r.getDataset().data[e];if(n){var i=r.getMeta();E(t,n,r.getScaleForId(i.xAxisID),!0,a),E(t,n,r.getScaleForId(i.yAxisID),!1,a)}}(this,r._model,e,a)}},T=t.controllers.lineWithErrorBars=t.controllers.line.extend(O),D={scales:{xAxes:[{type:"linearWithErrorBars"}],yAxes:[{type:"linearWithErrorBars"}]},tooltips:{callbacks:{label:function(r,t){var e=t.datasets[r.datasetIndex].data[r.index],a=function(r,t){var a=o(t);return null==e||a.every(function(r){return null==e[r]})?r:"".concat(r," [").concat(W(e[a[0]])," .. ").concat(e[a[1]],"]")};return"(".concat(a(r.xLabel,!0),", ").concat(a(r.yLabel,!1),")")}}}};t.defaults.scatterWithErrorBars=t.helpers.configMerge(t.defaults.scatter,D),t.defaults.global.datasets&&t.defaults.global.datasets.scatter&&(t.defaults.global.datasets.scatterWithErrorBars=n({},t.defaults.global.datasets.scatter));var L=t.controllers.scatterWithErrorBars=T,j={scale:{type:"radialLinearWithErrorBars"},tooltips:{callbacks:{label:function(r,e){var a=t.defaults.polarArea.tooltips.callbacks.label.call(this,r,e),n=e.datasets[r.datasetIndex].data[r.index],i=o(!1);return null==n||i.every(function(r){return null==n[r]})?a:"".concat(a," [").concat(W(n[i[0]])," .. ").concat(n[i[1]],"]")}}}};t.defaults.polarAreaWithErrorBars=t.helpers.configMerge(t.defaults.polarArea,j),t.defaults.global.datasets&&t.defaults.global.datasets.polarArea&&(t.defaults.global.datasets.polarAreaWithErrorBars=n({},t.defaults.global.datasets.polarArea));var R=t.controllers.polarArea.prototype,C={dataElementType:t.elements.ArcWithErrorBar,_elementOptions:function(){return this.chart.options.elements.arcWithErrorBar},_getPatchedDataset:function(){var r=R.getDataset.call(this);return n({},r,{data:r.data.map(function(r){return null!=r&&"number"==typeof r.y?r.y:r})})},_withPatching:function(r){try{return this.getDataset=this._getPatchedDataset.bind(this),r()}finally{delete this.getDataset}},updateElement:function(r,t,e){for(var a=this,n=arguments.length,i=new Array(n>3?n-3:0),l=3;l<n;l++)i[l-3]=arguments[l];this._withPatching(function(){var n;return(n=R.updateElement).call.apply(n,[a,r,t,e].concat(i))}),d(this,r,t),function(r,t,e,a,n){var i=r.getDataset().data[a];if(i){var l=r.chart,s=l.scale,c=l.options.animation,u=function(r){var e=s.getDistanceFromCenterForValue(r),a=c.animateScale?0:e;return n?a:t.hidden?0:e};o(!1).forEach(function(r){var t=i[r];Array.isArray(t)?e[r]=t.map(u):"number"==typeof t&&(e[r]=u(t))})}}(this,r,r._model,t,e)},countVisibleElements:function(){var r=this;return this._withPatching(function(){return R.countVisibleElements.call(r)})},_computeAngle:function(r){var t=this;return this._withPatching(function(){return R._computeAngle.call(t,r)})}},z=t.controllers.polarAreaWithErrorBars=t.controllers.polarArea.extend(C),I=t.helpers.merge({},[t.scaleService.getScaleDefaults("linear")]),N=t.scaleService.getScaleConstructor("linear").extend({determineDataLimits:function(){s.call(this,this.isHorizontal()),this.handleTickRangeOptions()}});t.scaleService.registerScaleType("linearWithErrorBars",N,I);var V=t.helpers.merge({},[t.scaleService.getScaleDefaults("logarithmic")]),F=t.scaleService.getScaleConstructor("logarithmic").extend({determineDataLimits:function(){var r=this;this.minNotZero=null,s.call(this,this.isHorizontal(),function(t,e){var a=e?t.xMin:t.yMin;"number"==typeof a&&0!==a&&(null===r.minNotZero||a<r.minNotZero)&&(r.minNotZero=a)}),this.handleTickRangeOptions()}});t.scaleService.registerScaleType("logarithmicWithErrorBars",F,V);var H=t.helpers.merge({},[t.scaleService.getScaleDefaults("radialLinear")]),Z=t.scaleService.getScaleConstructor("radialLinear").extend({determineDataLimits:function(){s.call(this,!1,null,!0),this.handleTickRangeOptions()}});t.scaleService.registerScaleType("radialLinearWithErrorBars",Z,H),r.ArcWithErrorBar=x,r.BarWithErrorBars=P,r.HorizontalBarWithErrorBars=w,r.LineWithErrorBars=T,r.LinearWithErrorBarsScale=N,r.LogarithmicWithErrorBarsScale=F,r.PointWithErrorBar=B,r.PolarAreaWithErrorBars=z,r.RadialLinearWithErrorBarsScale=Z,r.RectangleWithErrorBar=b,r.ScatterithErrorBars=L,Object.defineProperty(r,"__esModule",{value:!0})}); |
{ | ||
"name": "chartjs-chart-error-bars", | ||
"description": "Chart.js module for charting error bars", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Samuel Gratzl", |
@@ -35,6 +35,7 @@ 'use strict'; | ||
const dataset = superClass.getDataset.call(this); | ||
return Object.assign({}, dataset, { | ||
return { | ||
...dataset, | ||
// inline d.v | ||
data: dataset.data.map((d) => (d != null && typeof d.y === 'number' ? d.y : d)) | ||
}); | ||
}; | ||
}, | ||
@@ -41,0 +42,0 @@ |
@@ -246,3 +246,3 @@ import {allModelKeys, isSameArray} from '../data'; | ||
}; | ||
const length = Math.hypot(v.x, v.y); | ||
const length = Math.sqrt(v.x * v.x + v.y * v.y); | ||
v.x /= length; | ||
@@ -249,0 +249,0 @@ v.y /= length; |
2207
99865