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

chartjs-chart-error-bars

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chartjs-chart-error-bars - npm Package Compare versions

Comparing version 3.6.0 to 3.7.0

2

build/index.cjs.js

@@ -163,3 +163,3 @@ /**

}
BarWithErrorBar.id = 'rectangleWithErrorBar';
BarWithErrorBar.id = 'barWithErrorBar';
BarWithErrorBar.defaults = { ...chart_js.BarElement.defaults, ...errorBarDefaults };

@@ -166,0 +166,0 @@ BarWithErrorBar.defaultRoutes = chart_js.BarElement.defaultRoutes;

@@ -8,7 +8,28 @@ /**

import { BarElement, PointElement, ArcElement, BarController, Scale, ChartMeta, Element, UpdateMode, BarControllerDatasetOptions, ScriptableAndArrayOptions, ScriptableContext, Chart, ChartItem, ChartConfiguration, LineController, LineControllerDatasetOptions, ScatterController, ScatterControllerDatasetOptions, PolarAreaController, PolarAreaControllerDatasetOptions } from 'chart.js';
import { BarElement, PointElement, ArcElement, BarController, Scale, ChartMeta, Element, UpdateMode, BarControllerDatasetOptions, ScriptableAndArrayOptions as ScriptableAndArrayOptions$1, ScriptableContext as ScriptableContext$1, Chart, ChartItem, ChartConfiguration, LineController, LineControllerDatasetOptions, ScatterController, ScatterControllerDatasetOptions, PolarAreaController, PolarAreaControllerDatasetOptions } from 'chart.js';
interface IErrorBarOptions {
errorBarLineWidth: number | {
v: number[];
};
errorBarColor: string | {
v: string[];
};
errorBarWhiskerLineWidth: number | {
v: number[];
};
errorBarWhiskerRatio: number | {
v: number[];
};
errorBarWhiskerSize: number | {
v: number[];
};
errorBarWhiskerColor: string | {
v: string[];
};
}
declare class BarWithErrorBar extends BarElement {
draw(ctx: CanvasRenderingContext2D): void;
static readonly id = "rectangleWithErrorBar";
static readonly id = "barWithErrorBar";
static readonly defaults: any;

@@ -23,2 +44,7 @@ static readonly defaultRoutes: {

}
declare module 'chart.js' {
interface ElementOptionsByType<TType extends ChartType> {
barWithErrorBar: ScriptableAndArrayOptions<IErrorBarOptions & BarOptions & BarHoverOptions, ScriptableContext<TType>>;
}
}

@@ -37,2 +63,7 @@ declare class PointWithErrorBar extends PointElement {

}
declare module 'chart.js' {
interface ElementOptionsByType<TType extends ChartType> {
pointWithErrorBar: ScriptableAndArrayOptions<IErrorBarOptions & PointOptions & PointHoverOptions, ScriptableContext<TType>>;
}
}

@@ -51,22 +82,6 @@ declare class ArcWithErrorBar extends ArcElement {

}
interface IErrorBarOptions {
errorBarLineWidth: number | {
v: number[];
};
errorBarColor: string | {
v: string[];
};
errorBarWhiskerLineWidth: number | {
v: number[];
};
errorBarWhiskerRatio: number | {
v: number[];
};
errorBarWhiskerSize: number | {
v: number[];
};
errorBarWhiskerColor: string | {
v: string[];
};
declare module 'chart.js' {
interface ElementOptionsByType<TType extends ChartType> {
arcWithErrorBar: ScriptableAndArrayOptions<IErrorBarOptions & ArcOptions & ArcHoverOptions, ScriptableContext<TType>>;
}
}

@@ -106,3 +121,3 @@

}
interface BarWithErrorBarsControllerDatasetOptions extends BarControllerDatasetOptions, ScriptableAndArrayOptions<IErrorBarOptions, ScriptableContext<'barWithErrorBars'>> {
interface BarWithErrorBarsControllerDatasetOptions extends BarControllerDatasetOptions, ScriptableAndArrayOptions$1<IErrorBarOptions, ScriptableContext$1<'barWithErrorBars'>> {
}

@@ -140,3 +155,3 @@ declare module 'chart.js' {

}
interface LineWithErrorBarsControllerDatasetOptions extends LineControllerDatasetOptions, ScriptableAndArrayOptions<IErrorBarOptions, ScriptableContext<'lineWithErrorBars'>> {
interface LineWithErrorBarsControllerDatasetOptions extends LineControllerDatasetOptions, ScriptableAndArrayOptions$1<IErrorBarOptions, ScriptableContext$1<'lineWithErrorBars'>> {
}

@@ -174,3 +189,3 @@ declare module 'chart.js' {

}
interface ScatterWithErrorBarsControllerDatasetOptions extends ScatterControllerDatasetOptions, ScriptableAndArrayOptions<IErrorBarOptions, ScriptableContext<'scatterWithErrorBars'>> {
interface ScatterWithErrorBarsControllerDatasetOptions extends ScatterControllerDatasetOptions, ScriptableAndArrayOptions$1<IErrorBarOptions, ScriptableContext$1<'scatterWithErrorBars'>> {
}

@@ -210,3 +225,3 @@ declare module 'chart.js' {

}
interface PolarAreaWithErrorBarsControllerDatasetOptions extends PolarAreaControllerDatasetOptions, ScriptableAndArrayOptions<IErrorBarOptions, ScriptableContext<'polarAreaWithErrorBars'>> {
interface PolarAreaWithErrorBarsControllerDatasetOptions extends PolarAreaControllerDatasetOptions, ScriptableAndArrayOptions$1<IErrorBarOptions, ScriptableContext$1<'polarAreaWithErrorBars'>> {
}

@@ -213,0 +228,0 @@ declare module 'chart.js' {

@@ -159,3 +159,3 @@ /**

}
BarWithErrorBar.id = 'rectangleWithErrorBar';
BarWithErrorBar.id = 'barWithErrorBar';
BarWithErrorBar.defaults = { ...BarElement.defaults, ...errorBarDefaults };

@@ -162,0 +162,0 @@ BarWithErrorBar.defaultRoutes = BarElement.defaultRoutes;

@@ -198,3 +198,3 @@ /**

}
BarWithErrorBar.id = 'rectangleWithErrorBar';
BarWithErrorBar.id = 'barWithErrorBar';
BarWithErrorBar.defaults = { ...chart_js.BarElement.defaults, ...errorBarDefaults };

@@ -201,0 +201,0 @@ BarWithErrorBar.defaultRoutes = chart_js.BarElement.defaultRoutes;

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

!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("chart.js"),require("chart.js/helpers")):"function"==typeof define&&define.amd?define(["exports","chart.js","chart.js/helpers"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self).ChartErrorBars={},r.Chart,r.Chart.helpers)}(this,(function(r,e,t){"use strict";const a=["xMin","xMax","yMin","yMax"];function n(r){return r?a.slice(0,2):a.slice(2)}function o(r,e,t,a,n){const o=[`${a.axis}Min`,`${a.axis}Max`],s=a.getBasePixel();for(const l of o){const o=e[l];Array.isArray(o)?r[l]=o.map((r=>n?s:a.getPixelForValue(r,t))):"number"==typeof o&&(r[l]=n?s:a.getPixelForValue(o,t))}}const s={errorBarLineWidth:{v:[1,3]},errorBarColor:{v:["#2c2c2c","#1f1f1f"]},errorBarWhiskerLineWidth:{v:[1,3]},errorBarWhiskerRatio:{v:[.2,.25]},errorBarWhiskerSize:{v:[20,24]},errorBarWhiskerColor:{v:["#2c2c2c","#1f1f1f"]}},l={_scriptable:!0,_indexable:r=>"v"!==r},i=Object.keys(s);function c(r,e){const t=Array.isArray(r)?r:[r],a=Array.isArray(e)?e:[e];if(t.length===a.length)return t.map(((r,e)=>[r,a[e]]));const n=Math.max(t.length,a.length);return Array(n).map(((r,e)=>[t[e%t.length],a[e%a.length]]))}function u(r,e){if("string"==typeof r||"number"==typeof r)return r;const t=Array.isArray(r)?r:r.v;return t[e%t.length]}function d(r,e,t){const a=u(e.errorBarWhiskerRatio,t);if(null!=r&&a>0)return r*a*.5;return.5*u(e.errorBarWhiskerSize,t)}function h(r,e){var t,a,n,o;const s=r.getProps(["x","y","width","height","xMin","xMax","yMin","yMax"]);null==s.xMin&&null==s.xMax||function(r,e,t,a,n){n.save(),n.translate(0,r.y);const o=c(null==e?r.x:e,null==t?r.x:t);o.reverse().forEach((([e,t],s)=>{const l=o.length-s-1,i=d(r.height,a,l);n.lineWidth=u(a.errorBarLineWidth,l),n.strokeStyle=u(a.errorBarColor,l),n.beginPath(),n.moveTo(e,0),n.lineTo(t,0),n.stroke(),n.lineWidth=u(a.errorBarWhiskerLineWidth,l),n.strokeStyle=u(a.errorBarWhiskerColor,l),n.beginPath(),n.moveTo(e,-i),n.lineTo(e,i),n.moveTo(t,-i),n.lineTo(t,i),n.stroke()})),n.restore()}(s,null!==(t=s.xMin)&&void 0!==t?t:null,null!==(a=s.xMax)&&void 0!==a?a:null,r.options,e),null==s.yMin&&null==s.yMax||function(r,e,t,a,n){n.save(),n.translate(r.x,0);const o=c(null==e?r.y:e,null==t?r.y:t);o.reverse().forEach((([e,t],s)=>{const l=o.length-s-1,i=d(r.width,a,l);n.lineWidth=u(a.errorBarLineWidth,l),n.strokeStyle=u(a.errorBarColor,l),n.beginPath(),n.moveTo(0,e),n.lineTo(0,t),n.stroke(),n.lineWidth=u(a.errorBarWhiskerLineWidth,l),n.strokeStyle=u(a.errorBarWhiskerColor,l),n.beginPath(),n.moveTo(-i,e),n.lineTo(i,e),n.moveTo(-i,t),n.lineTo(i,t),n.stroke()})),n.restore()}(s,null!==(n=s.yMin)&&void 0!==n?n:null,null!==(o=s.yMax)&&void 0!==o?o:null,r.options,e)}function f(r,e){const t=r.getProps(["x","y","startAngle","endAngle","rMin","rMax","outerRadius"]);null==t.rMin&&null==t.rMax||function(r,e,t,a,n){n.save(),n.translate(r.x,r.y);const o=(r.startAngle+r.endAngle)/2,s=Math.cos(o),l=Math.sin(o),i={x:-l,y:s},h=Math.sqrt(i.x*i.x+i.y*i.y);i.x/=h,i.y/=h;const f=c(null!=e?e:r.outerRadius,null!=t?t:r.outerRadius);f.reverse().forEach((([r,e],t)=>{const o=f.length-t-1,c=r*s,h=r*l,p=e*s,y=e*l,x=d(null,a,o),m=i.x*x,g=i.y*x;n.lineWidth=u(a.errorBarLineWidth,o),n.strokeStyle=u(a.errorBarColor,o),n.beginPath(),n.moveTo(c,h),n.lineTo(p,y),n.stroke(),n.lineWidth=u(a.errorBarWhiskerLineWidth,o),n.strokeStyle=u(a.errorBarWhiskerColor,o),n.beginPath(),n.moveTo(c+m,h+g),n.lineTo(c-m,h-g),n.moveTo(p+m,y+g),n.lineTo(p-m,y-g),n.stroke()})),n.restore()}(t,t.rMin,t.rMax,r.options,e)}class p extends e.BarElement{draw(r){super.draw(r),h(this,r)}}p.id="rectangleWithErrorBar",p.defaults={...e.BarElement.defaults,...s},p.defaultRoutes=e.BarElement.defaultRoutes,p.descriptors=l;class y extends e.PointElement{draw(r,e){super.draw.call(this,r,e),h(this,r)}}y.id="pointWithErrorBar",y.defaults={...e.PointElement.defaults,...s},y.defaultRoutes=e.PointElement.defaultRoutes,y.descriptors=l;class x extends e.ArcElement{draw(r){super.draw(r),f(this,r)}}function m(r){return Array.isArray(r)?r.slice().reverse():r}function g(r){const t=n(r.element.horizontal),a=e.Tooltip.defaults.callbacks.label.call(this,r),o=r.chart.data.datasets[r.datasetIndex].data[r.dataIndex];return null==o||t.every((r=>null==o[r]))?a:`${a} (${m(o[t[0]])} .. ${o[t[1]]})`}x.id="arcWithErrorBar",x.defaults={...e.ArcElement.defaults,...s},x.defaultRoutes=e.ArcElement.defaultRoutes,x.descriptors=l;const M={color(r,e,a){const n=r||"transparent",o=e||"transparent";if(n===o)return e;const s=t.color(n),l=s.valid&&t.color(o);return l&&l.valid?l.mix(s,a).hexString():e},number:(r,e,t)=>r===e?e:r+(e-r)*t};function B(r,e,t,a,n){if(typeof r===a&&typeof e===a)return n(r,e,t);if(Array.isArray(r)&&Array.isArray(e))return r.map(((r,a)=>n(r,e[a],t)));const o=r=>r&&Array.isArray(r.v);return o(r)&&o(e)?{v:r.v.map(((r,a)=>n(r,e.v[a],t)))}:e}const E={animations:{numberArray:{fn:function(r,e,t){return B(r,e,t,"number",M.number)},properties:a.concat(i.filter((r=>!r.endsWith("Color"))),["rMin","rMax"])},colorArray:{fn:function(r,e,t){return B(r,e,t,"string",M.color)},properties:i.filter((r=>r.endsWith("Color")))}}};function b(r,e){const{axis:t}=r;r.axis=`${t}MinMin`;const{min:a}=e(r);r.axis=`${t}MaxMax`;const{max:n}=e(r);return r.axis=t,{min:a,max:n}}function v(r,e,t){return Array.isArray(e)?t(...e):"number"==typeof e?e:r}function C(r,e,t,a,n){const o="string"==typeof e?e:e.axis,s=`${o}Min`,l=`${o}Max`,i=`${o}MinMin`,c=`${o}MaxMax`;for(let e=0;e<n;e+=1){const n=e+a,u=r[e];u[s]=t[n][s],u[l]=t[n][l],u[i]=v(u[o],u[s],Math.min),u[c]=v(u[o],u[l],Math.max)}}function W(r,e,t,a){const{axis:n}=e,o=e.getLabels();for(let s=0;s<a;s+=1){const a=s+t;r[s][n]=e.parse(o[a],a)}}function A(r,t,a,n=[],o=[]){e.registry.addControllers(a),Array.isArray(n)?e.registry.addElements(...n):e.registry.addElements(n),Array.isArray(o)?e.registry.addScales(...o):e.registry.addScales(o);const s=t;return s.type=r,s}class S extends e.BarController{getMinMax(r,e){return b(r,(r=>super.getMinMax(r,e)))}parseObjectData(r,e,t,a){const n=super.parseObjectData(r,e,t,a);return C(n,r.vScale,e,t,a),W(n,r.iScale,t,a),n}updateElement(r,e,t,a){"number"==typeof e&&o(t,this.getParsed(e),e,this._cachedMeta.vScale,"reset"===a),super.updateElement(r,e,t,a)}}S.id="barWithErrorBars",S.defaults=t.merge({},[e.BarController.defaults,E,{dataElementType:p.id}]),S.overrides=t.merge({},[e.BarController.overrides,{plugins:{tooltip:{callbacks:{label:g}}}}]),S.defaultRoutes=e.BarController.defaultRoutes;class k extends e.Chart{constructor(r,t){super(r,A("barWithErrorBars",t,S,p,[e.LinearScale,e.CategoryScale]))}}k.id=S.id;class P extends e.LineController{getMinMax(r,e){return b(r,(r=>super.getMinMax(r,e)))}parseObjectData(r,e,t,a){const n=super.parseObjectData(r,e,t,a);return C(n,r.vScale,e,t,a),W(n,r.iScale,t,a),n}updateElement(r,e,t,a){r instanceof y&&"number"==typeof e&&o(t,this.getParsed(e),e,this._cachedMeta.vScale,"reset"===a),super.updateElement(r,e,t,a)}}P.id="lineWithErrorBars",P.defaults=t.merge({},[e.LineController.defaults,E,{dataElementType:y.id}]),P.overrides=t.merge({},[e.LineController.overrides,{plugins:{tooltip:{callbacks:{label:g}}}}]),P.defaultRoutes=e.LineController.defaultRoutes;class T extends e.Chart{constructor(r,t){super(r,A("lineWithErrorBars",t,P,y,[e.LinearScale,e.CategoryScale]))}}T.id=P.id;class $ extends e.ScatterController{getMinMax(r,e){return b(r,(r=>super.getMinMax(r,e)))}parseObjectData(r,e,t,a){const n=super.parseObjectData(r,e,t,a);return C(n,r.xScale,e,t,a),C(n,r.yScale,e,t,a),n}updateElement(r,e,t,a){r instanceof y&&"number"==typeof e&&(o(t,this.getParsed(e),e,this._cachedMeta.xScale,"reset"===a),o(t,this.getParsed(e),e,this._cachedMeta.yScale,"reset"===a)),super.updateElement(r,e,t,a)}}$.id="scatterWithErrorBars",$.defaults=t.merge({},[e.ScatterController.defaults,E,{dataElementType:y.id}]),$.overrides=t.merge({},[e.ScatterController.overrides,{plugins:{tooltip:{callbacks:{label:function(r){const e=r.chart.data.datasets[r.datasetIndex].data[r.dataIndex],t=(r,t)=>{const a=n(t);return null==e||a.every((r=>null==e[r]))?r:`${r} [${m(e[a[0]])} .. ${e[a[1]]}]`};return`(${t(r.label,!0)}, ${t(r.parsed.y,!1)})`}}}}}]),$.defaultRoutes=e.LineController.defaultRoutes;class L extends e.Chart{constructor(r,t){super(r,A("scatterWithErrorBars",t,$,y,[e.LinearScale]))}}L.id=$.id;class R extends e.PolarAreaController{getMinMax(r,e){return b(r,(r=>super.getMinMax(r,e)))}countVisibleElements(){const r=this._cachedMeta;return r.data.reduce(((e,t,a)=>!Number.isNaN(r._parsed[a].r)&&this.chart.getDataVisibility(a)?e+1:e),0)}parseObjectData(r,e,t,a){const n=new Array(a),o=r.rScale;for(let r=0;r<a;r+=1){const a=r+t,s=e[a],l=o.parse(s[o.axis],a);n[r]={[o.axis]:l}}return C(n,o,e,t,a),n}updateElement(r,e,t,a){"number"==typeof e&&function(r,e,t,a,n){const o=n.animation,s=[`${t.axis}Min`,`${t.axis}Max`],l=r=>{const e=t.getDistanceFromCenterForValue(r),n=o.animateScale?0:e;return a?n:e};for(const t of s){const a=e[t];Array.isArray(a)?r[t]=a.map(l):"number"==typeof a&&(r[t]=l(a))}}(t,this.getParsed(e),this._cachedMeta.rScale,"reset"===a,this.chart.options),super.updateElement(r,e,t,a)}updateElements(r,e,t,a){const n=this.chart.scales.r,o=n.getDistanceFromCenterForValue;n.getDistanceFromCenterForValue=function(r){return"number"==typeof r?o.call(this,r):o.call(this,r.r)},super.updateElements(r,e,t,a),n.getDistanceFromCenterForValue=o}}R.id="polarAreaWithErrorBars",R.defaults=t.merge({},[e.PolarAreaController.defaults,E,{dataElementType:x.id}]),R.overrides=t.merge({},[e.PolarAreaController.overrides,{plugins:{tooltip:{callbacks:{label:function(r){const t=e.PolarAreaController.overrides.plugins.tooltip.callbacks.label.call(this,r),a=r.chart.data.datasets[r.datasetIndex].data[r.dataIndex],n=["rMin","rMax"];return null==a||n.every((r=>null==a[r]))?t:`${t} [${m(a[n[0]])} .. ${a[n[1]]}]`}}}}}]),R.defaultRoutes=e.PolarAreaController.defaultRoutes;class j extends e.Chart{constructor(r,t){super(r,A("polarAreaWithErrorBars",t,R,x,[e.RadialLinearScale]))}}j.id=R.id,e.registry.addControllers(S,P,R,$),e.registry.addElements(p,x,P,y),r.ArcWithErrorBar=x,r.BarWithErrorBar=p,r.BarWithErrorBarsChart=k,r.BarWithErrorBarsController=S,r.LineWithErrorBarsChart=T,r.LineWithErrorBarsController=P,r.PointWithErrorBar=y,r.PolarAreaWithErrorBarsChart=j,r.PolarAreaWithErrorBarsController=R,r.ScatterWithErrorBarsChart=L,r.ScatterWithErrorBarsController=$,Object.defineProperty(r,"__esModule",{value:!0})}));
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("chart.js"),require("chart.js/helpers")):"function"==typeof define&&define.amd?define(["exports","chart.js","chart.js/helpers"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self).ChartErrorBars={},r.Chart,r.Chart.helpers)}(this,(function(r,e,t){"use strict";const a=["xMin","xMax","yMin","yMax"];function n(r){return r?a.slice(0,2):a.slice(2)}function o(r,e,t,a,n){const o=[`${a.axis}Min`,`${a.axis}Max`],s=a.getBasePixel();for(const l of o){const o=e[l];Array.isArray(o)?r[l]=o.map((r=>n?s:a.getPixelForValue(r,t))):"number"==typeof o&&(r[l]=n?s:a.getPixelForValue(o,t))}}const s={errorBarLineWidth:{v:[1,3]},errorBarColor:{v:["#2c2c2c","#1f1f1f"]},errorBarWhiskerLineWidth:{v:[1,3]},errorBarWhiskerRatio:{v:[.2,.25]},errorBarWhiskerSize:{v:[20,24]},errorBarWhiskerColor:{v:["#2c2c2c","#1f1f1f"]}},l={_scriptable:!0,_indexable:r=>"v"!==r},i=Object.keys(s);function c(r,e){const t=Array.isArray(r)?r:[r],a=Array.isArray(e)?e:[e];if(t.length===a.length)return t.map(((r,e)=>[r,a[e]]));const n=Math.max(t.length,a.length);return Array(n).map(((r,e)=>[t[e%t.length],a[e%a.length]]))}function u(r,e){if("string"==typeof r||"number"==typeof r)return r;const t=Array.isArray(r)?r:r.v;return t[e%t.length]}function d(r,e,t){const a=u(e.errorBarWhiskerRatio,t);if(null!=r&&a>0)return r*a*.5;return.5*u(e.errorBarWhiskerSize,t)}function h(r,e){var t,a,n,o;const s=r.getProps(["x","y","width","height","xMin","xMax","yMin","yMax"]);null==s.xMin&&null==s.xMax||function(r,e,t,a,n){n.save(),n.translate(0,r.y);const o=c(null==e?r.x:e,null==t?r.x:t);o.reverse().forEach((([e,t],s)=>{const l=o.length-s-1,i=d(r.height,a,l);n.lineWidth=u(a.errorBarLineWidth,l),n.strokeStyle=u(a.errorBarColor,l),n.beginPath(),n.moveTo(e,0),n.lineTo(t,0),n.stroke(),n.lineWidth=u(a.errorBarWhiskerLineWidth,l),n.strokeStyle=u(a.errorBarWhiskerColor,l),n.beginPath(),n.moveTo(e,-i),n.lineTo(e,i),n.moveTo(t,-i),n.lineTo(t,i),n.stroke()})),n.restore()}(s,null!==(t=s.xMin)&&void 0!==t?t:null,null!==(a=s.xMax)&&void 0!==a?a:null,r.options,e),null==s.yMin&&null==s.yMax||function(r,e,t,a,n){n.save(),n.translate(r.x,0);const o=c(null==e?r.y:e,null==t?r.y:t);o.reverse().forEach((([e,t],s)=>{const l=o.length-s-1,i=d(r.width,a,l);n.lineWidth=u(a.errorBarLineWidth,l),n.strokeStyle=u(a.errorBarColor,l),n.beginPath(),n.moveTo(0,e),n.lineTo(0,t),n.stroke(),n.lineWidth=u(a.errorBarWhiskerLineWidth,l),n.strokeStyle=u(a.errorBarWhiskerColor,l),n.beginPath(),n.moveTo(-i,e),n.lineTo(i,e),n.moveTo(-i,t),n.lineTo(i,t),n.stroke()})),n.restore()}(s,null!==(n=s.yMin)&&void 0!==n?n:null,null!==(o=s.yMax)&&void 0!==o?o:null,r.options,e)}function f(r,e){const t=r.getProps(["x","y","startAngle","endAngle","rMin","rMax","outerRadius"]);null==t.rMin&&null==t.rMax||function(r,e,t,a,n){n.save(),n.translate(r.x,r.y);const o=(r.startAngle+r.endAngle)/2,s=Math.cos(o),l=Math.sin(o),i={x:-l,y:s},h=Math.sqrt(i.x*i.x+i.y*i.y);i.x/=h,i.y/=h;const f=c(null!=e?e:r.outerRadius,null!=t?t:r.outerRadius);f.reverse().forEach((([r,e],t)=>{const o=f.length-t-1,c=r*s,h=r*l,p=e*s,y=e*l,x=d(null,a,o),m=i.x*x,g=i.y*x;n.lineWidth=u(a.errorBarLineWidth,o),n.strokeStyle=u(a.errorBarColor,o),n.beginPath(),n.moveTo(c,h),n.lineTo(p,y),n.stroke(),n.lineWidth=u(a.errorBarWhiskerLineWidth,o),n.strokeStyle=u(a.errorBarWhiskerColor,o),n.beginPath(),n.moveTo(c+m,h+g),n.lineTo(c-m,h-g),n.moveTo(p+m,y+g),n.lineTo(p-m,y-g),n.stroke()})),n.restore()}(t,t.rMin,t.rMax,r.options,e)}class p extends e.BarElement{draw(r){super.draw(r),h(this,r)}}p.id="barWithErrorBar",p.defaults={...e.BarElement.defaults,...s},p.defaultRoutes=e.BarElement.defaultRoutes,p.descriptors=l;class y extends e.PointElement{draw(r,e){super.draw.call(this,r,e),h(this,r)}}y.id="pointWithErrorBar",y.defaults={...e.PointElement.defaults,...s},y.defaultRoutes=e.PointElement.defaultRoutes,y.descriptors=l;class x extends e.ArcElement{draw(r){super.draw(r),f(this,r)}}function m(r){return Array.isArray(r)?r.slice().reverse():r}function g(r){const t=n(r.element.horizontal),a=e.Tooltip.defaults.callbacks.label.call(this,r),o=r.chart.data.datasets[r.datasetIndex].data[r.dataIndex];return null==o||t.every((r=>null==o[r]))?a:`${a} (${m(o[t[0]])} .. ${o[t[1]]})`}x.id="arcWithErrorBar",x.defaults={...e.ArcElement.defaults,...s},x.defaultRoutes=e.ArcElement.defaultRoutes,x.descriptors=l;const M={color(r,e,a){const n=r||"transparent",o=e||"transparent";if(n===o)return e;const s=t.color(n),l=s.valid&&t.color(o);return l&&l.valid?l.mix(s,a).hexString():e},number:(r,e,t)=>r===e?e:r+(e-r)*t};function B(r,e,t,a,n){if(typeof r===a&&typeof e===a)return n(r,e,t);if(Array.isArray(r)&&Array.isArray(e))return r.map(((r,a)=>n(r,e[a],t)));const o=r=>r&&Array.isArray(r.v);return o(r)&&o(e)?{v:r.v.map(((r,a)=>n(r,e.v[a],t)))}:e}const b={animations:{numberArray:{fn:function(r,e,t){return B(r,e,t,"number",M.number)},properties:a.concat(i.filter((r=>!r.endsWith("Color"))),["rMin","rMax"])},colorArray:{fn:function(r,e,t){return B(r,e,t,"string",M.color)},properties:i.filter((r=>r.endsWith("Color")))}}};function E(r,e){const{axis:t}=r;r.axis=`${t}MinMin`;const{min:a}=e(r);r.axis=`${t}MaxMax`;const{max:n}=e(r);return r.axis=t,{min:a,max:n}}function v(r,e,t){return Array.isArray(e)?t(...e):"number"==typeof e?e:r}function C(r,e,t,a,n){const o="string"==typeof e?e:e.axis,s=`${o}Min`,l=`${o}Max`,i=`${o}MinMin`,c=`${o}MaxMax`;for(let e=0;e<n;e+=1){const n=e+a,u=r[e];u[s]=t[n][s],u[l]=t[n][l],u[i]=v(u[o],u[s],Math.min),u[c]=v(u[o],u[l],Math.max)}}function W(r,e,t,a){const{axis:n}=e,o=e.getLabels();for(let s=0;s<a;s+=1){const a=s+t;r[s][n]=e.parse(o[a],a)}}function A(r,t,a,n=[],o=[]){e.registry.addControllers(a),Array.isArray(n)?e.registry.addElements(...n):e.registry.addElements(n),Array.isArray(o)?e.registry.addScales(...o):e.registry.addScales(o);const s=t;return s.type=r,s}class S extends e.BarController{getMinMax(r,e){return E(r,(r=>super.getMinMax(r,e)))}parseObjectData(r,e,t,a){const n=super.parseObjectData(r,e,t,a);return C(n,r.vScale,e,t,a),W(n,r.iScale,t,a),n}updateElement(r,e,t,a){"number"==typeof e&&o(t,this.getParsed(e),e,this._cachedMeta.vScale,"reset"===a),super.updateElement(r,e,t,a)}}S.id="barWithErrorBars",S.defaults=t.merge({},[e.BarController.defaults,b,{dataElementType:p.id}]),S.overrides=t.merge({},[e.BarController.overrides,{plugins:{tooltip:{callbacks:{label:g}}}}]),S.defaultRoutes=e.BarController.defaultRoutes;class k extends e.Chart{constructor(r,t){super(r,A("barWithErrorBars",t,S,p,[e.LinearScale,e.CategoryScale]))}}k.id=S.id;class P extends e.LineController{getMinMax(r,e){return E(r,(r=>super.getMinMax(r,e)))}parseObjectData(r,e,t,a){const n=super.parseObjectData(r,e,t,a);return C(n,r.vScale,e,t,a),W(n,r.iScale,t,a),n}updateElement(r,e,t,a){r instanceof y&&"number"==typeof e&&o(t,this.getParsed(e),e,this._cachedMeta.vScale,"reset"===a),super.updateElement(r,e,t,a)}}P.id="lineWithErrorBars",P.defaults=t.merge({},[e.LineController.defaults,b,{dataElementType:y.id}]),P.overrides=t.merge({},[e.LineController.overrides,{plugins:{tooltip:{callbacks:{label:g}}}}]),P.defaultRoutes=e.LineController.defaultRoutes;class T extends e.Chart{constructor(r,t){super(r,A("lineWithErrorBars",t,P,y,[e.LinearScale,e.CategoryScale]))}}T.id=P.id;class $ extends e.ScatterController{getMinMax(r,e){return E(r,(r=>super.getMinMax(r,e)))}parseObjectData(r,e,t,a){const n=super.parseObjectData(r,e,t,a);return C(n,r.xScale,e,t,a),C(n,r.yScale,e,t,a),n}updateElement(r,e,t,a){r instanceof y&&"number"==typeof e&&(o(t,this.getParsed(e),e,this._cachedMeta.xScale,"reset"===a),o(t,this.getParsed(e),e,this._cachedMeta.yScale,"reset"===a)),super.updateElement(r,e,t,a)}}$.id="scatterWithErrorBars",$.defaults=t.merge({},[e.ScatterController.defaults,b,{dataElementType:y.id}]),$.overrides=t.merge({},[e.ScatterController.overrides,{plugins:{tooltip:{callbacks:{label:function(r){const e=r.chart.data.datasets[r.datasetIndex].data[r.dataIndex],t=(r,t)=>{const a=n(t);return null==e||a.every((r=>null==e[r]))?r:`${r} [${m(e[a[0]])} .. ${e[a[1]]}]`};return`(${t(r.label,!0)}, ${t(r.parsed.y,!1)})`}}}}}]),$.defaultRoutes=e.LineController.defaultRoutes;class L extends e.Chart{constructor(r,t){super(r,A("scatterWithErrorBars",t,$,y,[e.LinearScale]))}}L.id=$.id;class R extends e.PolarAreaController{getMinMax(r,e){return E(r,(r=>super.getMinMax(r,e)))}countVisibleElements(){const r=this._cachedMeta;return r.data.reduce(((e,t,a)=>!Number.isNaN(r._parsed[a].r)&&this.chart.getDataVisibility(a)?e+1:e),0)}parseObjectData(r,e,t,a){const n=new Array(a),o=r.rScale;for(let r=0;r<a;r+=1){const a=r+t,s=e[a],l=o.parse(s[o.axis],a);n[r]={[o.axis]:l}}return C(n,o,e,t,a),n}updateElement(r,e,t,a){"number"==typeof e&&function(r,e,t,a,n){const o=n.animation,s=[`${t.axis}Min`,`${t.axis}Max`],l=r=>{const e=t.getDistanceFromCenterForValue(r),n=o.animateScale?0:e;return a?n:e};for(const t of s){const a=e[t];Array.isArray(a)?r[t]=a.map(l):"number"==typeof a&&(r[t]=l(a))}}(t,this.getParsed(e),this._cachedMeta.rScale,"reset"===a,this.chart.options),super.updateElement(r,e,t,a)}updateElements(r,e,t,a){const n=this.chart.scales.r,o=n.getDistanceFromCenterForValue;n.getDistanceFromCenterForValue=function(r){return"number"==typeof r?o.call(this,r):o.call(this,r.r)},super.updateElements(r,e,t,a),n.getDistanceFromCenterForValue=o}}R.id="polarAreaWithErrorBars",R.defaults=t.merge({},[e.PolarAreaController.defaults,b,{dataElementType:x.id}]),R.overrides=t.merge({},[e.PolarAreaController.overrides,{plugins:{tooltip:{callbacks:{label:function(r){const t=e.PolarAreaController.overrides.plugins.tooltip.callbacks.label.call(this,r),a=r.chart.data.datasets[r.datasetIndex].data[r.dataIndex],n=["rMin","rMax"];return null==a||n.every((r=>null==a[r]))?t:`${t} [${m(a[n[0]])} .. ${a[n[1]]}]`}}}}}]),R.defaultRoutes=e.PolarAreaController.defaultRoutes;class j extends e.Chart{constructor(r,t){super(r,A("polarAreaWithErrorBars",t,R,x,[e.RadialLinearScale]))}}j.id=R.id,e.registry.addControllers(S,P,R,$),e.registry.addElements(p,x,P,y),r.ArcWithErrorBar=x,r.BarWithErrorBar=p,r.BarWithErrorBarsChart=k,r.BarWithErrorBarsController=S,r.LineWithErrorBarsChart=T,r.LineWithErrorBarsController=P,r.PointWithErrorBar=y,r.PolarAreaWithErrorBarsChart=j,r.PolarAreaWithErrorBarsController=R,r.ScatterWithErrorBarsChart=L,r.ScatterWithErrorBarsController=$,Object.defineProperty(r,"__esModule",{value:!0})}));
//# sourceMappingURL=index.umd.min.js.map
{
"name": "chartjs-chart-error-bars",
"description": "Chart.js module for charting error bars",
"version": "3.6.0",
"version": "3.7.0",
"author": {

@@ -36,3 +36,3 @@ "name": "Samuel Gratzl",

"peerDependencies": {
"chart.js": "^3.6.0"
"chart.js": "^3.7.0"
},

@@ -46,36 +46,36 @@ "browserslist": [

"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "^13.0.6",
"@rollup/plugin-replace": "^3.0.0",
"@rollup/plugin-node-resolve": "^13.1.3",
"@rollup/plugin-replace": "^3.0.1",
"@rollup/plugin-typescript": "^8.3.0",
"@types/jest": "^27.0.2",
"@types/jest": "^27.4.0",
"@types/jest-image-snapshot": "^4.3.1",
"@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "^5.3.0",
"@typescript-eslint/parser": "^5.3.0",
"@types/node": "^17.0.16",
"@typescript-eslint/eslint-plugin": "^5.11.0",
"@typescript-eslint/parser": "^5.11.0",
"@yarnpkg/sdks": "^2.5.0",
"canvas": "^2.8.0",
"canvas": "^2.9.0",
"canvas-5-polyfill": "^0.1.5",
"chart.js": "^3.6.0",
"eslint": "^8.1.0",
"eslint-config-airbnb-typescript": "^14.0.1",
"chart.js": "^3.7.0",
"eslint": "^8.8.0",
"eslint-config-airbnb-typescript": "^16.1.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-react-app": "^6.0.0",
"eslint-config-react-app": "^7.0.0",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-react-hooks": "^4.2.0",
"jest": "^27.3.1",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"jest": "^27.5.1",
"jest-image-snapshot": "^4.5.1",
"prettier": "^2.4.1",
"prettier": "^2.5.1",
"rimraf": "^3.0.2",
"rollup": "^2.59.0",
"rollup": "^2.67.1",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-dts": "^4.0.0",
"rollup-plugin-dts": "^4.1.0",
"rollup-plugin-terser": "^7.0.2",
"ts-jest": "^27.0.7",
"ts-jest": "^27.1.3",
"tslib": "^2.3.1",
"typedoc": "^0.22.7",
"typescript": "^4.4.4"
"typedoc": "^0.22.11",
"typescript": "^4.5.5"
},

@@ -92,2 +92,3 @@ "scripts": {

"test:coverage": "jest --passWithNoTests --coverage",
"samples": "yarn tsc samples/type_test.ts",
"lint": "yarn run eslint && yarn run prettier",

@@ -102,3 +103,3 @@ "fix": "yarn run eslint:fix && yarn run prettier:write",

},
"packageManager": "yarn@3.1.0"
"packageManager": "yarn@3.1.1"
}

@@ -121,7 +121,7 @@ # Chart.js Error Bars

```js
import Chart from 'chart.js';
import { BarWithErrorBarsController, RectangleWithErrorBar } from 'chartjs-chart-error-bars';
import Chart, { LinearScale, CategoryScale } from 'chart.js';
import { BarWithErrorBarsController, BarWithErrorBar } from 'chartjs-chart-error-bars';
// register controller in chart.js and ensure the defaults are set
Chart.register(BarWithErrorBarsController, RectangleWithErrorBar);
Chart.register(BarWithErrorBarsController, BarWithErrorBar, LinearScale, CategoryScale);

@@ -128,0 +128,0 @@ const chart = new Chart(document.getElementById('canvas').getContext('2d'), {

import { ArcElement } from 'chart.js';
import { renderErrorBarArc, errorBarDefaults, errorBarDescriptors } from './render';
import { renderErrorBarArc, errorBarDefaults, errorBarDescriptors, IErrorBarOptions } from './render';

@@ -19,1 +19,10 @@ export default class ArcWithErrorBar extends ArcElement {

}
declare module 'chart.js' {
export interface ElementOptionsByType<TType extends ChartType> {
arcWithErrorBar: ScriptableAndArrayOptions<
IErrorBarOptions & ArcOptions & ArcHoverOptions,
ScriptableContext<TType>
>;
}
}
import { BarElement } from 'chart.js';
import { renderErrorBar, errorBarDefaults, errorBarDescriptors } from './render';
import { renderErrorBar, errorBarDefaults, errorBarDescriptors, IErrorBarOptions } from './render';

@@ -11,3 +11,3 @@ export default class BarWithErrorBar extends BarElement {

static readonly id = 'rectangleWithErrorBar';
static readonly id = 'barWithErrorBar';

@@ -20,1 +20,10 @@ static readonly defaults: any = /* #__PURE__ */ { ...BarElement.defaults, ...errorBarDefaults };

}
declare module 'chart.js' {
export interface ElementOptionsByType<TType extends ChartType> {
barWithErrorBar: ScriptableAndArrayOptions<
IErrorBarOptions & BarOptions & BarHoverOptions,
ScriptableContext<TType>
>;
}
}
import { PointElement } from 'chart.js';
import { renderErrorBar, errorBarDefaults, errorBarDescriptors } from './render';
import { renderErrorBar, errorBarDefaults, errorBarDescriptors, IErrorBarOptions } from './render';

@@ -20,1 +20,10 @@ export default class PointWithErrorBar extends PointElement {

}
declare module 'chart.js' {
export interface ElementOptionsByType<TType extends ChartType> {
pointWithErrorBar: ScriptableAndArrayOptions<
IErrorBarOptions & PointOptions & PointHoverOptions,
ScriptableContext<TType>
>;
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc