2023-04-05 15:58:09 -04:00
|
|
|
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("chart.js"),require("chart.js/helpers")):"function"==typeof define&&define.amd?define(["exports","chart.js","chart.js/helpers"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).ChartErrorBars={},e.Chart,e.Chart.helpers)}(this,(function(e,r,t){"use strict";const a=["xMin","xMax","yMin","yMax"];function s(e){return e?a.slice(0,2):a.slice(2)}function n(e,r,t,a,s){const n=[`${a.axis}Min`,`${a.axis}Max`],o=a.getBasePixel();for(const i of n){const n=r[i];Array.isArray(n)?e[i]=n.map((e=>s?o:a.getPixelForValue(e,t))):e[i]="number"==typeof n?s?o:a.getPixelForValue(n,t):null}}const o={errorBarLineWidth:{v:[1,3]},errorBarColor:{v:["#2c2c2c","#1f1f1f"]},errorBarWhiskerLineWidth:{v:[1,3]},errorBarWhiskerRatio:{v:[.2,.25]},errorBarWhiskerSize:{v:[20,24]},errorBarWhiskerColor:{v:["#2c2c2c","#1f1f1f"]}},i={_scriptable:!0,_indexable:e=>"v"!==e},l=Object.keys(o);function c(e,r){const t=Array.isArray(e)?e:[e],a=Array.isArray(r)?r:[r];if(t.length===a.length)return t.map(((e,r)=>[e,a[r]]));const s=Math.max(t.length,a.length);return Array(s).map(((e,r)=>[t[r%t.length],a[r%a.length]]))}function u(e,r){if("string"==typeof e||"number"==typeof e)return e;const t=Array.isArray(e)?e:e.v;return t[r%t.length]}function d(e,r,t){const a=u(r.errorBarWhiskerRatio,t);if(null!=e&&a>0)return e*a*.5;return.5*u(r.errorBarWhiskerSize,t)}function h(e,r){var t,a,s,n;const o=e.getProps(["x","y","width","height","xMin","xMax","yMin","yMax"]);null==o.xMin&&null==o.xMax||function(e,r,t,a,s){s.save(),s.translate(0,e.y);const n=c(null==r?e.x:r,null==t?e.x:t);n.reverse().forEach((([r,t],o)=>{const i=n.length-o-1,l=d(e.height,a,i);s.lineWidth=u(a.errorBarLineWidth,i),s.strokeStyle=u(a.errorBarColor,i),s.beginPath(),s.moveTo(r,0),s.lineTo(t,0),s.stroke(),s.lineWidth=u(a.errorBarWhiskerLineWidth,i),s.strokeStyle=u(a.errorBarWhiskerColor,i),s.beginPath(),s.moveTo(r,-l),s.lineTo(r,l),s.moveTo(t,-l),s.lineTo(t,l),s.stroke()})),s.restore()}(o,null!==(t=o.xMin)&&void 0!==t?t:null,null!==(a=o.xMax)&&void 0!==a?a:null,e.options,r),null==o.yMin&&null==o.yMax||function(e,r,t,a,s){s.save(),s.translate(e.x,0);const n=c(null==r?e.y:r,null==t?e.y:t);n.reverse().forEach((([r,t],o)=>{const i=n.length-o-1,l=d(e.width,a,i);s.lineWidth=u(a.errorBarLineWidth,i),s.strokeStyle=u(a.errorBarColor,i),s.beginPath(),s.moveTo(0,r),s.lineTo(0,t),s.stroke(),s.lineWidth=u(a.errorBarWhiskerLineWidth,i),s.strokeStyle=u(a.errorBarWhiskerColor,i),s.beginPath(),s.moveTo(-l,r),s.lineTo(l,r),s.moveTo(-l,t),s.lineTo(l,t),s.stroke()})),s.restore()}(o,null!==(s=o.yMin)&&void 0!==s?s:null,null!==(n=o.yMax)&&void 0!==n?n:null,e.options,r)}function p(e,r){const t=e.getProps(["x","y","startAngle","endAngle","rMin","rMax","outerRadius"]);null==t.rMin&&null==t.rMax||function(e,r,t,a,s){s.save(),s.translate(e.x,e.y);const n=(e.startAngle+e.endAngle)/2,o=Math.cos(n),i=Math.sin(n),l={x:-i,y:o},h=Math.sqrt(l.x*l.x+l.y*l.y);l.x/=h,l.y/=h;const p=c(null!=r?r:e.outerRadius,null!=t?t:e.outerRadius);p.reverse().forEach((([e,r],t)=>{const n=p.length-t-1,c=e*o,h=e*i,f=r*o,m=r*i,x=d(null,a,n),y=l.x*x,g=l.y*x;s.lineWidth=u(a.errorBarLineWidth,n),s.strokeStyle=u(a.errorBarColor,n),s.beginPath(),s.moveTo(c,h),s.lineTo(f,m),s.stroke(),s.lineWidth=u(a.errorBarWhiskerLineWidth,n),s.strokeStyle=u(a.errorBarWhiskerColor,n),s.beginPath(),s.moveTo(c+y,h+g),s.lineTo(c-y,h-g),s.moveTo(f+y,m+g),s.lineTo(f-y,m-g),s.stroke()})),s.restore()}(t,t.rMin,t.rMax,e.options,r)}class f extends r.BarElement{draw(e){super.draw(e),h(this,e)}}f.id="barWithErrorBar",f.defaults={...r.BarElement.defaults,...o},f.defaultRoutes=r.BarElement.defaultRoutes,f.descriptors=i;class m extends r.PointElement{draw(e,r){super.draw.call(this,e,r),h(this,e)}}m.id="pointWithErrorBar",m.defaults={...r.PointElement.defaults,...o},m.defaultRoutes=r.PointElement.defaultRoutes,m.descriptors=i;class x extends r.ArcElement{draw(e){super.draw(e),p(this,e)}}function y(e){return Array.isArray(e)?e.slice().reverse():e}function g(e){const t=s(e.element.horizontal),a=r.Tooltip.defaults.callb
|