New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.0.0-rc.0 to 3.0.0

13

build/index.cjs.js

@@ -23,2 +23,6 @@ /**

};
const errorBarDescriptors = {
_scriptable: true,
_indexable: (name) => name !== 'v',
};
const styleKeys = Object.keys(errorBarDefaults);

@@ -162,2 +166,3 @@ function resolveMulti(vMin, vMax) {

BarWithErrorBar.defaultRoutes = chart_js.BarElement.defaultRoutes;
BarWithErrorBar.descriptors = errorBarDescriptors;

@@ -173,2 +178,3 @@ class PointWithErrorBar extends chart_js.PointElement {

PointWithErrorBar.defaultRoutes = chart_js.PointElement.defaultRoutes;
PointWithErrorBar.descriptors = errorBarDescriptors;

@@ -184,2 +190,3 @@ class ArcWithErrorBar extends chart_js.ArcElement {

ArcWithErrorBar.defaultRoutes = chart_js.ArcElement.defaultRoutes;
ArcWithErrorBar.descriptors = errorBarDescriptors;

@@ -284,4 +291,4 @@ const allModelKeys = ['xMin', 'xMax', 'yMin', 'yMax'];

const isV = (t) => t && Array.isArray(t.v);
if (isV(from) && Array.isArray(from.v) && isV(to)) {
return from.v.map((f, i) => interpolator(f, to.v[i], factor));
if (isV(from) && isV(to)) {
return { v: from.v.map((f, i) => interpolator(f, to.v[i], factor)) };
}

@@ -304,3 +311,3 @@ return to;

fn: interpolateColorOptionArray,
properties: allModelKeys.concat(styleKeys.filter((d) => d.endsWith('Color'))),
properties: styleKeys.filter((d) => d.endsWith('Color')),
},

@@ -307,0 +314,0 @@ },

@@ -8,3 +8,3 @@ /**

import { BarElement, PointElement, ArcElement, BarController, Scale, ChartMeta, UpdateMode, BarControllerDatasetOptions, ScriptableAndArrayOptions, ScriptableContext, BarControllerChartOptions, CartesianScaleTypeRegistry, Chart, ChartItem, ChartConfiguration, LineController, LineControllerDatasetOptions, LineControllerChartOptions, ScatterController, ScatterControllerDatasetOptions, ScatterControllerChartOptions, PolarAreaController, Element, PolarAreaControllerDatasetOptions, PolarAreaControllerChartOptions } from 'chart.js';
import { BarElement, PointElement, ArcElement, BarController, Scale, ChartMeta, UpdateMode, BarControllerDatasetOptions, ScriptableAndArrayOptions, ScriptableContext, Chart, ChartItem, ChartConfiguration, LineController, LineControllerDatasetOptions, ScatterController, ScatterControllerDatasetOptions, PolarAreaController, Element, PolarAreaControllerDatasetOptions } from 'chart.js';

@@ -18,2 +18,6 @@ declare class BarWithErrorBar extends BarElement {

} | undefined;
static readonly descriptors: {
_scriptable: boolean;
_indexable: (name: string) => boolean;
};
}

@@ -28,2 +32,6 @@

} | undefined;
static readonly descriptors: {
_scriptable: boolean;
_indexable: (name: string) => boolean;
};
}

@@ -38,2 +46,6 @@

} | undefined;
static readonly descriptors: {
_scriptable: boolean;
_indexable: (name: string) => boolean;
};
}

@@ -158,4 +170,5 @@

datasetOptions: BarWithErrorBarsControllerDatasetOptions;
defaultDataPoint: IErrorBarXDataPoint[];
defaultDataPoint: IErrorBarXDataPoint;
scales: keyof CartesianScaleTypeRegistry;
parsedDataType: IErrorBarXDataPoint & ChartTypeRegistry['bar']['parsedDataType'];
};

@@ -190,4 +203,5 @@ }

datasetOptions: LineWithErrorBarsControllerDatasetOptions;
defaultDataPoint: IErrorBarXDataPoint[];
defaultDataPoint: IErrorBarXDataPoint;
scales: keyof CartesianScaleTypeRegistry;
parsedDataType: IErrorBarXDataPoint & ChartTypeRegistry['line']['parsedDataType'];
};

@@ -222,4 +236,5 @@ }

datasetOptions: ScatterWithErrorBarsControllerDatasetOptions;
defaultDataPoint: IErrorBarXYDataPoint[];
defaultDataPoint: IErrorBarXYDataPoint;
scales: keyof CartesianScaleTypeRegistry;
parsedDataType: IErrorBarXYDataPoint & ChartTypeRegistry['scatter']['parsedDataType'];
};

@@ -256,4 +271,5 @@ }

datasetOptions: PolarAreaWithErrorBarsControllerDatasetOptions;
defaultDataPoint: IErrorBarRDataPoint[];
defaultDataPoint: IErrorBarRDataPoint;
scales: keyof CartesianScaleTypeRegistry;
parsedDataType: IErrorBarRDataPoint & ChartTypeRegistry['polarArea']['parsedDataType'];
};

@@ -260,0 +276,0 @@ }

@@ -19,2 +19,6 @@ /**

};
const errorBarDescriptors = {
_scriptable: true,
_indexable: (name) => name !== 'v',
};
const styleKeys = Object.keys(errorBarDefaults);

@@ -158,2 +162,3 @@ function resolveMulti(vMin, vMax) {

BarWithErrorBar.defaultRoutes = BarElement.defaultRoutes;
BarWithErrorBar.descriptors = errorBarDescriptors;

@@ -169,2 +174,3 @@ class PointWithErrorBar extends PointElement {

PointWithErrorBar.defaultRoutes = PointElement.defaultRoutes;
PointWithErrorBar.descriptors = errorBarDescriptors;

@@ -180,2 +186,3 @@ class ArcWithErrorBar extends ArcElement {

ArcWithErrorBar.defaultRoutes = ArcElement.defaultRoutes;
ArcWithErrorBar.descriptors = errorBarDescriptors;

@@ -280,4 +287,4 @@ const allModelKeys = ['xMin', 'xMax', 'yMin', 'yMax'];

const isV = (t) => t && Array.isArray(t.v);
if (isV(from) && Array.isArray(from.v) && isV(to)) {
return from.v.map((f, i) => interpolator(f, to.v[i], factor));
if (isV(from) && isV(to)) {
return { v: from.v.map((f, i) => interpolator(f, to.v[i], factor)) };
}

@@ -300,3 +307,3 @@ return to;

fn: interpolateColorOptionArray,
properties: allModelKeys.concat(styleKeys.filter((d) => d.endsWith('Color'))),
properties: styleKeys.filter((d) => d.endsWith('Color')),
},

@@ -303,0 +310,0 @@ },

@@ -61,2 +61,6 @@ /**

};
const errorBarDescriptors = {
_scriptable: true,
_indexable: (name) => name !== 'v',
};
const styleKeys = Object.keys(errorBarDefaults);

@@ -200,2 +204,3 @@ function resolveMulti(vMin, vMax) {

BarWithErrorBar.defaultRoutes = chart_js.BarElement.defaultRoutes;
BarWithErrorBar.descriptors = errorBarDescriptors;

@@ -211,2 +216,3 @@ class PointWithErrorBar extends chart_js.PointElement {

PointWithErrorBar.defaultRoutes = chart_js.PointElement.defaultRoutes;
PointWithErrorBar.descriptors = errorBarDescriptors;

@@ -222,2 +228,3 @@ class ArcWithErrorBar extends chart_js.ArcElement {

ArcWithErrorBar.defaultRoutes = chart_js.ArcElement.defaultRoutes;
ArcWithErrorBar.descriptors = errorBarDescriptors;

@@ -283,4 +290,4 @@ function reverseOrder(v) {

const isV = (t) => t && Array.isArray(t.v);
if (isV(from) && Array.isArray(from.v) && isV(to)) {
return from.v.map((f, i) => interpolator(f, to.v[i], factor));
if (isV(from) && isV(to)) {
return { v: from.v.map((f, i) => interpolator(f, to.v[i], factor)) };
}

@@ -303,3 +310,3 @@ return to;

fn: interpolateColorOptionArray,
properties: allModelKeys.concat(styleKeys.filter((d) => d.endsWith('Color'))),
properties: styleKeys.filter((d) => d.endsWith('Color')),
},

@@ -306,0 +313,0 @@ },

@@ -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=Object.keys(s);function i(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 c(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 u(r,e,t){const a=c(e.errorBarWhiskerRatio,t);if(null!=r&&a>0)return r*a*.5;return.5*c(e.errorBarWhiskerSize,t)}function d(r,e){const t=r.getProps(["x","y","width","height","xMin","xMax","yMin","yMax"]);null==t.xMin&&null==t.xMax||function(r,e,t,a,n){n.save(),n.translate(0,r.y);const o=i(null==e?r.x:e,null==t?r.x:t);o.reverse().forEach(([e,t],s)=>{const l=o.length-s-1,i=u(r.height,a,l);n.lineWidth=c(a.errorBarLineWidth,l),n.strokeStyle=c(a.errorBarColor,l),n.beginPath(),n.moveTo(e,0),n.lineTo(t,0),n.stroke(),n.lineWidth=c(a.errorBarWhiskerLineWidth,l),n.strokeStyle=c(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()}(t,t.xMin??null,t.xMax??null,r.options,e),null==t.yMin&&null==t.yMax||function(r,e,t,a,n){n.save(),n.translate(r.x,0);const o=i(null==e?r.y:e,null==t?r.y:t);o.reverse().forEach(([e,t],s)=>{const l=o.length-s-1,i=u(r.width,a,l);n.lineWidth=c(a.errorBarLineWidth,l),n.strokeStyle=c(a.errorBarColor,l),n.beginPath(),n.moveTo(0,e),n.lineTo(0,t),n.stroke(),n.lineWidth=c(a.errorBarWhiskerLineWidth,l),n.strokeStyle=c(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()}(t,t.yMin??null,t.yMax??null,r.options,e)}function h(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),d={x:-l,y:s},h=Math.sqrt(d.x*d.x+d.y*d.y);d.x/=h,d.y/=h;const f=i(e??r.outerRadius,t??r.outerRadius);f.reverse().forEach(([r,e],t)=>{const o=f.length-t-1,i=r*s,h=r*l,p=e*s,y=e*l,x=u(null,a,o),m=d.x*x,g=d.y*x;n.lineWidth=c(a.errorBarLineWidth,o),n.strokeStyle=c(a.errorBarColor,o),n.beginPath(),n.moveTo(i,h),n.lineTo(p,y),n.stroke(),n.lineWidth=c(a.errorBarWhiskerLineWidth,o),n.strokeStyle=c(a.errorBarWhiskerColor,o),n.beginPath(),n.moveTo(i+m,h+g),n.lineTo(i-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 f extends e.BarElement{draw(r){super.draw(r),d(this,r)}}f.id="rectangleWithErrorBar",f.defaults={...e.BarElement.defaults,...s},f.defaultRoutes=e.BarElement.defaultRoutes;class p extends e.PointElement{draw(r){super.draw(r),d(this,r)}}p.id="pointWithErrorBar",p.defaults={...e.PointElement.defaults,...s},p.defaultRoutes=e.PointElement.defaultRoutes;class y extends e.ArcElement{draw(r){super.draw(r),h(this,r)}}function x(r){return Array.isArray(r)?r.slice().reverse():r}function m(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} (${x(o[t[0]])} .. ${o[t[1]]})`}y.id="arcWithErrorBar",y.defaults={...e.ArcElement.defaults,...s},y.defaultRoutes=e.ArcElement.defaultRoutes;const g={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 M(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)&&Array.isArray(r.v)&&o(e)?r.v.map((r,a)=>n(r,e.v[a],t)):e}const B={animations:{numberArray:{fn:function(r,e,t){return M(r,e,t,"number",g.number)},properties:a.concat(l.filter(r=>!r.endsWith("Color")),["rMin","rMax"])},colorArray:{fn:function(r,e,t){return M(r,e,t,"string",g.color)},properties:a.concat(l.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 b(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]=b(u[o],u[s],Math.min),u[c]=b(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 v 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)}}v.id="barWithErrorBars",v.defaults=t.merge({},[e.BarController.defaults,B,{dataElementType:f.id}]),v.overrides=t.merge({},[e.BarController.overrides,{plugins:{tooltip:{callbacks:{label:m}}}}]),v.defaultRoutes=e.BarController.defaultRoutes;class S extends e.Chart{constructor(r,t){super(r,A("barWithErrorBars",t,v,f,[e.LinearScale,e.CategoryScale]))}}S.id=v.id;class k 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 p&&"number"==typeof e&&o(t,this.getParsed(e),e,this._cachedMeta.vScale,"reset"===a),super.updateElement(r,e,t,a)}}k.id="lineWithErrorBars",k.defaults=t.merge({},[e.LineController.defaults,B,{dataElementType:p.id}]),k.overrides=t.merge({},[e.LineController.overrides,{plugins:{tooltip:{callbacks:{label:m}}}}]),k.defaultRoutes=e.LineController.defaultRoutes;class P extends e.Chart{constructor(r,t){super(r,A("lineWithErrorBars",t,k,p,[e.LinearScale,e.CategoryScale]))}}P.id=k.id;class T 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 p&&"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)}}T.id="scatterWithErrorBars",T.defaults=t.merge({},[e.ScatterController.defaults,B,{dataElementType:p.id}]),T.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} [${x(e[a[0]])} .. ${e[a[1]]}]`};return`(${t(r.label,!0)}, ${t(r.parsed.y,!1)})`}}}}}]),T.defaultRoutes=e.LineController.defaultRoutes;class L extends e.Chart{constructor(r,t){super(r,A("scatterWithErrorBars",t,T,p,[e.LinearScale]))}}L.id=T.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:y.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} [${x(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,y,[e.RadialLinearScale]))}}j.id=R.id,e.registry.addControllers(v,k,R,T),e.registry.addElements(f,y,k,p),r.ArcWithErrorBar=y,r.BarWithErrorBar=f,r.BarWithErrorBarsChart=S,r.BarWithErrorBarsController=v,r.LineWithErrorBarsChart=P,r.LineWithErrorBarsController=k,r.PointWithErrorBar=p,r.PolarAreaWithErrorBarsChart=j,r.PolarAreaWithErrorBarsController=R,r.ScatterWithErrorBarsChart=L,r.ScatterWithErrorBarsController=T,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){const t=r.getProps(["x","y","width","height","xMin","xMax","yMin","yMax"]);null==t.xMin&&null==t.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()}(t,t.xMin??null,t.xMax??null,r.options,e),null==t.yMin&&null==t.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()}(t,t.yMin??null,t.yMax??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(e??r.outerRadius,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){super.draw(r),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 C(r,e,t){return Array.isArray(e)?t(...e):"number"==typeof e?e:r}function W(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]=C(u[o],u[s],Math.min),u[c]=C(u[o],u[l],Math.max)}}function v(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 W(n,r.vScale,e,t,a),v(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 W(n,r.vScale,e,t,a),v(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 W(n,r.xScale,e,t,a),W(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 W(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})}));
//# sourceMappingURL=index.umd.min.js.map
{
"name": "chartjs-chart-error-bars",
"description": "Chart.js module for charting error bars",
"version": "3.0.0-rc.0",
"version": "3.0.0",
"author": {

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

"peerDependencies": {
"chart.js": "^3.0.0-rc"
"chart.js": "^3.0.2"
},

@@ -45,16 +45,16 @@ "browserslist": [

"devDependencies": {
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"@rollup/plugin-replace": "^2.4.1",
"@rollup/plugin-typescript": "^8.2.0",
"@types/jest": "^26.0.21",
"@rollup/plugin-commonjs": "^18.0.0",
"@rollup/plugin-node-resolve": "^11.2.1",
"@rollup/plugin-replace": "^2.4.2",
"@rollup/plugin-typescript": "^8.2.1",
"@types/jest": "^26.0.22",
"@types/jest-image-snapshot": "^4.3.0",
"@types/node": "^14.14.35",
"@typescript-eslint/eslint-plugin": "^4.18.0",
"@typescript-eslint/parser": "^4.18.0",
"@types/node": "^14.14.37",
"@typescript-eslint/eslint-plugin": "^4.20.0",
"@typescript-eslint/parser": "^4.20.0",
"@yarnpkg/pnpify": "^2.4.0",
"canvas": "^2.7.0",
"canvas-5-polyfill": "^0.1.5",
"chart.js": "^3.0.0-rc",
"eslint": "^7.22.0",
"chart.js": "^3.0.2",
"eslint": "^7.23.0",
"eslint-config-airbnb-typescript": "^12.3.1",

@@ -67,10 +67,10 @@ "eslint-config-prettier": "^8.1.0",

"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react": "^7.23.1",
"eslint-plugin-react-hooks": "^4.2.0",
"jest": "^26.6.3",
"jest-image-snapshot": "^4.4.0",
"jest-image-snapshot": "^4.4.1",
"prettier": "^2.2.1",
"release-it": "^14.5.0",
"release-it": "^14.5.1",
"rimraf": "^3.0.2",
"rollup": "^2.42.1",
"rollup": "^2.44.0",
"rollup-plugin-cleanup": "^3.2.1",

@@ -81,3 +81,3 @@ "rollup-plugin-dts": "^3.0.1",

"tslib": "^2.1.0",
"typedoc": "^0.20.32",
"typedoc": "^0.20.35",
"typescript": "^4.2.3"

@@ -84,0 +84,0 @@ },

@@ -33,3 +33,3 @@ # Chart.js Error Bars

```bash
npm install --save chart.js@next chartjs-chart-error-bars@next
npm install --save chart.js chartjs-chart-error-bars
```

@@ -36,0 +36,0 @@

@@ -44,4 +44,4 @@ import { color } from 'chart.js/helpers';

if (isV(from) && Array.isArray(from.v) && isV(to)) {
return from.v.map((f, i) => interpolator(f, to.v[i], factor));
if (isV(from) && isV(to)) {
return { v: from.v.map((f, i) => interpolator(f, to.v[i], factor)) };
}

@@ -78,3 +78,3 @@ return to;

fn: interpolateColorOptionArray,
properties: allModelKeys.concat(styleKeys.filter((d) => d.endsWith('Color'))),
properties: styleKeys.filter((d) => d.endsWith('Color')),
},

@@ -81,0 +81,0 @@ },

@@ -15,8 +15,6 @@ import {

BarControllerDatasetOptions,
CartesianScaleTypeRegistry,
BarControllerChartOptions,
} from 'chart.js';
import { merge } from 'chart.js/helpers';
import { calculateScale } from './utils';
import { IErrorBarOptions } from '../elements/render';
import type { IErrorBarOptions } from '../elements/render';
import { BarWithErrorBar } from '../elements';

@@ -98,4 +96,5 @@ import { generateBarTooltip } from './tooltip';

datasetOptions: BarWithErrorBarsControllerDatasetOptions;
defaultDataPoint: IErrorBarXDataPoint[];
defaultDataPoint: IErrorBarXDataPoint;
scales: keyof CartesianScaleTypeRegistry;
parsedDataType: IErrorBarXDataPoint & ChartTypeRegistry['bar']['parsedDataType'];
};

@@ -102,0 +101,0 @@ }

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

import { Scale } from 'chart.js';
import type { Scale } from 'chart.js';

@@ -3,0 +3,0 @@ export interface IErrorBarXDataPoint {

@@ -14,4 +14,2 @@ import {

UpdateMode,
CartesianScaleTypeRegistry,
LineControllerChartOptions,
ScriptableContext,

@@ -21,3 +19,3 @@ } from 'chart.js';

import { calculateScale } from './utils';
import { IErrorBarOptions } from '../elements/render';
import type { IErrorBarOptions } from '../elements/render';
import { PointWithErrorBar } from '../elements';

@@ -100,4 +98,5 @@ import { generateBarTooltip } from './tooltip';

datasetOptions: LineWithErrorBarsControllerDatasetOptions;
defaultDataPoint: IErrorBarXDataPoint[];
defaultDataPoint: IErrorBarXDataPoint;
scales: keyof CartesianScaleTypeRegistry;
parsedDataType: IErrorBarXDataPoint & ChartTypeRegistry['line']['parsedDataType'];
};

@@ -104,0 +103,0 @@ }

@@ -13,4 +13,2 @@ import {

ScriptableAndArrayOptions,
PolarAreaControllerChartOptions,
CartesianScaleTypeRegistry,
ScriptableContext,

@@ -24,3 +22,3 @@ } from 'chart.js';

import { ArcWithErrorBar } from '../elements';
import { IErrorBarOptions } from '../elements/render';
import type { IErrorBarOptions } from '../elements/render';
import patchController from './patchController';

@@ -140,4 +138,5 @@

datasetOptions: PolarAreaWithErrorBarsControllerDatasetOptions;
defaultDataPoint: IErrorBarRDataPoint[];
defaultDataPoint: IErrorBarRDataPoint;
scales: keyof CartesianScaleTypeRegistry;
parsedDataType: IErrorBarRDataPoint & ChartTypeRegistry['polarArea']['parsedDataType'];
};

@@ -144,0 +143,0 @@ }

@@ -14,4 +14,2 @@ import {

LineController,
ScatterControllerChartOptions,
CartesianScaleTypeRegistry,
ScriptableContext,

@@ -25,3 +23,3 @@ } from 'chart.js';

import { PointWithErrorBar } from '../elements';
import { IErrorBarOptions } from '../elements/render';
import type { IErrorBarOptions } from '../elements/render';
import patchController from './patchController';

@@ -101,4 +99,5 @@

datasetOptions: ScatterWithErrorBarsControllerDatasetOptions;
defaultDataPoint: IErrorBarXYDataPoint[];
defaultDataPoint: IErrorBarXYDataPoint;
scales: keyof CartesianScaleTypeRegistry;
parsedDataType: IErrorBarXYDataPoint & ChartTypeRegistry['scatter']['parsedDataType'];
};

@@ -105,0 +104,0 @@ }

import { Tooltip, PolarAreaController, TooltipItem, TooltipModel } from 'chart.js';
import { modelKeys } from './utils';
import { IErrorBarRDataPoint, IErrorBarXYDataPoint } from './base';
import type { IErrorBarRDataPoint, IErrorBarXYDataPoint } from './base';

@@ -5,0 +5,0 @@ function reverseOrder<T>(v: T | T[]) {

@@ -1,3 +0,3 @@

import { LinearScale, RadialLinearScale } from 'chart.js';
import { IErrorBarRDataPoint, IErrorBarXYDataPoint } from './base';
import type { LinearScale, RadialLinearScale } from 'chart.js';
import type { IErrorBarRDataPoint, IErrorBarXYDataPoint } from './base';

@@ -4,0 +4,0 @@ export const allModelKeys = ['xMin', 'xMax', 'yMin', 'yMax'];

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

@@ -16,2 +16,4 @@ export default class ArcWithErrorBar extends ArcElement {

static readonly defaultRoutes = ArcElement.defaultRoutes;
static readonly descriptors = errorBarDescriptors;
}
import { BarElement } from 'chart.js';
import { renderErrorBar, errorBarDefaults } from './render';
import { renderErrorBar, errorBarDefaults, errorBarDescriptors } from './render';

@@ -16,2 +16,4 @@ export default class BarWithErrorBar extends BarElement {

static readonly defaultRoutes = BarElement.defaultRoutes;
static readonly descriptors = errorBarDescriptors;
}
import { PointElement } from 'chart.js';
import { renderErrorBar, errorBarDefaults } from './render';
import { renderErrorBar, errorBarDefaults, errorBarDescriptors } from './render';

@@ -16,2 +16,4 @@ export default class PointWithErrorBar extends PointElement {

static readonly defaultRoutes = PointElement.defaultRoutes;
static readonly descriptors = errorBarDescriptors;
}

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

import { Element, ArcProps } from 'chart.js';
import type { Element, ArcProps } from 'chart.js';

@@ -12,2 +12,7 @@ export const errorBarDefaults = {

export const errorBarDescriptors = /* #__PURE__ */ {
_scriptable: true,
_indexable: (name: string): boolean => name !== 'v',
};
export interface IErrorBarOptions {

@@ -14,0 +19,0 @@ /**

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