@sgratzl/chartjs-chart-boxplot
Advanced tools
Comparing version 3.0.0-beta.4 to 3.0.0-beta.6
@@ -8,5 +8,5 @@ /** | ||
import { TooltipModel, Element, BarController, Scale, IChartMeta, UpdateMode, IControllerDatasetOptions, ScriptableAndArrayOptions, ICommonHoverOptions, ICartesianScaleTypeRegistry, Chart, ChartItem, IChartConfiguration } from 'chart.js'; | ||
import { TooltipModel, Element, BarController, Scale, ChartMeta, UpdateMode, ControllerDatasetOptions, ScriptableAndArrayOptions, CommonHoverOptions, CartesianScaleTypeRegistry, Chart, ChartItem, ChartConfiguration } from 'chart.js'; | ||
interface IExtendedTooltip extends TooltipModel { | ||
interface ExtendedTooltip extends TooltipModel { | ||
_tooltipOutlier?: { | ||
@@ -154,3 +154,3 @@ index: number; | ||
y: number; | ||
} | boolean, tooltip?: IExtendedTooltip): { | ||
} | boolean, tooltip?: ExtendedTooltip): { | ||
x: number; | ||
@@ -313,5 +313,5 @@ y: number; | ||
}; | ||
parsePrimitiveData(meta: IChartMeta, data: any[], start: number, count: number): any[]; | ||
parseArrayData(meta: IChartMeta, data: any[], start: number, count: number): any[]; | ||
parseObjectData(meta: IChartMeta, data: any[], start: number, count: number): any[]; | ||
parsePrimitiveData(meta: ChartMeta, data: any[], start: number, count: number): any[]; | ||
parseArrayData(meta: ChartMeta, data: any[], start: number, count: number): any[]; | ||
parseObjectData(meta: ChartMeta, data: any[], start: number, count: number): any[]; | ||
protected abstract _parseStats(value: any, config: C): S; | ||
@@ -331,23 +331,20 @@ getLabelAndValue(index: number): any; | ||
} | ||
interface IBoxPlotControllerDatasetOptions extends IControllerDatasetOptions, IBoxplotOptions, ScriptableAndArrayOptions<IBoxAndWhiskersOptions>, ScriptableAndArrayOptions<ICommonHoverOptions> { | ||
interface BoxPlotControllerDatasetOptions extends ControllerDatasetOptions, IBoxplotOptions, ScriptableAndArrayOptions<IBoxAndWhiskersOptions>, ScriptableAndArrayOptions<CommonHoverOptions> { | ||
} | ||
declare type IBoxPlotDataPoint = number[] | (Partial<IBoxPlot> & IBaseStats); | ||
declare type BoxPlotDataPoint = number[] | (Partial<IBoxPlot> & IBaseStats); | ||
interface IBoxPlotChartOptions { | ||
} | ||
declare module 'chart.js' { | ||
enum ChartTypeEnum { | ||
boxplot = "boxplot" | ||
} | ||
interface IChartTypeRegistry { | ||
interface ChartTypeRegistry { | ||
boxplot: { | ||
chartOptions: IBoxPlotChartOptions; | ||
datasetOptions: IBoxPlotControllerDatasetOptions; | ||
defaultDataPoint: IBoxPlotDataPoint[]; | ||
scales: keyof ICartesianScaleTypeRegistry; | ||
datasetOptions: BoxPlotControllerDatasetOptions; | ||
defaultDataPoint: BoxPlotDataPoint[]; | ||
scales: keyof CartesianScaleTypeRegistry; | ||
}; | ||
} | ||
} | ||
declare class BoxPlotChart<DATA extends unknown[] = IBoxPlotDataPoint[], LABEL = string> extends Chart<'boxplot', DATA, LABEL> { | ||
declare class BoxPlotChart<DATA extends unknown[] = BoxPlotDataPoint[], LABEL = string> extends Chart<'boxplot', DATA, LABEL> { | ||
static id: string; | ||
constructor(item: ChartItem, config: Omit<IChartConfiguration<'boxplot', DATA, LABEL>, 'type'>); | ||
constructor(item: ChartItem, config: Omit<ChartConfiguration<'boxplot', DATA, LABEL>, 'type'>); | ||
} | ||
@@ -362,26 +359,23 @@ | ||
} | ||
interface IViolinControllerDatasetOptions extends IControllerDatasetOptions, IViolinOptions, ScriptableAndArrayOptions<IViolinElementOptions>, ScriptableAndArrayOptions<ICommonHoverOptions> { | ||
interface ViolinControllerDatasetOptions extends ControllerDatasetOptions, IViolinOptions, ScriptableAndArrayOptions<IViolinElementOptions>, ScriptableAndArrayOptions<CommonHoverOptions> { | ||
} | ||
declare type IViolinDataPoint = number[] | (Partial<IViolin> & IBaseStats); | ||
declare type ViolinDataPoint = number[] | (Partial<IViolin> & IBaseStats); | ||
interface IViolinChartOptions { | ||
} | ||
declare module 'chart.js' { | ||
enum ChartTypeEnum { | ||
violin = "violin" | ||
} | ||
interface IChartTypeRegistry { | ||
interface ChartTypeRegistry { | ||
violin: { | ||
chartOptions: IViolinChartOptions; | ||
datasetOptions: IViolinControllerDatasetOptions; | ||
defaultDataPoint: IViolinDataPoint[]; | ||
scales: keyof ICartesianScaleTypeRegistry; | ||
datasetOptions: ViolinControllerDatasetOptions; | ||
defaultDataPoint: ViolinDataPoint[]; | ||
scales: keyof CartesianScaleTypeRegistry; | ||
}; | ||
} | ||
} | ||
declare class ViolinChart<DATA extends unknown[] = IViolinDataPoint[], LABEL = string> extends Chart<'violin', DATA, LABEL> { | ||
declare class ViolinChart<DATA extends unknown[] = ViolinDataPoint[], LABEL = string> extends Chart<'violin', DATA, LABEL> { | ||
static id: string; | ||
constructor(item: ChartItem, config: Omit<IChartConfiguration<'violin', DATA, LABEL>, 'type'>); | ||
constructor(item: ChartItem, config: Omit<ChartConfiguration<'violin', DATA, LABEL>, 'type'>); | ||
} | ||
export { BoxAndWiskers, BoxPlotChart, BoxPlotController, IBoxAndWhiskerProps, IBoxAndWhiskersOptions, IBoxPlotChartOptions, IBoxPlotControllerDatasetOptions, IBoxPlotDataPoint, IStatsBaseOptions, IStatsBaseProps, IViolinChartOptions, IViolinControllerDatasetOptions, IViolinDataPoint, IViolinElementOptions, IViolinElementProps, StatsBase, Violin, ViolinChart, ViolinController }; | ||
export { BoxAndWiskers, BoxPlotChart, BoxPlotController, BoxPlotControllerDatasetOptions, BoxPlotDataPoint, IBoxAndWhiskerProps, IBoxAndWhiskersOptions, IBoxPlotChartOptions, IStatsBaseOptions, IStatsBaseProps, IViolinChartOptions, IViolinElementOptions, IViolinElementProps, StatsBase, Violin, ViolinChart, ViolinController, ViolinControllerDatasetOptions, ViolinDataPoint }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -8,3 +8,3 @@ /** | ||
import { Element, Rectangle, Tooltip, BarController, registry, Chart, LinearScale, CategoryScale } from 'chart.js'; | ||
import { Element, BarElement, Tooltip, BarController, registry, Chart, LinearScale, CategoryScale } from 'chart.js'; | ||
import { drawPoint, merge } from 'chart.js/helpers'; | ||
@@ -511,7 +511,7 @@ import boxplots, { quantilesType7, quantilesHinges, quantilesFivenum, quantilesLinear, quantilesLower, quantilesHigher, quantilesNearest, quantilesMidpoint } from '@sgratzl/boxplots'; | ||
BoxAndWiskers.id = 'boxandwhiskers'; | ||
BoxAndWiskers.defaults = Object.assign({}, Rectangle.defaults, baseDefaults, { | ||
BoxAndWiskers.defaults = Object.assign({}, BarElement.defaults, baseDefaults, { | ||
medianColor: 'transparent', | ||
lowerBackgroundColor: 'transparent', | ||
}); | ||
BoxAndWiskers.defaultRoutes = Object.assign({}, Rectangle.defaultRoutes, baseRoutes); | ||
BoxAndWiskers.defaultRoutes = Object.assign({}, BarElement.defaultRoutes, baseRoutes); | ||
@@ -595,4 +595,4 @@ class Violin extends StatsBase { | ||
Violin.id = 'violin'; | ||
Violin.defaults = Object.assign({}, Rectangle.defaults, baseDefaults); | ||
Violin.defaultRoutes = Object.assign({}, Rectangle.defaultRoutes, baseRoutes); | ||
Violin.defaults = Object.assign({}, BarElement.defaults, baseDefaults); | ||
Violin.defaultRoutes = Object.assign({}, BarElement.defaultRoutes, baseRoutes); | ||
@@ -599,0 +599,0 @@ const interpolators = { |
@@ -518,7 +518,7 @@ /** | ||
BoxAndWiskers.id = 'boxandwhiskers'; | ||
BoxAndWiskers.defaults = Object.assign({}, chart_js.Rectangle.defaults, baseDefaults, { | ||
BoxAndWiskers.defaults = Object.assign({}, chart_js.BarElement.defaults, baseDefaults, { | ||
medianColor: 'transparent', | ||
lowerBackgroundColor: 'transparent', | ||
}); | ||
BoxAndWiskers.defaultRoutes = Object.assign({}, chart_js.Rectangle.defaultRoutes, baseRoutes); | ||
BoxAndWiskers.defaultRoutes = Object.assign({}, chart_js.BarElement.defaultRoutes, baseRoutes); | ||
@@ -602,4 +602,4 @@ class Violin extends StatsBase { | ||
Violin.id = 'violin'; | ||
Violin.defaults = Object.assign({}, chart_js.Rectangle.defaults, baseDefaults); | ||
Violin.defaultRoutes = Object.assign({}, chart_js.Rectangle.defaultRoutes, baseRoutes); | ||
Violin.defaults = Object.assign({}, chart_js.BarElement.defaults, baseDefaults); | ||
Violin.defaultRoutes = Object.assign({}, chart_js.BarElement.defaultRoutes, baseRoutes); | ||
@@ -606,0 +606,0 @@ const interpolators = { |
@@ -895,7 +895,7 @@ /** | ||
BoxAndWiskers.id = 'boxandwhiskers'; | ||
BoxAndWiskers.defaults = Object.assign({}, chart_js.Rectangle.defaults, baseDefaults$1, { | ||
BoxAndWiskers.defaults = Object.assign({}, chart_js.BarElement.defaults, baseDefaults$1, { | ||
medianColor: 'transparent', | ||
lowerBackgroundColor: 'transparent', | ||
}); | ||
BoxAndWiskers.defaultRoutes = Object.assign({}, chart_js.Rectangle.defaultRoutes, baseRoutes); | ||
BoxAndWiskers.defaultRoutes = Object.assign({}, chart_js.BarElement.defaultRoutes, baseRoutes); | ||
@@ -979,4 +979,4 @@ class Violin extends StatsBase$1 { | ||
Violin.id = 'violin'; | ||
Violin.defaults = Object.assign({}, chart_js.Rectangle.defaults, baseDefaults$1); | ||
Violin.defaultRoutes = Object.assign({}, chart_js.Rectangle.defaultRoutes, baseRoutes); | ||
Violin.defaults = Object.assign({}, chart_js.BarElement.defaults, baseDefaults$1); | ||
Violin.defaultRoutes = Object.assign({}, chart_js.BarElement.defaultRoutes, baseRoutes); | ||
@@ -983,0 +983,0 @@ function patchController(type, config, controller, elements = [], scales = []) { |
@@ -1,2 +0,2 @@ | ||
!function(t,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((t="undefined"!=typeof globalThis?globalThis:t||self).ChartBoxPlot={},t.Chart,t.Chart.helpers)}(this,(function(t,e,r){"use strict";function i(t,e,r){const i=e-1,o=e=>{const o=e*i,n=Math.floor(o),s=o-n,a=t[n];return 0===s?a:r(a,t[Math.min(n+1,i)],s)};return{q1:o(.25),median:o(.5),q3:o(.75)}}function o(t,e=t.length){return i(t,e,(t,e,r)=>t+r*(e-t))}function n(t,e=t.length){return i(t,e,(t,e,r)=>t+(e-t)*r)}function s(t,e=t.length){return i(t,e,t=>t)}function a(t,e=t.length){return i(t,e,(t,e)=>e)}function l(t,e=t.length){return i(t,e,(t,e,r)=>r<.5?t:e)}function u(t,e=t.length){return i(t,e,(t,e)=>.5*(t+e))}function h(t,e=t.length){const r=e,i=Math.floor((r+3)/2)/2,o=e=>.5*(t[Math.floor(e)-1]+t[Math.ceil(e)-1]);return{q1:o(i),median:o((r+1)/2),q3:o(r+1-i)}}function d(t,e=t.length){return h(t,e)}function m(t,e={}){const{quantiles:r,validAndSorted:i,coef:n,whiskersMode:s,eps:a}=Object.assign({coef:1.5,eps:.01,quantiles:o,validAndSorted:!1,whiskersMode:"nearest"},e),{missing:l,s:u,min:h,max:d,sum:m}=i?function(t){if(0===t.length)return{sum:Number.NaN,min:Number.NaN,max:Number.NaN,missing:0,s:[]};const e=t[0],r=t[t.length-1],i=(t,e)=>t+e;return{sum:(t instanceof Float32Array||Float64Array,t.reduce(i,0)),min:e,max:r,missing:0,s:t}}(t):function(t){let e=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,i=0,o=0,n=t.length;const s=t instanceof Float64Array?new Float64Array(n):new Float32Array(n);for(let a=0;a<n;++a){const n=t[a];null==n||Number.isNaN(n)||(s[o]=n,o++,n<e&&(e=n),n>r&&(r=n),i+=n)}const a=n-o;if(0===o)return{sum:i,min:e,max:r,missing:a,s:[]};const l=(o===n?s:s.subarray(0,o)).sort((t,e)=>t===e?0:t<e?-1:1);return{sum:i,min:l[0],max:l[l.length-1],missing:a,s:l}}(t),c={min:Number.NaN,max:Number.NaN,mean:Number.NaN,missing:l,iqr:Number.NaN,count:t.length,whiskerHigh:Number.NaN,whiskerLow:Number.NaN,outlier:[],median:Number.NaN,q1:Number.NaN,q3:Number.NaN,items:[]},f=(t,e)=>Math.abs(t-e)<a,g=t.length-l;if(0===g)return c;const{median:p,q1:x,q3:y}=r(u,g),b=y-x,q="number"==typeof n&&n>0;let w=q?Math.max(h,x-n*b):h,k=q?Math.min(d,y+n*b):d;const M=[];for(let t=0;t<g;++t){const e=u[t];if(e>=w||f(e,w)){"nearest"===s&&(w=e);break}0!==M.length&&f(M[M.length-1],e)||M.push(e)}const N=[];for(let t=g-1;t>=0;--t){const e=u[t];if(e<=k||f(e,k)){"nearest"===s&&(k=e);break}0!==N.length&&f(N[N.length-1],e)||0!==M.length&&f(M[M.length-1],e)||N.push(e)}return{min:h,max:d,count:t.length,missing:l,mean:m/g,whiskerHigh:k,whiskerLow:w,outlier:M.concat(N.reverse()),median:p,q1:x,q3:y,iqr:b,items:u}}function c(t){const e=t.length;if(e<1)return Number.NaN;if(1===e)return 0;const r=function(t){return 0===t.length?Number.NaN:t.reduce((t,e,r)=>t+(e-t)/(r+1),0)}(t);return t.reduce((t,e)=>t+(e-r)*(e-r),0)/(t.length-1)}function f(t,e,r){const i=function(t,e){const r=e(t),i=(r.q3-r.q1)/1.34;return 1.06*Math.min(Math.sqrt(c(t)),i)*Math.pow(t.length,-.2)}(e,r);return t.map(t=>{const r=e.reduce((e,r)=>{return e+(o=(t-r)/i,1/Math.sqrt(2*Math.PI)*Math.exp(-.5*o*o));var o},0);return{v:t,estimate:r/i/e.length}})}const g={coef:1.5,quantiles:7};function p(t){return{coef:null==t||"number"!=typeof t.coef?g.coef:t.coef,quantiles:function(t){return"function"==typeof t?t:{hinges:d,fivenum:h,7:o,quantiles:o,linear:n,lower:s,higher:a,nearest:l,midpoint:u}[t]||o}(null==t||null==t.quantiles?o:t.quantiles)}}function x(t,e){if(t){if("number"==typeof t.median&&"number"==typeof t.q1&&"number"==typeof t.q3){if(void 0===t.whiskerMin){const{coef:r}=p(e),{whiskerMin:i,whiskerMax:o}=function(t,e,r=1.5){const i=t.q3-t.q1,o="number"==typeof r&&r>0;let n=o?Math.max(t.min,t.q1-r*i):t.min,s=o?Math.min(t.max,t.q3+r*i):t.max;if(Array.isArray(e)){for(let t=0;t<e.length;t++){const r=e[t];if(r>=n){n=r;break}}for(let t=e.length-1;t>=0;t--){const r=e[t];if(r<=s){s=r;break}}}return{whiskerMin:n,whiskerMax:s}}(t,Array.isArray(t.items)?t.items.slice().sort((t,e)=>t-e):null,r);t.whiskerMin=i,t.whiskerMax=o}return t}if(Array.isArray(t))return function(t,e){const r=m(t,p(e));return{items:Array.from(r.items),outliers:r.outlier,whiskerMax:r.whiskerHigh,whiskerMin:r.whiskerLow,max:r.max,median:r.median,min:r.min,q1:r.q1,q3:r.q3}}(t,e)}}function y(t,e){if(t){if("number"==typeof t.median&&Array.isArray(t.coords))return t;if(Array.isArray(t))return function(t,e){if(0===t.length)return;const r=t.filter(t=>"number"==typeof t&&!Number.isNaN(t)).sort((t,e)=>t-e),{quantiles:i}=p(e),o=i(r),n=r[0],s=r[r.length-1],a=[],l=(s-n)/e.points;for(let t=n;t<=s&&l>0;t+=l)a.push(t);a[a.length-1]!==s&&a.push(s);const u=f(r,a,i),h=u.reduce((t,e)=>Math.max(t,e.estimate),Number.NEGATIVE_INFINITY);return{...o,min:n,items:r,max:s,coords:u,outliers:[],maxEstimate:h}}(t,e)}}const b={number:(t,e,r)=>t===e||null==t?e:null==e?t:t+(e-t)*r};function q(t,e,r){return"number"==typeof t&&"number"==typeof e?b.number(t,e,r):Array.isArray(t)&&Array.isArray(e)?e.map((e,i)=>b.number(t[i],e,r)):e}function w(t){const e=t.formattedValue,r=this;e&&null!=r._tooltipOutlier&&t.datasetIndex===r._tooltipOutlier.datasetIndex&&(e.hoveredOutlierIndex=r._tooltipOutlier.index)}function k(t,e){if(!t.length)return!1;let r=0,i=0,o=0;for(let n=0;n<t.length;++n){const s=t[n].element;if(s&&s.hasValue()){const t=s.tooltipPosition(e,this);r+=t.x,i+=t.y,++o}}return{x:r/o,y:i/o}}function M(t){const e=["borderColor","backgroundColor"].concat(t.filter(t=>t.endsWith("Color")));return{datasets:Object.assign({animation:{numberArray:{fn:q,properties:["outliers","items"]},colors:{type:"color",properties:e},show:{colors:{type:"color",properties:e,from:"transparent"}},hide:{colors:{type:"color",properties:e,to:"transparent"}}},minStats:"min",maxStats:"max"},g),tooltips:{position:k.register().id,callbacks:{beforeLabel:w}}}}k.id="averageInstance",k.register=()=>(e.Tooltip.positioners.averageInstance=k,k);class N extends e.BarController{getMinMax(t,e){const r=t.axis,i=this._config;t.axis=i.minStats;const o=super.getMinMax(t,e).min;t.axis=i.maxStats;const n=super.getMinMax(t,e).max;return t.axis=r,{min:o,max:n}}parsePrimitiveData(t,e,r,i){const o=t.vScale,n=t.iScale,s=n.getLabels(),a=[];for(let t=0;t<i;t++){const i=t+r,l={};l[n.axis]=n.parse(s[i],i);const u=this._parseStats(null==e?null:e[i],this._config);u&&(Object.assign(l,u),l[o.axis]=u.median),a.push(l)}return a}parseArrayData(t,e,r,i){return this.parsePrimitiveData(t,e,r,i)}parseObjectData(t,e,r,i){return this.parsePrimitiveData(t,e,r,i)}getLabelAndValue(t){const e=super.getLabelAndValue(t),r=this._cachedMeta.vScale,i=this.getParsed(t);if(!r||!i||"NaN"===e.value)return e;e.value={raw:i,hoveredOutlierIndex:-1},this._transformStats(e.value,i,t=>r.getLabelForValue(t),"string");const o=this._toStringStats(e.value);return e.value.toString=function(){return this.hoveredOutlierIndex>=0?`(outlier: ${this.outliers[this.hoveredOutlierIndex]})`:o},e}updateElement(t,e,r,i){const o="reset"===i,n=this._cachedMeta.vScale,s=this.getParsed(e),a=n.getBasePixel();r._datasetIndex=this.index,r._index=e,this._transformStats(r,s,t=>o?a:n.getPixelForValue(t,e),i),super.updateElement(t,e,r,i)}}const C={borderWidth:1,outlierStyle:"circle",outlierRadius:2,outlierBorderWidth:1,itemStyle:"circle",itemRadius:0,itemBorderWidth:0,hitPadding:2,outlierHitRadius:4},_={outlierBackgroundColor:"color",outlierBorderColor:"color",itemBackgroundColor:"color",itemBorderColor:"color"},v=Object.keys(C).concat(Object.keys(_));class P extends e.Element{isVertical(){return null==this.getProps(["height"]).height}_drawItems(t){const e=this.isVertical(),i=this.getProps(["x","y","items","width","height"]),o=this.options;if(o.itemRadius<=0||!i.items||i.items.length<=0)return;t.save(),t.strokeStyle=o.itemBorderColor,t.fillStyle=o.itemBackgroundColor,t.lineWidth=o.itemBorderWidth;const n=function(t=Date.now()){let e=t;return()=>(e=(9301*e+49297)%233280,e/233280)}(1e3*this._datasetIndex+this._index),s={pointStyle:o.itemStyle,radius:o.itemRadius,borderWidth:o.itemBorderWidth};e?i.items.forEach(e=>{r.drawPoint(t,s,i.x-i.width/2+n()*i.width,e)}):i.items.forEach(e=>{r.drawPoint(t,s,e,i.y-i.height/2+n()*i.height)}),t.restore()}_drawOutliers(t){const e=this.isVertical(),i=this.getProps(["x","y","outliers"]),o=this.options;if(o.outlierRadius<=0||!i.outliers||0===i.outliers.length)return;t.save(),t.fillStyle=o.outlierBackgroundColor,t.strokeStyle=o.outlierBorderColor,t.lineWidth=o.outlierBorderWidth;const n={pointStyle:o.outlierStyle,radius:o.outlierRadius,borderWidth:o.outlierBorderWidth};e?i.outliers.forEach(e=>{r.drawPoint(t,n,i.x,e)}):i.outliers.forEach(e=>{r.drawPoint(t,n,e,i.y)}),t.restore()}_getBounds(t){return{left:0,top:0,right:0,bottom:0}}_getHitBounds(t){const e=this.options.hitPadding,r=this._getBounds(t);return{left:r.left-e,top:r.top-e,right:r.right+e,bottom:r.bottom+e}}inRange(t,e,r){return(!Number.isNaN(this.x)||!Number.isNaN(this.y))&&(this._boxInRange(t,e,r)||this._outlierIndexInRange(t,e,r)>=0)}inXRange(t,e){const r=this._getHitBounds(e);return t>=r.left&&t<=r.right}inYRange(t,e){const r=this._getHitBounds(e);return t>=r.top&&t<=r.bottom}_outlierIndexInRange(t,e,r){const i=this.getProps(["x","y"],r),o=this.options.outlierHitRadius,n=this._getOutliers(r),s=this.isVertical();if(s&&Math.abs(t-i.x)>o||!s&&Math.abs(e-i.y)>o)return-1;const a=s?e:t;for(let t=0;t<n.length;t++)if(Math.abs(n[t]-a)<=o)return t;return-1}_boxInRange(t,e,r){const i=this._getHitBounds(r);return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}getCenterPoint(t){const e=this.getProps(["x","y"],t);return{x:e.x,y:e.y}}_getOutliers(t){return this.getProps(["outliers"],t).outliers||[]}tooltipPosition(t,e){if(!t||"boolean"==typeof t)return this.getCenterPoint();e&&delete e._tooltipOutlier;const r=this.getProps(["x","y"]),i=this._outlierIndexInRange(t.x,t.y);return i<0||!e?this.getCenterPoint():(e._tooltipOutlier={index:i,datasetIndex:this._datasetIndex},this.isVertical()?{x:r.x,y:this._getOutliers()[i]}:{x:this._getOutliers()[i],y:r.y})}}const S=v.concat(["medianColor","lowerBackgroundColor"]);class B extends P{draw(t){t.save(),t.fillStyle=this.options.backgroundColor,t.strokeStyle=this.options.borderColor,t.lineWidth=this.options.borderWidth,this._drawBoxPlot(t),this._drawOutliers(t),t.restore(),this._drawItems(t)}_drawBoxPlot(t){this.isVertical()?this._drawBoxPlotVertical(t):this._drawBoxPlotHorizontal(t)}_drawBoxPlotVertical(t){const e=this.options,r=this.getProps(["x","width","q1","q3","median","whiskerMin","whiskerMax"]),i=r.x,o=r.width,n=i-o/2;r.q3>r.q1?t.fillRect(n,r.q1,o,r.q3-r.q1):t.fillRect(n,r.q3,o,r.q1-r.q3),t.save(),e.medianColor&&"transparent"!==e.medianColor&&"#0000"!==e.medianColor&&(t.strokeStyle=e.medianColor),t.beginPath(),t.moveTo(n,r.median),t.lineTo(n+o,r.median),t.closePath(),t.stroke(),t.restore(),t.save(),e.lowerBackgroundColor&&"transparent"!==e.lowerBackgroundColor&&"#0000"!==e.lowerBackgroundColor&&(t.fillStyle=e.lowerBackgroundColor,r.q3>r.q1?t.fillRect(n,r.median,o,r.q3-r.median):t.fillRect(n,r.median,o,r.q1-r.median)),t.restore(),r.q3>r.q1?t.strokeRect(n,r.q1,o,r.q3-r.q1):t.strokeRect(n,r.q3,o,r.q1-r.q3),t.beginPath(),t.moveTo(n,r.whiskerMin),t.lineTo(n+o,r.whiskerMin),t.moveTo(i,r.whiskerMin),t.lineTo(i,r.q1),t.moveTo(n,r.whiskerMax),t.lineTo(n+o,r.whiskerMax),t.moveTo(i,r.whiskerMax),t.lineTo(i,r.q3),t.closePath(),t.stroke()}_drawBoxPlotHorizontal(t){const e=this.options,r=this.getProps(["y","height","q1","q3","median","whiskerMin","whiskerMax"]),i=r.y,o=r.height,n=i-o/2;r.q3>r.q1?t.fillRect(r.q1,n,r.q3-r.q1,o):t.fillRect(r.q3,n,r.q1-r.q3,o),t.save(),e.medianColor&&"transparent"!==e.medianColor&&(t.strokeStyle=e.medianColor),t.beginPath(),t.moveTo(r.median,n),t.lineTo(r.median,n+o),t.closePath(),t.stroke(),t.restore(),t.save(),e.lowerBackgroundColor&&"transparent"!==e.lowerBackgroundColor&&(t.fillStyle=e.lowerBackgroundColor,r.q3>r.q1?t.fillRect(r.median,n,r.q3-r.median,o):t.fillRect(r.median,n,r.q1-r.median,o)),t.restore(),r.q3>r.q1?t.strokeRect(r.q1,n,r.q3-r.q1,o):t.strokeRect(r.q3,n,r.q1-r.q3,o),t.beginPath(),t.moveTo(r.whiskerMin,n),t.lineTo(r.whiskerMin,n+o),t.moveTo(r.whiskerMin,i),t.lineTo(r.q1,i),t.moveTo(r.whiskerMax,n),t.lineTo(r.whiskerMax,n+o),t.moveTo(r.whiskerMax,i),t.lineTo(r.q3,i),t.closePath(),t.stroke()}_getBounds(t){const e=this.isVertical();if(null==this.x)return{left:0,top:0,right:0,bottom:0};if(e){const{x:e,width:r,whiskerMax:i,whiskerMin:o}=this.getProps(["x","width","whiskerMin","whiskerMax"],t),n=e-r/2;return{left:n,top:i,right:n+r,bottom:o}}const{y:r,height:i,whiskerMax:o,whiskerMin:n}=this.getProps(["y","height","whiskerMin","whiskerMax"],t),s=r-i/2;return{left:n,top:s,right:o,bottom:s+i}}}B.id="boxandwhiskers",B.defaults=Object.assign({},e.Rectangle.defaults,C,{medianColor:"transparent",lowerBackgroundColor:"transparent"}),B.defaultRoutes=Object.assign({},e.Rectangle.defaultRoutes,_);class A extends P{draw(t){t.save(),t.fillStyle=this.options.backgroundColor,t.strokeStyle=this.options.borderColor,t.lineWidth=this.options.borderWidth;const e=this.getProps(["x","y","width","height","min","max","coords","maxEstimate"]);r.drawPoint(t,{pointStyle:"rectRot",radius:5,borderWidth:this.options.borderWidth},e.x,e.y),e.coords&&e.coords.length>0&&this._drawCoords(t,e),this._drawOutliers(t),t.restore(),this._drawItems(t)}_drawCoords(t,e){if(t.beginPath(),this.isVertical()){const r=e.x,i=e.width/2/e.maxEstimate;t.moveTo(r,e.min),e.coords.forEach(e=>{t.lineTo(r-e.estimate*i,e.v)}),t.lineTo(r,e.max),t.moveTo(r,e.min),e.coords.forEach(e=>{t.lineTo(r+e.estimate*i,e.v)}),t.lineTo(r,e.max)}else{const r=e.y,i=e.height/2/e.maxEstimate;t.moveTo(e.min,r),e.coords.forEach(e=>{t.lineTo(e.v,r-e.estimate*i)}),t.lineTo(e.max,r),t.moveTo(e.min,r),e.coords.forEach(e=>{t.lineTo(e.v,r+e.estimate*i)}),t.lineTo(e.max,r)}t.closePath(),t.stroke(),t.fill()}_getBounds(t){if(this.isVertical()){const{x:e,width:r,min:i,max:o}=this.getProps(["x","width","min","max"],t),n=e-r/2;return{left:n,top:o,right:n+r,bottom:i}}const{y:e,height:r,min:i,max:o}=this.getProps(["y","height","min","max"],t),n=e-r/2;return{left:i,top:n,right:o,bottom:n+r}}}function T(t,r,i,o=[],n=[]){e.registry.addControllers(i),Array.isArray(o)?e.registry.addElements(...o):e.registry.addElements(o),Array.isArray(n)?e.registry.addScales(...n):e.registry.addScales(n);const s=r;return s.type=t,s}A.id="violin",A.defaults=Object.assign({},e.Rectangle.defaults,C),A.defaultRoutes=Object.assign({},e.Rectangle.defaultRoutes,_);class I extends N{_parseStats(t,e){return x(t,e)}_toStringStats(t){return`(min: ${t.min}, 25% quantile: ${t.q1}, median: ${t.median}, 75% quantile: ${t.q3}, max: ${t.max})`}_transformStats(t,e,r){for(const i of["min","max","median","q3","q1","whiskerMin","whiskerMax"])t[i]=r(e[i]);for(const i of["outliers","items"])Array.isArray(e[i])&&(t[i]=e[i].map(r))}}I.id="boxplot",I.defaults=r.merge({},[e.BarController.defaults,M(S),{datasets:{animation:{numbers:{type:"number",properties:e.BarController.defaults.datasets.animation.numbers.properties.concat(["q1","q3","min","max","median","whiskerMin","whiskerMax"],S.filter(t=>!t.endsWith("Color")))}}},dataElementType:B.id,dataElementOptions:e.BarController.defaults.dataElementOptions.concat(S)}]);class R extends e.Chart{constructor(t,r){super(t,T("boxplot",r,I,B,[e.LinearScale,e.CategoryScale]))}}R.id=I.id;class O extends N{_parseStats(t,e){return y(t,e)}_toStringStats(t){return`(min: ${t.min}, 25% quantile: ${t.q1}, median: ${t.median}, 75% quantile: ${t.q3}, max: ${t.max})`}_transformStats(t,e,r){for(const i of["min","max","median","q3","q1"])t[i]=r(e[i]);t.maxEstimate=e.maxEstimate;for(const i of["items","outliers"])Array.isArray(e[i])&&(t[i]=e[i].map(r));Array.isArray(e.coords)&&(t.coords=e.coords.map(t=>Object.assign({},t,{v:r(t.v)})))}}O.id="violin",O.defaults=r.merge({},[e.BarController.defaults,M(v),{datasets:{points:100,animation:{numbers:{type:"number",properties:e.BarController.defaults.datasets.animation.numbers.properties.concat(["q1","q3","min","max","median","maxEstimate"],v.filter(t=>!t.endsWith("Color")))},kdeCoords:{fn:function(t,e,r){return Array.isArray(t)&&Array.isArray(e)?e.map((e,i)=>({v:b.number(t[i]?t[i].v:null,e.v,r),estimate:b.number(t[i]?t[i].estimate:null,e.estimate,r)})):e},properties:["coords"]}}},dataElementType:A.id,dataElementOptions:e.BarController.defaults.dataElementOptions.concat(v)}]);class E extends e.Chart{constructor(t,r){super(t,T("violin",r,O,A,[e.LinearScale,e.CategoryScale]))}}E.id=O.id,e.registry.addControllers(I,O),e.registry.addElements(B,A),t.BoxAndWiskers=B,t.BoxPlotChart=R,t.BoxPlotController=I,t.StatsBase=P,t.Violin=A,t.ViolinChart=E,t.ViolinController=O,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,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((t="undefined"!=typeof globalThis?globalThis:t||self).ChartBoxPlot={},t.Chart,t.Chart.helpers)}(this,(function(t,e,r){"use strict";function i(t,e,r){const i=e-1,o=e=>{const o=e*i,n=Math.floor(o),s=o-n,a=t[n];return 0===s?a:r(a,t[Math.min(n+1,i)],s)};return{q1:o(.25),median:o(.5),q3:o(.75)}}function o(t,e=t.length){return i(t,e,(t,e,r)=>t+r*(e-t))}function n(t,e=t.length){return i(t,e,(t,e,r)=>t+(e-t)*r)}function s(t,e=t.length){return i(t,e,t=>t)}function a(t,e=t.length){return i(t,e,(t,e)=>e)}function l(t,e=t.length){return i(t,e,(t,e,r)=>r<.5?t:e)}function u(t,e=t.length){return i(t,e,(t,e)=>.5*(t+e))}function h(t,e=t.length){const r=e,i=Math.floor((r+3)/2)/2,o=e=>.5*(t[Math.floor(e)-1]+t[Math.ceil(e)-1]);return{q1:o(i),median:o((r+1)/2),q3:o(r+1-i)}}function d(t,e=t.length){return h(t,e)}function m(t,e={}){const{quantiles:r,validAndSorted:i,coef:n,whiskersMode:s,eps:a}=Object.assign({coef:1.5,eps:.01,quantiles:o,validAndSorted:!1,whiskersMode:"nearest"},e),{missing:l,s:u,min:h,max:d,sum:m}=i?function(t){if(0===t.length)return{sum:Number.NaN,min:Number.NaN,max:Number.NaN,missing:0,s:[]};const e=t[0],r=t[t.length-1],i=(t,e)=>t+e;return{sum:(t instanceof Float32Array||Float64Array,t.reduce(i,0)),min:e,max:r,missing:0,s:t}}(t):function(t){let e=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,i=0,o=0,n=t.length;const s=t instanceof Float64Array?new Float64Array(n):new Float32Array(n);for(let a=0;a<n;++a){const n=t[a];null==n||Number.isNaN(n)||(s[o]=n,o++,n<e&&(e=n),n>r&&(r=n),i+=n)}const a=n-o;if(0===o)return{sum:i,min:e,max:r,missing:a,s:[]};const l=(o===n?s:s.subarray(0,o)).sort((t,e)=>t===e?0:t<e?-1:1);return{sum:i,min:l[0],max:l[l.length-1],missing:a,s:l}}(t),c={min:Number.NaN,max:Number.NaN,mean:Number.NaN,missing:l,iqr:Number.NaN,count:t.length,whiskerHigh:Number.NaN,whiskerLow:Number.NaN,outlier:[],median:Number.NaN,q1:Number.NaN,q3:Number.NaN,items:[]},f=(t,e)=>Math.abs(t-e)<a,g=t.length-l;if(0===g)return c;const{median:p,q1:x,q3:y}=r(u,g),b=y-x,q="number"==typeof n&&n>0;let w=q?Math.max(h,x-n*b):h,k=q?Math.min(d,y+n*b):d;const M=[];for(let t=0;t<g;++t){const e=u[t];if(e>=w||f(e,w)){"nearest"===s&&(w=e);break}0!==M.length&&f(M[M.length-1],e)||M.push(e)}const N=[];for(let t=g-1;t>=0;--t){const e=u[t];if(e<=k||f(e,k)){"nearest"===s&&(k=e);break}0!==N.length&&f(N[N.length-1],e)||0!==M.length&&f(M[M.length-1],e)||N.push(e)}return{min:h,max:d,count:t.length,missing:l,mean:m/g,whiskerHigh:k,whiskerLow:w,outlier:M.concat(N.reverse()),median:p,q1:x,q3:y,iqr:b,items:u}}function c(t){const e=t.length;if(e<1)return Number.NaN;if(1===e)return 0;const r=function(t){return 0===t.length?Number.NaN:t.reduce((t,e,r)=>t+(e-t)/(r+1),0)}(t);return t.reduce((t,e)=>t+(e-r)*(e-r),0)/(t.length-1)}function f(t,e,r){const i=function(t,e){const r=e(t),i=(r.q3-r.q1)/1.34;return 1.06*Math.min(Math.sqrt(c(t)),i)*Math.pow(t.length,-.2)}(e,r);return t.map(t=>{const r=e.reduce((e,r)=>{return e+(o=(t-r)/i,1/Math.sqrt(2*Math.PI)*Math.exp(-.5*o*o));var o},0);return{v:t,estimate:r/i/e.length}})}const g={coef:1.5,quantiles:7};function p(t){return{coef:null==t||"number"!=typeof t.coef?g.coef:t.coef,quantiles:function(t){return"function"==typeof t?t:{hinges:d,fivenum:h,7:o,quantiles:o,linear:n,lower:s,higher:a,nearest:l,midpoint:u}[t]||o}(null==t||null==t.quantiles?o:t.quantiles)}}function x(t,e){if(t){if("number"==typeof t.median&&"number"==typeof t.q1&&"number"==typeof t.q3){if(void 0===t.whiskerMin){const{coef:r}=p(e),{whiskerMin:i,whiskerMax:o}=function(t,e,r=1.5){const i=t.q3-t.q1,o="number"==typeof r&&r>0;let n=o?Math.max(t.min,t.q1-r*i):t.min,s=o?Math.min(t.max,t.q3+r*i):t.max;if(Array.isArray(e)){for(let t=0;t<e.length;t++){const r=e[t];if(r>=n){n=r;break}}for(let t=e.length-1;t>=0;t--){const r=e[t];if(r<=s){s=r;break}}}return{whiskerMin:n,whiskerMax:s}}(t,Array.isArray(t.items)?t.items.slice().sort((t,e)=>t-e):null,r);t.whiskerMin=i,t.whiskerMax=o}return t}if(Array.isArray(t))return function(t,e){const r=m(t,p(e));return{items:Array.from(r.items),outliers:r.outlier,whiskerMax:r.whiskerHigh,whiskerMin:r.whiskerLow,max:r.max,median:r.median,min:r.min,q1:r.q1,q3:r.q3}}(t,e)}}function y(t,e){if(t){if("number"==typeof t.median&&Array.isArray(t.coords))return t;if(Array.isArray(t))return function(t,e){if(0===t.length)return;const r=t.filter(t=>"number"==typeof t&&!Number.isNaN(t)).sort((t,e)=>t-e),{quantiles:i}=p(e),o=i(r),n=r[0],s=r[r.length-1],a=[],l=(s-n)/e.points;for(let t=n;t<=s&&l>0;t+=l)a.push(t);a[a.length-1]!==s&&a.push(s);const u=f(r,a,i),h=u.reduce((t,e)=>Math.max(t,e.estimate),Number.NEGATIVE_INFINITY);return{...o,min:n,items:r,max:s,coords:u,outliers:[],maxEstimate:h}}(t,e)}}const b={number:(t,e,r)=>t===e||null==t?e:null==e?t:t+(e-t)*r};function q(t,e,r){return"number"==typeof t&&"number"==typeof e?b.number(t,e,r):Array.isArray(t)&&Array.isArray(e)?e.map((e,i)=>b.number(t[i],e,r)):e}function w(t){const e=t.formattedValue,r=this;e&&null!=r._tooltipOutlier&&t.datasetIndex===r._tooltipOutlier.datasetIndex&&(e.hoveredOutlierIndex=r._tooltipOutlier.index)}function k(t,e){if(!t.length)return!1;let r=0,i=0,o=0;for(let n=0;n<t.length;++n){const s=t[n].element;if(s&&s.hasValue()){const t=s.tooltipPosition(e,this);r+=t.x,i+=t.y,++o}}return{x:r/o,y:i/o}}function M(t){const e=["borderColor","backgroundColor"].concat(t.filter(t=>t.endsWith("Color")));return{datasets:Object.assign({animation:{numberArray:{fn:q,properties:["outliers","items"]},colors:{type:"color",properties:e},show:{colors:{type:"color",properties:e,from:"transparent"}},hide:{colors:{type:"color",properties:e,to:"transparent"}}},minStats:"min",maxStats:"max"},g),tooltips:{position:k.register().id,callbacks:{beforeLabel:w}}}}k.id="averageInstance",k.register=()=>(e.Tooltip.positioners.averageInstance=k,k);class N extends e.BarController{getMinMax(t,e){const r=t.axis,i=this._config;t.axis=i.minStats;const o=super.getMinMax(t,e).min;t.axis=i.maxStats;const n=super.getMinMax(t,e).max;return t.axis=r,{min:o,max:n}}parsePrimitiveData(t,e,r,i){const o=t.vScale,n=t.iScale,s=n.getLabels(),a=[];for(let t=0;t<i;t++){const i=t+r,l={};l[n.axis]=n.parse(s[i],i);const u=this._parseStats(null==e?null:e[i],this._config);u&&(Object.assign(l,u),l[o.axis]=u.median),a.push(l)}return a}parseArrayData(t,e,r,i){return this.parsePrimitiveData(t,e,r,i)}parseObjectData(t,e,r,i){return this.parsePrimitiveData(t,e,r,i)}getLabelAndValue(t){const e=super.getLabelAndValue(t),r=this._cachedMeta.vScale,i=this.getParsed(t);if(!r||!i||"NaN"===e.value)return e;e.value={raw:i,hoveredOutlierIndex:-1},this._transformStats(e.value,i,t=>r.getLabelForValue(t),"string");const o=this._toStringStats(e.value);return e.value.toString=function(){return this.hoveredOutlierIndex>=0?`(outlier: ${this.outliers[this.hoveredOutlierIndex]})`:o},e}updateElement(t,e,r,i){const o="reset"===i,n=this._cachedMeta.vScale,s=this.getParsed(e),a=n.getBasePixel();r._datasetIndex=this.index,r._index=e,this._transformStats(r,s,t=>o?a:n.getPixelForValue(t,e),i),super.updateElement(t,e,r,i)}}const C={borderWidth:1,outlierStyle:"circle",outlierRadius:2,outlierBorderWidth:1,itemStyle:"circle",itemRadius:0,itemBorderWidth:0,hitPadding:2,outlierHitRadius:4},_={outlierBackgroundColor:"color",outlierBorderColor:"color",itemBackgroundColor:"color",itemBorderColor:"color"},v=Object.keys(C).concat(Object.keys(_));class P extends e.Element{isVertical(){return null==this.getProps(["height"]).height}_drawItems(t){const e=this.isVertical(),i=this.getProps(["x","y","items","width","height"]),o=this.options;if(o.itemRadius<=0||!i.items||i.items.length<=0)return;t.save(),t.strokeStyle=o.itemBorderColor,t.fillStyle=o.itemBackgroundColor,t.lineWidth=o.itemBorderWidth;const n=function(t=Date.now()){let e=t;return()=>(e=(9301*e+49297)%233280,e/233280)}(1e3*this._datasetIndex+this._index),s={pointStyle:o.itemStyle,radius:o.itemRadius,borderWidth:o.itemBorderWidth};e?i.items.forEach(e=>{r.drawPoint(t,s,i.x-i.width/2+n()*i.width,e)}):i.items.forEach(e=>{r.drawPoint(t,s,e,i.y-i.height/2+n()*i.height)}),t.restore()}_drawOutliers(t){const e=this.isVertical(),i=this.getProps(["x","y","outliers"]),o=this.options;if(o.outlierRadius<=0||!i.outliers||0===i.outliers.length)return;t.save(),t.fillStyle=o.outlierBackgroundColor,t.strokeStyle=o.outlierBorderColor,t.lineWidth=o.outlierBorderWidth;const n={pointStyle:o.outlierStyle,radius:o.outlierRadius,borderWidth:o.outlierBorderWidth};e?i.outliers.forEach(e=>{r.drawPoint(t,n,i.x,e)}):i.outliers.forEach(e=>{r.drawPoint(t,n,e,i.y)}),t.restore()}_getBounds(t){return{left:0,top:0,right:0,bottom:0}}_getHitBounds(t){const e=this.options.hitPadding,r=this._getBounds(t);return{left:r.left-e,top:r.top-e,right:r.right+e,bottom:r.bottom+e}}inRange(t,e,r){return(!Number.isNaN(this.x)||!Number.isNaN(this.y))&&(this._boxInRange(t,e,r)||this._outlierIndexInRange(t,e,r)>=0)}inXRange(t,e){const r=this._getHitBounds(e);return t>=r.left&&t<=r.right}inYRange(t,e){const r=this._getHitBounds(e);return t>=r.top&&t<=r.bottom}_outlierIndexInRange(t,e,r){const i=this.getProps(["x","y"],r),o=this.options.outlierHitRadius,n=this._getOutliers(r),s=this.isVertical();if(s&&Math.abs(t-i.x)>o||!s&&Math.abs(e-i.y)>o)return-1;const a=s?e:t;for(let t=0;t<n.length;t++)if(Math.abs(n[t]-a)<=o)return t;return-1}_boxInRange(t,e,r){const i=this._getHitBounds(r);return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}getCenterPoint(t){const e=this.getProps(["x","y"],t);return{x:e.x,y:e.y}}_getOutliers(t){return this.getProps(["outliers"],t).outliers||[]}tooltipPosition(t,e){if(!t||"boolean"==typeof t)return this.getCenterPoint();e&&delete e._tooltipOutlier;const r=this.getProps(["x","y"]),i=this._outlierIndexInRange(t.x,t.y);return i<0||!e?this.getCenterPoint():(e._tooltipOutlier={index:i,datasetIndex:this._datasetIndex},this.isVertical()?{x:r.x,y:this._getOutliers()[i]}:{x:this._getOutliers()[i],y:r.y})}}const B=v.concat(["medianColor","lowerBackgroundColor"]);class S extends P{draw(t){t.save(),t.fillStyle=this.options.backgroundColor,t.strokeStyle=this.options.borderColor,t.lineWidth=this.options.borderWidth,this._drawBoxPlot(t),this._drawOutliers(t),t.restore(),this._drawItems(t)}_drawBoxPlot(t){this.isVertical()?this._drawBoxPlotVertical(t):this._drawBoxPlotHorizontal(t)}_drawBoxPlotVertical(t){const e=this.options,r=this.getProps(["x","width","q1","q3","median","whiskerMin","whiskerMax"]),i=r.x,o=r.width,n=i-o/2;r.q3>r.q1?t.fillRect(n,r.q1,o,r.q3-r.q1):t.fillRect(n,r.q3,o,r.q1-r.q3),t.save(),e.medianColor&&"transparent"!==e.medianColor&&"#0000"!==e.medianColor&&(t.strokeStyle=e.medianColor),t.beginPath(),t.moveTo(n,r.median),t.lineTo(n+o,r.median),t.closePath(),t.stroke(),t.restore(),t.save(),e.lowerBackgroundColor&&"transparent"!==e.lowerBackgroundColor&&"#0000"!==e.lowerBackgroundColor&&(t.fillStyle=e.lowerBackgroundColor,r.q3>r.q1?t.fillRect(n,r.median,o,r.q3-r.median):t.fillRect(n,r.median,o,r.q1-r.median)),t.restore(),r.q3>r.q1?t.strokeRect(n,r.q1,o,r.q3-r.q1):t.strokeRect(n,r.q3,o,r.q1-r.q3),t.beginPath(),t.moveTo(n,r.whiskerMin),t.lineTo(n+o,r.whiskerMin),t.moveTo(i,r.whiskerMin),t.lineTo(i,r.q1),t.moveTo(n,r.whiskerMax),t.lineTo(n+o,r.whiskerMax),t.moveTo(i,r.whiskerMax),t.lineTo(i,r.q3),t.closePath(),t.stroke()}_drawBoxPlotHorizontal(t){const e=this.options,r=this.getProps(["y","height","q1","q3","median","whiskerMin","whiskerMax"]),i=r.y,o=r.height,n=i-o/2;r.q3>r.q1?t.fillRect(r.q1,n,r.q3-r.q1,o):t.fillRect(r.q3,n,r.q1-r.q3,o),t.save(),e.medianColor&&"transparent"!==e.medianColor&&(t.strokeStyle=e.medianColor),t.beginPath(),t.moveTo(r.median,n),t.lineTo(r.median,n+o),t.closePath(),t.stroke(),t.restore(),t.save(),e.lowerBackgroundColor&&"transparent"!==e.lowerBackgroundColor&&(t.fillStyle=e.lowerBackgroundColor,r.q3>r.q1?t.fillRect(r.median,n,r.q3-r.median,o):t.fillRect(r.median,n,r.q1-r.median,o)),t.restore(),r.q3>r.q1?t.strokeRect(r.q1,n,r.q3-r.q1,o):t.strokeRect(r.q3,n,r.q1-r.q3,o),t.beginPath(),t.moveTo(r.whiskerMin,n),t.lineTo(r.whiskerMin,n+o),t.moveTo(r.whiskerMin,i),t.lineTo(r.q1,i),t.moveTo(r.whiskerMax,n),t.lineTo(r.whiskerMax,n+o),t.moveTo(r.whiskerMax,i),t.lineTo(r.q3,i),t.closePath(),t.stroke()}_getBounds(t){const e=this.isVertical();if(null==this.x)return{left:0,top:0,right:0,bottom:0};if(e){const{x:e,width:r,whiskerMax:i,whiskerMin:o}=this.getProps(["x","width","whiskerMin","whiskerMax"],t),n=e-r/2;return{left:n,top:i,right:n+r,bottom:o}}const{y:r,height:i,whiskerMax:o,whiskerMin:n}=this.getProps(["y","height","whiskerMin","whiskerMax"],t),s=r-i/2;return{left:n,top:s,right:o,bottom:s+i}}}S.id="boxandwhiskers",S.defaults=Object.assign({},e.BarElement.defaults,C,{medianColor:"transparent",lowerBackgroundColor:"transparent"}),S.defaultRoutes=Object.assign({},e.BarElement.defaultRoutes,_);class A extends P{draw(t){t.save(),t.fillStyle=this.options.backgroundColor,t.strokeStyle=this.options.borderColor,t.lineWidth=this.options.borderWidth;const e=this.getProps(["x","y","width","height","min","max","coords","maxEstimate"]);r.drawPoint(t,{pointStyle:"rectRot",radius:5,borderWidth:this.options.borderWidth},e.x,e.y),e.coords&&e.coords.length>0&&this._drawCoords(t,e),this._drawOutliers(t),t.restore(),this._drawItems(t)}_drawCoords(t,e){if(t.beginPath(),this.isVertical()){const r=e.x,i=e.width/2/e.maxEstimate;t.moveTo(r,e.min),e.coords.forEach(e=>{t.lineTo(r-e.estimate*i,e.v)}),t.lineTo(r,e.max),t.moveTo(r,e.min),e.coords.forEach(e=>{t.lineTo(r+e.estimate*i,e.v)}),t.lineTo(r,e.max)}else{const r=e.y,i=e.height/2/e.maxEstimate;t.moveTo(e.min,r),e.coords.forEach(e=>{t.lineTo(e.v,r-e.estimate*i)}),t.lineTo(e.max,r),t.moveTo(e.min,r),e.coords.forEach(e=>{t.lineTo(e.v,r+e.estimate*i)}),t.lineTo(e.max,r)}t.closePath(),t.stroke(),t.fill()}_getBounds(t){if(this.isVertical()){const{x:e,width:r,min:i,max:o}=this.getProps(["x","width","min","max"],t),n=e-r/2;return{left:n,top:o,right:n+r,bottom:i}}const{y:e,height:r,min:i,max:o}=this.getProps(["y","height","min","max"],t),n=e-r/2;return{left:i,top:n,right:o,bottom:n+r}}}function T(t,r,i,o=[],n=[]){e.registry.addControllers(i),Array.isArray(o)?e.registry.addElements(...o):e.registry.addElements(o),Array.isArray(n)?e.registry.addScales(...n):e.registry.addScales(n);const s=r;return s.type=t,s}A.id="violin",A.defaults=Object.assign({},e.BarElement.defaults,C),A.defaultRoutes=Object.assign({},e.BarElement.defaultRoutes,_);class I extends N{_parseStats(t,e){return x(t,e)}_toStringStats(t){return`(min: ${t.min}, 25% quantile: ${t.q1}, median: ${t.median}, 75% quantile: ${t.q3}, max: ${t.max})`}_transformStats(t,e,r){for(const i of["min","max","median","q3","q1","whiskerMin","whiskerMax"])t[i]=r(e[i]);for(const i of["outliers","items"])Array.isArray(e[i])&&(t[i]=e[i].map(r))}}I.id="boxplot",I.defaults=r.merge({},[e.BarController.defaults,M(B),{datasets:{animation:{numbers:{type:"number",properties:e.BarController.defaults.datasets.animation.numbers.properties.concat(["q1","q3","min","max","median","whiskerMin","whiskerMax"],B.filter(t=>!t.endsWith("Color")))}}},dataElementType:S.id,dataElementOptions:e.BarController.defaults.dataElementOptions.concat(B)}]);class E extends e.Chart{constructor(t,r){super(t,T("boxplot",r,I,S,[e.LinearScale,e.CategoryScale]))}}E.id=I.id;class O extends N{_parseStats(t,e){return y(t,e)}_toStringStats(t){return`(min: ${t.min}, 25% quantile: ${t.q1}, median: ${t.median}, 75% quantile: ${t.q3}, max: ${t.max})`}_transformStats(t,e,r){for(const i of["min","max","median","q3","q1"])t[i]=r(e[i]);t.maxEstimate=e.maxEstimate;for(const i of["items","outliers"])Array.isArray(e[i])&&(t[i]=e[i].map(r));Array.isArray(e.coords)&&(t.coords=e.coords.map(t=>Object.assign({},t,{v:r(t.v)})))}}O.id="violin",O.defaults=r.merge({},[e.BarController.defaults,M(v),{datasets:{points:100,animation:{numbers:{type:"number",properties:e.BarController.defaults.datasets.animation.numbers.properties.concat(["q1","q3","min","max","median","maxEstimate"],v.filter(t=>!t.endsWith("Color")))},kdeCoords:{fn:function(t,e,r){return Array.isArray(t)&&Array.isArray(e)?e.map((e,i)=>({v:b.number(t[i]?t[i].v:null,e.v,r),estimate:b.number(t[i]?t[i].estimate:null,e.estimate,r)})):e},properties:["coords"]}}},dataElementType:A.id,dataElementOptions:e.BarController.defaults.dataElementOptions.concat(v)}]);class R extends e.Chart{constructor(t,r){super(t,T("violin",r,O,A,[e.LinearScale,e.CategoryScale]))}}R.id=O.id,e.registry.addControllers(I,O),e.registry.addElements(S,A),t.BoxAndWiskers=S,t.BoxPlotChart=E,t.BoxPlotController=I,t.StatsBase=P,t.Violin=A,t.ViolinChart=R,t.ViolinController=O,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.umd.min.js.map |
{ | ||
"name": "@sgratzl/chartjs-chart-boxplot", | ||
"description": "Chart.js module for charting boxplots and violin charts", | ||
"version": "3.0.0-beta.4", | ||
"version": "3.0.0-beta.6", | ||
"publishConfig": { | ||
@@ -62,36 +62,36 @@ "access": "public" | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^15.1.0", | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
"@rollup/plugin-replace": "^2.3.3", | ||
"@rollup/plugin-typescript": "^6.0.0", | ||
"@rollup/plugin-commonjs": "^16.0.0", | ||
"@rollup/plugin-node-resolve": "^10.0.0", | ||
"@rollup/plugin-replace": "^2.3.4", | ||
"@rollup/plugin-typescript": "^6.1.0", | ||
"@types/jest": "^26.0.15", | ||
"@types/jest-image-snapshot": "^4.1.2", | ||
"@types/node": "^14.14.0", | ||
"@typescript-eslint/eslint-plugin": "^4.5.0", | ||
"@typescript-eslint/parser": "^4.5.0", | ||
"@types/jest-image-snapshot": "^4.1.3", | ||
"@types/node": "^14.14.7", | ||
"@typescript-eslint/eslint-plugin": "^4.7.0", | ||
"@typescript-eslint/parser": "^4.7.0", | ||
"@yarnpkg/pnpify": "^2.3.3", | ||
"canvas": "^2.6.1", | ||
"chart.js": "^3.0.0-beta.4", | ||
"eslint": "^7.11.0", | ||
"eslint-config-prettier": "^6.13.0", | ||
"eslint-config-react-app": "^5.2.1", | ||
"chart.js": "^3.0.0-beta.6", | ||
"eslint": "^7.13.0", | ||
"eslint-config-prettier": "^6.15.0", | ||
"eslint-config-react-app": "^6.0.0", | ||
"eslint-plugin-flowtype": "^5.2.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jsx-a11y": "^6.3.1", | ||
"eslint-plugin-jsx-a11y": "^6.4.1", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"eslint-plugin-react": "^7.21.5", | ||
"eslint-plugin-react-hooks": "^4.2.0", | ||
"jest": "^26.6.0", | ||
"jest": "^26.6.3", | ||
"jest-image-snapshot": "^4.2.0", | ||
"prettier": "^2.1.2", | ||
"release-it": "^14.2.0", | ||
"release-it": "^14.2.1", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.32.1", | ||
"rollup": "^2.33.1", | ||
"rollup-plugin-cleanup": "^3.2.1", | ||
"rollup-plugin-dts": "^1.4.13", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"ts-jest": "^26.4.1", | ||
"ts-jest": "^26.4.4", | ||
"tslib": "^2.0.3", | ||
"typedoc": "^0.19.2", | ||
"typescript": "^4.0.3" | ||
"typescript": "^4.0.5" | ||
}, | ||
@@ -98,0 +98,0 @@ "scripts": { |
/// <reference types="jest" /> | ||
/// <reference types="node" /> | ||
import { Chart, IChartConfiguration, defaults, IChartType, DefaultDataPoint } from 'chart.js'; | ||
import { Chart, ChartConfiguration, defaults, ChartType, DefaultDataPoint } from 'chart.js'; | ||
import { toMatchImageSnapshot, MatchImageSnapshotOptions } from 'jest-image-snapshot'; | ||
@@ -25,6 +25,6 @@ | ||
export default function createChart< | ||
TYPE extends IChartType, | ||
TYPE extends ChartType, | ||
DATA extends unknown[] = DefaultDataPoint<TYPE>, | ||
LABEL = string | ||
>(config: IChartConfiguration<TYPE, DATA, LABEL>, width = 300, height = 300) { | ||
>(config: ChartConfiguration<TYPE, DATA, LABEL>, width = 800, height = 600) { | ||
const canvas = document.createElement('canvas'); | ||
@@ -31,0 +31,0 @@ canvas.width = width; |
import { interpolateNumberArray } from '../animation'; | ||
import { outlierPositioner, patchInHoveredOutlier } from '../tooltip'; | ||
import { BarController, Element, IChartMeta, LinearScale, Scale, UpdateMode } from 'chart.js'; | ||
import { BarController, Element, ChartMeta, LinearScale, Scale, UpdateMode } from 'chart.js'; | ||
import { defaultStatsOptions, IBaseOptions } from '../data'; | ||
@@ -63,3 +63,3 @@ | ||
parsePrimitiveData(meta: IChartMeta, data: any[], start: number, count: number) { | ||
parsePrimitiveData(meta: ChartMeta, data: any[], start: number, count: number) { | ||
const vScale = meta.vScale!; | ||
@@ -83,7 +83,7 @@ const iScale = meta.iScale!; | ||
parseArrayData(meta: IChartMeta, data: any[], start: number, count: number) { | ||
parseArrayData(meta: ChartMeta, data: any[], start: number, count: number) { | ||
return this.parsePrimitiveData(meta, data, start, count); | ||
} | ||
parseObjectData(meta: IChartMeta, data: any[], start: number, count: number) { | ||
parseObjectData(meta: ChartMeta, data: any[], start: number, count: number) { | ||
return this.parsePrimitiveData(meta, data, start, count); | ||
@@ -90,0 +90,0 @@ } |
import createChart from '../__tests__/createChart'; | ||
import { BoxPlotController, IBoxPlotDataPoint } from './BoxPlotController'; | ||
import { BoxPlotController, BoxPlotDataPoint } from './BoxPlotController'; | ||
import { Samples } from './__tests__/utils'; | ||
import { registry, BarController, LineController, Point, Rectangle, Line } from 'chart.js'; | ||
import { registry, BarController, LineController, PointElement, BarElement, LineElement } from 'chart.js'; | ||
import { BoxAndWiskers } from '../elements'; | ||
@@ -23,3 +23,3 @@ | ||
registry.addControllers(BoxPlotController, BarController, LineController); | ||
registry.addElements(BoxAndWiskers, Point, Rectangle, Line); | ||
registry.addElements(BoxAndWiskers, PointElement, BarElement, LineElement); | ||
}); | ||
@@ -30,3 +30,3 @@ | ||
const chart = createChart<'boxplot', IBoxPlotDataPoint[]>({ | ||
const chart = createChart<'boxplot', BoxPlotDataPoint[]>({ | ||
type: BoxPlotController.id, | ||
@@ -148,3 +148,3 @@ data: { | ||
const chart = createChart<'boxplot', IBoxPlotDataPoint[]>({ | ||
const chart = createChart<'boxplot', BoxPlotDataPoint[]>({ | ||
type: BoxPlotController.id, | ||
@@ -246,3 +246,3 @@ data: { | ||
const chart = createChart<'boxplot', IBoxPlotDataPoint[]>({ | ||
const chart = createChart<'boxplot', BoxPlotDataPoint[]>({ | ||
type: BoxPlotController.id, | ||
@@ -249,0 +249,0 @@ data: { |
@@ -5,10 +5,10 @@ import { asBoxPlotStats, IBaseStats, IBoxPlot, IBoxplotOptions } from '../data'; | ||
BarController, | ||
IControllerDatasetOptions, | ||
ControllerDatasetOptions, | ||
ScriptableAndArrayOptions, | ||
ICommonHoverOptions, | ||
CommonHoverOptions, | ||
ChartItem, | ||
IChartConfiguration, | ||
ChartConfiguration, | ||
LinearScale, | ||
CategoryScale, | ||
ICartesianScaleTypeRegistry, | ||
CartesianScaleTypeRegistry, | ||
} from 'chart.js'; | ||
@@ -63,9 +63,9 @@ import { merge } from 'chart.js/helpers'; | ||
export interface IBoxPlotControllerDatasetOptions | ||
extends IControllerDatasetOptions, | ||
export interface BoxPlotControllerDatasetOptions | ||
extends ControllerDatasetOptions, | ||
IBoxplotOptions, | ||
ScriptableAndArrayOptions<IBoxAndWhiskersOptions>, | ||
ScriptableAndArrayOptions<ICommonHoverOptions> {} | ||
ScriptableAndArrayOptions<CommonHoverOptions> {} | ||
export type IBoxPlotDataPoint = number[] | (Partial<IBoxPlot> & IBaseStats); | ||
export type BoxPlotDataPoint = number[] | (Partial<IBoxPlot> & IBaseStats); | ||
@@ -76,12 +76,8 @@ // eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
declare module 'chart.js' { | ||
export enum ChartTypeEnum { | ||
boxplot = 'boxplot', | ||
} | ||
export interface IChartTypeRegistry { | ||
export interface ChartTypeRegistry { | ||
boxplot: { | ||
chartOptions: IBoxPlotChartOptions; | ||
datasetOptions: IBoxPlotControllerDatasetOptions; | ||
defaultDataPoint: IBoxPlotDataPoint[]; | ||
scales: keyof ICartesianScaleTypeRegistry; | ||
datasetOptions: BoxPlotControllerDatasetOptions; | ||
defaultDataPoint: BoxPlotDataPoint[]; | ||
scales: keyof CartesianScaleTypeRegistry; | ||
}; | ||
@@ -91,3 +87,3 @@ } | ||
export class BoxPlotChart<DATA extends unknown[] = IBoxPlotDataPoint[], LABEL = string> extends Chart< | ||
export class BoxPlotChart<DATA extends unknown[] = BoxPlotDataPoint[], LABEL = string> extends Chart< | ||
'boxplot', | ||
@@ -99,5 +95,5 @@ DATA, | ||
constructor(item: ChartItem, config: Omit<IChartConfiguration<'boxplot', DATA, LABEL>, 'type'>) { | ||
constructor(item: ChartItem, config: Omit<ChartConfiguration<'boxplot', DATA, LABEL>, 'type'>) { | ||
super(item, patchController('boxplot', config, BoxPlotController, BoxAndWiskers, [LinearScale, CategoryScale])); | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { registry, IDatasetControllerChartComponent, IChartComponent } from 'chart.js'; | ||
import { registry, DatasetControllerChartComponent, ChartComponent } from 'chart.js'; | ||
@@ -6,5 +6,5 @@ export default function patchController<T, TYPE>( | ||
config: T, | ||
controller: IDatasetControllerChartComponent, | ||
elements: IChartComponent | IChartComponent[] = [], | ||
scales: IChartComponent | IChartComponent[] = [] | ||
controller: DatasetControllerChartComponent, | ||
elements: ChartComponent | ChartComponent[] = [], | ||
scales: ChartComponent | ChartComponent[] = [] | ||
): T & { type: TYPE } { | ||
@@ -11,0 +11,0 @@ registry.addControllers(controller); |
@@ -6,9 +6,9 @@ import { asViolinStats, IBaseStats, IViolin, IViolinOptions } from '../data'; | ||
ChartItem, | ||
IControllerDatasetOptions, | ||
ControllerDatasetOptions, | ||
ScriptableAndArrayOptions, | ||
ICommonHoverOptions, | ||
IChartConfiguration, | ||
CommonHoverOptions, | ||
ChartConfiguration, | ||
LinearScale, | ||
CategoryScale, | ||
ICartesianScaleTypeRegistry, | ||
CartesianScaleTypeRegistry, | ||
} from 'chart.js'; | ||
@@ -73,9 +73,9 @@ import { merge } from 'chart.js/helpers'; | ||
export interface IViolinControllerDatasetOptions | ||
extends IControllerDatasetOptions, | ||
export interface ViolinControllerDatasetOptions | ||
extends ControllerDatasetOptions, | ||
IViolinOptions, | ||
ScriptableAndArrayOptions<IViolinElementOptions>, | ||
ScriptableAndArrayOptions<ICommonHoverOptions> {} | ||
ScriptableAndArrayOptions<CommonHoverOptions> {} | ||
export type IViolinDataPoint = number[] | (Partial<IViolin> & IBaseStats); | ||
export type ViolinDataPoint = number[] | (Partial<IViolin> & IBaseStats); | ||
@@ -86,12 +86,8 @@ // eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
declare module 'chart.js' { | ||
export enum ChartTypeEnum { | ||
violin = 'violin', | ||
} | ||
export interface IChartTypeRegistry { | ||
export interface ChartTypeRegistry { | ||
violin: { | ||
chartOptions: IViolinChartOptions; | ||
datasetOptions: IViolinControllerDatasetOptions; | ||
defaultDataPoint: IViolinDataPoint[]; | ||
scales: keyof ICartesianScaleTypeRegistry; | ||
datasetOptions: ViolinControllerDatasetOptions; | ||
defaultDataPoint: ViolinDataPoint[]; | ||
scales: keyof CartesianScaleTypeRegistry; | ||
}; | ||
@@ -101,3 +97,3 @@ } | ||
export class ViolinChart<DATA extends unknown[] = IViolinDataPoint[], LABEL = string> extends Chart< | ||
export class ViolinChart<DATA extends unknown[] = ViolinDataPoint[], LABEL = string> extends Chart< | ||
'violin', | ||
@@ -109,5 +105,5 @@ DATA, | ||
constructor(item: ChartItem, config: Omit<IChartConfiguration<'violin', DATA, LABEL>, 'type'>) { | ||
constructor(item: ChartItem, config: Omit<ChartConfiguration<'violin', DATA, LABEL>, 'type'>) { | ||
super(item, patchController('violin', config, ViolinController, Violin, [LinearScale, CategoryScale])); | ||
} | ||
} |
import { Element } from 'chart.js'; | ||
import { drawPoint } from 'chart.js/helpers'; | ||
import { rnd } from '../data'; | ||
import { IExtendedTooltip } from '../tooltip'; | ||
import { ExtendedTooltip } from '../tooltip'; | ||
@@ -322,3 +322,3 @@ export interface IStatsBaseOptions { | ||
tooltipPosition(eventPosition?: { x: number; y: number } | boolean, tooltip?: IExtendedTooltip) { | ||
tooltipPosition(eventPosition?: { x: number; y: number } | boolean, tooltip?: ExtendedTooltip) { | ||
if (!eventPosition || typeof eventPosition === 'boolean') { | ||
@@ -325,0 +325,0 @@ // fallback |
@@ -1,2 +0,2 @@ | ||
import { Rectangle } from 'chart.js'; | ||
import { BarElement } from 'chart.js'; | ||
import { StatsBase, baseDefaults, baseOptionKeys, baseRoutes, IStatsBaseOptions, IStatsBaseProps } from './base'; | ||
@@ -217,7 +217,7 @@ | ||
static id = 'boxandwhiskers'; | ||
static defaults = /*#__PURE__*/ Object.assign({}, Rectangle.defaults, baseDefaults, { | ||
static defaults = /*#__PURE__*/ Object.assign({}, BarElement.defaults, baseDefaults, { | ||
medianColor: 'transparent', | ||
lowerBackgroundColor: 'transparent', | ||
}); | ||
static defaultRoutes = /*#__PURE__*/ Object.assign({}, Rectangle.defaultRoutes, baseRoutes); | ||
static defaultRoutes = /*#__PURE__*/ Object.assign({}, BarElement.defaultRoutes, baseRoutes); | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Rectangle } from 'chart.js'; | ||
import { BarElement } from 'chart.js'; | ||
import { drawPoint } from 'chart.js/helpers'; | ||
@@ -104,4 +104,4 @@ import { IKDEPoint } from '../data'; | ||
static id = 'violin'; | ||
static defaults = /*#__PURE__*/ Object.assign({}, Rectangle.defaults, baseDefaults); | ||
static defaultRoutes = /*#__PURE__*/ Object.assign({}, Rectangle.defaultRoutes, baseRoutes); | ||
static defaults = /*#__PURE__*/ Object.assign({}, BarElement.defaults, baseDefaults); | ||
static defaultRoutes = /*#__PURE__*/ Object.assign({}, BarElement.defaultRoutes, baseRoutes); | ||
} |
@@ -1,4 +0,4 @@ | ||
import { InteractionItem, ITooltipItem, Tooltip, TooltipModel } from 'chart.js'; | ||
import { InteractionItem, TooltipItem, Tooltip, TooltipModel } from 'chart.js'; | ||
export interface IExtendedTooltip extends TooltipModel { | ||
export interface ExtendedTooltip extends TooltipModel { | ||
_tooltipOutlier?: { | ||
@@ -10,5 +10,5 @@ index: number; | ||
export function patchInHoveredOutlier(this: TooltipModel, item: ITooltipItem) { | ||
export function patchInHoveredOutlier(this: TooltipModel, item: TooltipItem) { | ||
const value = item.formattedValue as any; | ||
const that = this as IExtendedTooltip; | ||
const that = this as ExtendedTooltip; | ||
if (value && that._tooltipOutlier != null && item.datasetIndex === that._tooltipOutlier.datasetIndex) { | ||
@@ -15,0 +15,0 @@ value.hoveredOutlierIndex = that._tooltipOutlier.index; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
333682
5106