poop-graph/static/chartjs-chart-error-bars.umd.min.js

3 lines
12 KiB
JavaScript
Raw Normal View History

2023-03-31 17:25:27 -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 n(e){return e?a.slice(0,2):a.slice(2)}function s(e,r,t,a,n){const s=[`${a.axis}Min`,`${a.axis}Max`],o=a.getBasePixel();for(const i of s){const s=r[i];Array.isArray(s)?e[i]=s.map((e=>n?o:a.getPixelForValue(e,t))):e[i]="number"==typeof s?n?o:a.getPixelForValue(s,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 n=Math.max(t.length,a.length);return Array(n).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,n,s;const o=e.getProps(["x","y","width","height","xMin","xMax","yMin","yMax"]);null==o.xMin&&null==o.xMax||function(e,r,t,a,n){n.save(),n.translate(0,e.y);const s=c(null==r?e.x:r,null==t?e.x:t);s.reverse().forEach((([r,t],o)=>{const i=s.length-o-1,l=d(e.height,a,i);n.lineWidth=u(a.errorBarLineWidth,i),n.strokeStyle=u(a.errorBarColor,i),n.beginPath(),n.moveTo(r,0),n.lineTo(t,0),n.stroke(),n.lineWidth=u(a.errorBarWhiskerLineWidth,i),n.strokeStyle=u(a.errorBarWhiskerColor,i),n.beginPath(),n.moveTo(r,-l),n.lineTo(r,l),n.moveTo(t,-l),n.lineTo(t,l),n.stroke()})),n.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,n){n.save(),n.translate(e.x,0);const s=c(null==r?e.y:r,null==t?e.y:t);s.reverse().forEach((([r,t],o)=>{const i=s.length-o-1,l=d(e.width,a,i);n.lineWidth=u(a.errorBarLineWidth,i),n.strokeStyle=u(a.errorBarColor,i),n.beginPath(),n.moveTo(0,r),n.lineTo(0,t),n.stroke(),n.lineWidth=u(a.errorBarWhiskerLineWidth,i),n.strokeStyle=u(a.errorBarWhiskerColor,i),n.beginPath(),n.moveTo(-l,r),n.lineTo(l,r),n.moveTo(-l,t),n.lineTo(l,t),n.stroke()})),n.restore()}(o,null!==(n=o.yMin)&&void 0!==n?n:null,null!==(s=o.yMax)&&void 0!==s?s: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,n){n.save(),n.translate(e.x,e.y);const s=(e.startAngle+e.endAngle)/2,o=Math.cos(s),i=Math.sin(s),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 s=p.length-t-1,c=e*o,h=e*i,f=r*o,m=r*i,y=d(null,a,s),x=l.x*y,g=l.y*y;n.lineWidth=u(a.errorBarLineWidth,s),n.strokeStyle=u(a.errorBarColor,s),n.beginPath(),n.moveTo(c,h),n.lineTo(f,m),n.stroke(),n.lineWidth=u(a.errorBarWhiskerLineWidth,s),n.strokeStyle=u(a.errorBarWhiskerColor,s),n.beginPath(),n.moveTo(c+x,h+g),n.lineTo(c-x,h-g),n.moveTo(f+x,m+g),n.lineTo(f-x,m-g),n.stroke()})),n.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 y extends r.ArcElement{draw(e){super.draw(e),p(this,e)}}function x(e){return Array.isArray(e)?e.slice().reverse():e}function g(e){const t=n(e.element.horizontal),a=r.Tooltip.defaults.callb
//# sourceMappingURL=chartjs-chart-error-bars.umd.min.js.map