@sgratzl/chartjs-chart-boxplot
Advanced tools
Comparing version 4.2.0 to 4.2.1
@@ -8,11 +8,4 @@ /** | ||
import { TooltipModel, Element, ChartType, ScriptableAndArrayOptions, CommonHoverOptions, ScriptableContext, BarController, Scale, ChartMeta, UpdateMode, CartesianScaleTypeRegistry, ControllerDatasetOptions, AnimationOptions, Chart, ChartItem, ChartConfiguration } from 'chart.js'; | ||
import { Element, ChartType, ScriptableAndArrayOptions, CommonHoverOptions, ScriptableContext, BarController, CartesianScaleTypeRegistry, ControllerDatasetOptions, AnimationOptions, Chart, ChartItem, ChartConfiguration, TooltipModel } from 'chart.js'; | ||
interface ExtendedTooltip extends TooltipModel<'boxplot' | 'violin'> { | ||
_tooltipOutlier?: { | ||
index: number; | ||
datasetIndex: number; | ||
}; | ||
} | ||
interface IStatsBaseOptions { | ||
@@ -51,38 +44,2 @@ backgroundColor: string; | ||
}, O extends IStatsBaseOptions> extends Element<T, O> { | ||
_datasetIndex: number; | ||
horizontal: boolean; | ||
_index: number; | ||
isVertical(): boolean; | ||
protected _drawItems(ctx: CanvasRenderingContext2D): void; | ||
protected _drawOutliers(ctx: CanvasRenderingContext2D): void; | ||
protected _drawMeanDot(ctx: CanvasRenderingContext2D): void; | ||
_getBounds(_useFinalPosition?: boolean): { | ||
left: number; | ||
top: number; | ||
right: number; | ||
bottom: number; | ||
}; | ||
_getHitBounds(useFinalPosition?: boolean): { | ||
left: number; | ||
top: number; | ||
right: number; | ||
bottom: number; | ||
}; | ||
inRange(mouseX: number, mouseY: number, useFinalPosition?: boolean): boolean; | ||
inXRange(mouseX: number, useFinalPosition?: boolean): boolean; | ||
inYRange(mouseY: number, useFinalPosition?: boolean): boolean; | ||
protected _outlierIndexInRange(mouseX: number, mouseY: number, useFinalPosition?: boolean): number; | ||
protected _boxInRange(mouseX: number, mouseY: number, useFinalPosition?: boolean): boolean; | ||
getCenterPoint(useFinalPosition?: boolean): { | ||
x: number; | ||
y: number; | ||
}; | ||
protected _getOutliers(useFinalPosition?: boolean): number[]; | ||
tooltipPosition(eventPosition?: { | ||
x: number; | ||
y: number; | ||
} | boolean, tooltip?: ExtendedTooltip): { | ||
x: number; | ||
y: number; | ||
}; | ||
} | ||
@@ -103,37 +60,2 @@ | ||
declare class BoxAndWiskers extends StatsBase$1<IBoxAndWhiskerProps, IBoxAndWhiskersOptions> { | ||
draw(ctx: CanvasRenderingContext2D): void; | ||
protected _drawBoxPlot(ctx: CanvasRenderingContext2D): void; | ||
protected _drawBoxPlotVertical(ctx: CanvasRenderingContext2D): void; | ||
protected _drawBoxPlotHorizontal(ctx: CanvasRenderingContext2D): void; | ||
_getBounds(useFinalPosition?: boolean): { | ||
left: number; | ||
top: number; | ||
right: number; | ||
bottom: number; | ||
}; | ||
static id: string; | ||
static defaults: { | ||
medianColor: string; | ||
lowerBackgroundColor: string; | ||
borderWidth: number; | ||
outlierStyle: string; | ||
outlierRadius: number; | ||
outlierBorderWidth: number; | ||
itemStyle: string; | ||
itemRadius: number; | ||
itemBorderWidth: number; | ||
meanStyle: string; | ||
meanRadius: number; | ||
meanBorderWidth: number; | ||
hitPadding: number; | ||
outlierHitRadius: number; | ||
}; | ||
static defaultRoutes: { | ||
outlierBackgroundColor: string; | ||
outlierBorderColor: string; | ||
itemBackgroundColor: string; | ||
itemBorderColor: string; | ||
meanBackgroundColor: string; | ||
meanBorderColor: string; | ||
}; | ||
} | ||
@@ -193,33 +115,2 @@ declare module 'chart.js' { | ||
declare class Violin extends StatsBase$1<IViolinElementProps, IViolinElementOptions> { | ||
draw(ctx: CanvasRenderingContext2D): void; | ||
protected _drawCoords(ctx: CanvasRenderingContext2D, props: Pick<IViolinElementProps, 'x' | 'coords' | 'y' | 'maxEstimate' | 'width' | 'height' | 'min' | 'max'>): void; | ||
_getBounds(useFinalPosition?: boolean): { | ||
left: number; | ||
top: number; | ||
right: number; | ||
bottom: number; | ||
}; | ||
static id: string; | ||
static defaults: { | ||
borderWidth: number; | ||
outlierStyle: string; | ||
outlierRadius: number; | ||
outlierBorderWidth: number; | ||
itemStyle: string; | ||
itemRadius: number; | ||
itemBorderWidth: number; | ||
meanStyle: string; | ||
meanRadius: number; | ||
meanBorderWidth: number; | ||
hitPadding: number; | ||
outlierHitRadius: number; | ||
}; | ||
static defaultRoutes: { | ||
outlierBackgroundColor: string; | ||
outlierBorderColor: string; | ||
itemBackgroundColor: string; | ||
itemBorderColor: string; | ||
meanBackgroundColor: string; | ||
meanBorderColor: string; | ||
}; | ||
} | ||
@@ -233,34 +124,10 @@ declare module 'chart.js' { | ||
declare abstract class StatsBase<S extends IBaseStats, C extends Required<IBaseOptions>> extends BarController { | ||
options: C; | ||
protected _transformStats<T>(target: any, source: S, mapper: (v: number) => T): void; | ||
getMinMax(scale: Scale, canStack?: boolean | undefined): { | ||
min: number; | ||
max: number; | ||
}; | ||
parsePrimitiveData(meta: ChartMeta, data: any[], start: number, count: number): Record<string, unknown>[]; | ||
parseArrayData(meta: ChartMeta, data: any[], start: number, count: number): Record<string, unknown>[]; | ||
parseObjectData(meta: ChartMeta, data: any[], start: number, count: number): Record<string, unknown>[]; | ||
protected abstract _parseStats(value: any, options: C): S | undefined; | ||
getLabelAndValue(index: number): { | ||
label: string; | ||
value: string & { | ||
raw: S; | ||
hoveredOutlierIndex: number; | ||
} & S; | ||
}; | ||
protected _toStringStats(b: S): string; | ||
updateElement(rectangle: Element, index: number, properties: any, mode: UpdateMode): void; | ||
} | ||
declare class BoxPlotController extends StatsBase<IBoxPlot, Required<IBoxplotOptions>> { | ||
protected _parseStats(value: unknown, config: IBoxplotOptions): IBoxPlot | undefined; | ||
protected _transformStats<T>(target: any, source: IBoxPlot, mapper: (v: number) => T): void; | ||
static readonly id = "boxplot"; | ||
static readonly defaults: any; | ||
static readonly overrides: any; | ||
} | ||
interface BoxPlotControllerDatasetOptions extends ControllerDatasetOptions, IBoxplotOptions, ScriptableAndArrayOptions<IBoxAndWhiskersOptions, ScriptableContext<'boxplot'>>, ScriptableAndArrayOptions<CommonHoverOptions, ScriptableContext<'boxplot'>>, AnimationOptions<'boxplot'> { | ||
} | ||
type BoxPlotDataPoint = number[] | (Partial<IBoxPlot> & IBaseStats); | ||
interface IBoxPlotChartOptions { | ||
type BoxPlotDataPoint = number[] | (Partial<IBoxPlot> & Pick<IBoxPlot, 'min' | 'max' | 'median' | 'q1' | 'q3'>); | ||
interface IBoxPlotChartOptions extends IBoxplotOptions { | ||
} | ||
@@ -280,3 +147,2 @@ declare module 'chart.js' { | ||
declare class BoxPlotChart<DATA extends unknown[] = BoxPlotDataPoint[], LABEL = string> extends Chart<'boxplot', DATA, LABEL> { | ||
static id: string; | ||
constructor(item: ChartItem, config: Omit<ChartConfiguration<'boxplot', DATA, LABEL>, 'type'>); | ||
@@ -286,12 +152,7 @@ } | ||
declare class ViolinController extends StatsBase<IViolin, Required<IViolinOptions>> { | ||
protected _parseStats(value: any, config: IViolinOptions): IViolin | undefined; | ||
protected _transformStats<T>(target: any, source: IViolin, mapper: (v: number) => T): void; | ||
static readonly id = "violin"; | ||
static readonly defaults: any; | ||
static readonly overrides: any; | ||
} | ||
type ViolinDataPoint = number[] | (Partial<IViolin> & IBaseStats); | ||
type ViolinDataPoint = number[] | (Partial<IViolin> & Pick<IViolin, 'median' | 'coords'>); | ||
interface ViolinControllerDatasetOptions extends ControllerDatasetOptions, IViolinOptions, ScriptableAndArrayOptions<IViolinElementOptions, ScriptableContext<'violin'>>, ScriptableAndArrayOptions<CommonHoverOptions, ScriptableContext<'violin'>>, AnimationOptions<'violin'> { | ||
} | ||
interface IViolinChartOptions { | ||
interface IViolinChartOptions extends IViolinOptions { | ||
} | ||
@@ -315,3 +176,10 @@ declare module 'chart.js' { | ||
export { BoxAndWiskers, BoxPlotChart, BoxPlotController, BoxPlotControllerDatasetOptions, BoxPlotDataPoint, IBoxAndWhiskerProps, IBoxAndWhiskersOptions, IBoxPlotChartOptions, IStatsBaseOptions, IStatsBaseProps, IViolinChartOptions, IViolinElementOptions, IViolinElementProps, StatsBase$1 as StatsBase, Violin, ViolinChart, ViolinController, ViolinControllerDatasetOptions, ViolinDataPoint }; | ||
interface ExtendedTooltip extends TooltipModel<'boxplot' | 'violin'> { | ||
_tooltipOutlier?: { | ||
index: number; | ||
datasetIndex: number; | ||
}; | ||
} | ||
export { BoxAndWiskers, BoxPlotChart, BoxPlotController, BoxPlotControllerDatasetOptions, BoxPlotDataPoint, ExtendedTooltip, IBaseOptions, IBaseStats, IBoxAndWhiskerProps, IBoxAndWhiskersOptions, IBoxPlot, IBoxPlotChartOptions, IBoxplotOptions, IKDEPoint, IStatsBaseOptions, IStatsBaseProps, IViolin, IViolinChartOptions, IViolinElementOptions, IViolinElementProps, IViolinOptions, QuantileMethod, StatsBase$1 as StatsBase, Violin, ViolinChart, ViolinController, ViolinControllerDatasetOptions, ViolinDataPoint }; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@sgratzl/chartjs-chart-boxplot", | ||
"description": "Chart.js module for charting boxplots and violin charts", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"publishConfig": { | ||
@@ -76,16 +76,16 @@ "access": "public" | ||
"@chiogen/rollup-plugin-terser": "^7.1.3", | ||
"@rollup/plugin-commonjs": "^24.1.0", | ||
"@rollup/plugin-node-resolve": "^15.0.2", | ||
"@rollup/plugin-commonjs": "^25.0.2", | ||
"@rollup/plugin-node-resolve": "^15.1.0", | ||
"@rollup/plugin-replace": "^5.0.2", | ||
"@rollup/plugin-typescript": "^11.1.0", | ||
"@types/jest": "^29.5.1", | ||
"@rollup/plugin-typescript": "^11.1.2", | ||
"@types/jest": "^29.5.2", | ||
"@types/jest-image-snapshot": "^6.1.0", | ||
"@types/node": "^18.16.3", | ||
"@typescript-eslint/eslint-plugin": "^5.59.1", | ||
"@typescript-eslint/parser": "^5.59.1", | ||
"@yarnpkg/sdks": "^2.7.0", | ||
"@types/node": "^20.3.3", | ||
"@typescript-eslint/eslint-plugin": "^5.61.0", | ||
"@typescript-eslint/parser": "^5.61.0", | ||
"@yarnpkg/sdks": "^2.7.1", | ||
"canvas": "^2.11.2", | ||
"canvas-5-polyfill": "^0.1.5", | ||
"chart.js": "^4.3.0", | ||
"eslint": "^8.39.0", | ||
"eslint": "^8.44.0", | ||
"eslint-config-airbnb-typescript": "^17.0.0", | ||
@@ -100,14 +100,19 @@ "eslint-config-prettier": "^8.8.0", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"jest": "^29.5.0", | ||
"jest-environment-jsdom": "^29.5.0", | ||
"jest": "^29.6.0", | ||
"jest-environment-jsdom": "^29.6.0", | ||
"jest-image-snapshot": "^6.1.0", | ||
"prettier": "^2.8.8", | ||
"rimraf": "^5.0.0", | ||
"rollup": "^3.21.1", | ||
"rimraf": "^5.0.1", | ||
"rollup": "^3.26.0", | ||
"rollup-plugin-cleanup": "^3.2.1", | ||
"rollup-plugin-dts": "^5.3.0", | ||
"ts-jest": "^29.1.0", | ||
"tslib": "^2.5.0", | ||
"typedoc": "^0.24.6", | ||
"typescript": "^5.0.4" | ||
"ts-jest": "^29.1.1", | ||
"tslib": "^2.6.0", | ||
"typedoc": "^0.24.8", | ||
"typedoc-plugin-markdown": "^4.0.0-next.16", | ||
"typedoc-vitepress-theme": "^1.0.0-next.2", | ||
"typescript": "^5.1.6", | ||
"vitepress": "^1.0.0-beta.5", | ||
"vue": "^3.3.4", | ||
"vue-chartjs": "^5.2.0" | ||
}, | ||
@@ -123,3 +128,2 @@ "scripts": { | ||
"test:coverage": "yarn run test --coverage", | ||
"samples": "yarn tsc samples/type_test.ts", | ||
"lint": "yarn run eslint && yarn run prettier", | ||
@@ -131,14 +135,9 @@ "fix": "yarn run eslint:fix && yarn run prettier:write", | ||
"eslint:fix": "yarn run eslint --fix", | ||
"docs": "typedoc src/index.ts", | ||
"prepare": "yarn run build" | ||
"prepare": "yarn run build", | ||
"docs:api": "typedoc --options typedoc.json", | ||
"docs:dev": "vitepress dev docs", | ||
"docs:build": "yarn run docs:api && vitepress build docs", | ||
"docs:preview": "vitepress preview docs" | ||
}, | ||
"packageManager": "yarn@3.5.0", | ||
"dependenciesMeta": { | ||
"chart.js@4.0.1": { | ||
"unplugged": true | ||
}, | ||
"chart.js@4.1.2": { | ||
"unplugged": true | ||
} | ||
} | ||
"packageManager": "yarn@3.6.1" | ||
} |
@@ -10,18 +10,6 @@ # Chart.js Box and Violin Plot | ||
## Related Plugins | ||
Check out also my other chart.js plugins: | ||
- [chartjs-chart-error-bars](https://github.com/sgratzl/chartjs-chart-error-bars) for rendering errors bars to bars and line charts | ||
- [chartjs-chart-geo](https://github.com/sgratzl/chartjs-chart-geo) for rendering map, bubble maps, and choropleth charts | ||
- [chartjs-chart-graph](https://github.com/sgratzl/chartjs-chart-graph) for rendering graphs, trees, and networks | ||
- [chartjs-chart-pcp](https://github.com/sgratzl/chartjs-chart-pcp) for rendering parallel coordinate plots | ||
- [chartjs-chart-venn](https://github.com/sgratzl/chartjs-chart-venn) for rendering venn and euler diagrams | ||
- [chartjs-chart-wordcloud](https://github.com/sgratzl/chartjs-chart-wordcloud) for rendering word clouds | ||
- [chartjs-plugin-hierarchical](https://github.com/sgratzl/chartjs-plugin-hierarchical) for rendering hierarchical categorical axes which can be expanded and collapsed | ||
## Install | ||
```bash | ||
npm install --save chart.js @sgratzl/chartjs-chart-boxplot | ||
npm install chart.js @sgratzl/chartjs-chart-boxplot | ||
``` | ||
@@ -31,3 +19,3 @@ | ||
see [Samples](https://github.com/sgratzl/chartjs-chart-box-and-violin-plot/tree/main/samples) on Github | ||
see [Examples](https://sgratzl.com/chartjs-chart-boxplot/examples/) | ||
@@ -81,3 +69,3 @@ and [![Open in CodePen][codepen]](https://codepen.io/sgratzl/pen/QxoLoY) | ||
### ESM and Tree Shaking | ||
## ESM and Tree Shaking | ||
@@ -112,2 +100,14 @@ The ESM build of the library supports tree shaking thus having no side effects. As a consequence the chart.js library won't be automatically manipulated nor new controllers automatically registered. One has to manually import and register them. | ||
## Related Plugins | ||
Check out also my other chart.js plugins: | ||
- [chartjs-chart-error-bars](https://github.com/sgratzl/chartjs-chart-error-bars) for rendering errors bars to bars and line charts | ||
- [chartjs-chart-geo](https://github.com/sgratzl/chartjs-chart-geo) for rendering map, bubble maps, and choropleth charts | ||
- [chartjs-chart-graph](https://github.com/sgratzl/chartjs-chart-graph) for rendering graphs, trees, and networks | ||
- [chartjs-chart-pcp](https://github.com/sgratzl/chartjs-chart-pcp) for rendering parallel coordinate plots | ||
- [chartjs-chart-venn](https://github.com/sgratzl/chartjs-chart-venn) for rendering venn and euler diagrams | ||
- [chartjs-chart-wordcloud](https://github.com/sgratzl/chartjs-chart-wordcloud) for rendering word clouds | ||
- [chartjs-plugin-hierarchical](https://github.com/sgratzl/chartjs-plugin-hierarchical) for rendering hierarchical categorical axes which can be expanded and collapsed | ||
## Development Environment | ||
@@ -114,0 +114,0 @@ |
@@ -16,3 +16,3 @@ import { | ||
import { merge } from 'chart.js/helpers'; | ||
import { asBoxPlotStats, IBaseStats, IBoxPlot, IBoxplotOptions } from '../data'; | ||
import { asBoxPlotStats, IBoxPlot, IBoxplotOptions } from '../data'; | ||
import { baseDefaults, StatsBase, defaultOverrides } from './StatsBase'; | ||
@@ -24,2 +24,5 @@ import { BoxAndWiskers, IBoxAndWhiskersOptions } from '../elements'; | ||
export class BoxPlotController extends StatsBase<IBoxPlot, Required<IBoxplotOptions>> { | ||
/** | ||
* @internal | ||
*/ | ||
// eslint-disable-next-line class-methods-use-this | ||
@@ -30,2 +33,5 @@ protected _parseStats(value: unknown, config: IBoxplotOptions): IBoxPlot | undefined { | ||
/** | ||
* @internal | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
@@ -40,4 +46,10 @@ protected _transformStats<T>(target: any, source: IBoxPlot, mapper: (v: number) => T): void { | ||
/** | ||
* @internal | ||
*/ | ||
static readonly id = 'boxplot'; | ||
/** | ||
* @internal | ||
*/ | ||
static readonly defaults: any = /* #__PURE__ */ merge({}, [ | ||
@@ -60,2 +72,5 @@ BarController.defaults, | ||
/** | ||
* @internal | ||
*/ | ||
static readonly overrides: any = /* #__PURE__ */ merge({}, [(BarController as any).overrides, defaultOverrides()]); | ||
@@ -71,6 +86,6 @@ } | ||
export type BoxPlotDataPoint = number[] | (Partial<IBoxPlot> & IBaseStats); | ||
export type BoxPlotDataPoint = number[] | (Partial<IBoxPlot> & Pick<IBoxPlot, 'min' | 'max' | 'median' | 'q1' | 'q3'>); | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface IBoxPlotChartOptions {} | ||
export interface IBoxPlotChartOptions extends IBoxplotOptions {} | ||
@@ -95,2 +110,5 @@ declare module 'chart.js' { | ||
> { | ||
/** | ||
* @internal | ||
*/ | ||
static id = BoxPlotController.id; | ||
@@ -97,0 +115,0 @@ |
@@ -6,3 +6,5 @@ import { BarController, Element, ChartMeta, LinearScale, Scale, UpdateMode } from 'chart.js'; | ||
import { defaultStatsOptions, IBaseOptions, IBaseStats } from '../data'; | ||
/** | ||
* @internal | ||
*/ | ||
export /* #__PURE__ */ function baseDefaults(keys: string[]): Record<string, unknown> { | ||
@@ -61,4 +63,10 @@ const colorKeys = ['borderColor', 'backgroundColor'].concat(keys.filter((c) => c.endsWith('Color'))); | ||
export abstract class StatsBase<S extends IBaseStats, C extends Required<IBaseOptions>> extends BarController { | ||
/** | ||
* @internal | ||
*/ | ||
declare options: C; | ||
/** | ||
* @internal | ||
*/ | ||
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types | ||
@@ -81,2 +89,5 @@ protected _transformStats<T>(target: any, source: S, mapper: (v: number) => T): void { | ||
/** | ||
* @internal | ||
*/ | ||
getMinMax(scale: Scale, canStack?: boolean | undefined): { min: number; max: number } { | ||
@@ -96,2 +107,5 @@ const bak = scale.axis; | ||
/** | ||
* @internal | ||
*/ | ||
parsePrimitiveData(meta: ChartMeta, data: any[], start: number, count: number): Record<string, unknown>[] { | ||
@@ -118,2 +132,5 @@ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
/** | ||
* @internal | ||
*/ | ||
parseArrayData(meta: ChartMeta, data: any[], start: number, count: number): Record<string, unknown>[] { | ||
@@ -123,2 +140,5 @@ return this.parsePrimitiveData(meta, data, start, count); | ||
/** | ||
* @internal | ||
*/ | ||
parseObjectData(meta: ChartMeta, data: any[], start: number, count: number): Record<string, unknown>[] { | ||
@@ -128,5 +148,10 @@ return this.parsePrimitiveData(meta, data, start, count); | ||
/** | ||
* @internal | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
protected abstract _parseStats(value: any, options: C): S | undefined; | ||
/** | ||
* @internal | ||
*/ | ||
getLabelAndValue(index: number): { label: string; value: string & { raw: S; hoveredOutlierIndex: number } & S } { | ||
@@ -156,2 +181,5 @@ const r = super.getLabelAndValue(index) as any; | ||
/** | ||
* @internal | ||
*/ | ||
// eslint-disable-next-line class-methods-use-this | ||
@@ -166,2 +194,5 @@ protected _toStringStats(b: S): string { | ||
/** | ||
* @internal | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
@@ -168,0 +199,0 @@ updateElement(rectangle: Element, index: number, properties: any, mode: UpdateMode): void { |
@@ -16,3 +16,3 @@ import { | ||
import { merge } from 'chart.js/helpers'; | ||
import { asViolinStats, IBaseStats, IViolin, IViolinOptions } from '../data'; | ||
import { asViolinStats, IViolin, IViolinOptions } from '../data'; | ||
import { StatsBase, baseDefaults, defaultOverrides } from './StatsBase'; | ||
@@ -25,2 +25,5 @@ import { baseOptionKeys } from '../elements/base'; | ||
export class ViolinController extends StatsBase<IViolin, Required<IViolinOptions>> { | ||
/** | ||
* @internal | ||
*/ | ||
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types | ||
@@ -31,2 +34,5 @@ protected _parseStats(value: any, config: IViolinOptions): IViolin | undefined { | ||
/** | ||
* @internal | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
@@ -43,4 +49,10 @@ protected _transformStats<T>(target: any, source: IViolin, mapper: (v: number) => T): void { | ||
/** | ||
* @internal | ||
*/ | ||
static readonly id = 'violin'; | ||
/** | ||
* @internal | ||
*/ | ||
static readonly defaults: any = /* #__PURE__ */ merge({}, [ | ||
@@ -68,5 +80,8 @@ BarController.defaults, | ||
/** | ||
* @internal | ||
*/ | ||
static readonly overrides: any = /* #__PURE__ */ merge({}, [(BarController as any).overrides, defaultOverrides()]); | ||
} | ||
export type ViolinDataPoint = number[] | (Partial<IViolin> & IBaseStats); | ||
export type ViolinDataPoint = number[] | (Partial<IViolin> & Pick<IViolin, 'median' | 'coords'>); | ||
@@ -81,3 +96,3 @@ export interface ViolinControllerDatasetOptions | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface IViolinChartOptions {} | ||
export interface IViolinChartOptions extends IViolinOptions {} | ||
@@ -84,0 +99,0 @@ declare module 'chart.js' { |
@@ -150,2 +150,5 @@ import { | ||
/** | ||
* @internal | ||
*/ | ||
export const defaultStatsOptions = { | ||
@@ -184,2 +187,5 @@ coef: 1.5, | ||
/** | ||
* @internal | ||
*/ | ||
export function boxplotStats(arr: readonly number[] | Float32Array | Float64Array, options: IBaseOptions): IBoxPlot { | ||
@@ -219,2 +225,5 @@ const vs = | ||
/** | ||
* @internal | ||
*/ | ||
export function violinStats(arr: readonly number[], options: IViolinOptions): IViolin | undefined { | ||
@@ -250,2 +259,5 @@ // console.assert(Array.isArray(arr)); | ||
/** | ||
* @internal | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
@@ -278,2 +290,5 @@ export function asBoxPlotStats(value: any, options: IBoxplotOptions): IBoxPlot | undefined { | ||
/** | ||
* @internal | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
@@ -293,2 +308,5 @@ export function asViolinStats(value: any, options: IViolinOptions): IViolin | undefined { | ||
/** | ||
* @internal | ||
*/ | ||
export function rnd(seed = Date.now()): () => number { | ||
@@ -295,0 +313,0 @@ // Adapted from http://indiegamr.com/generate-repeatable-random-numbers-in-js/ |
@@ -185,2 +185,5 @@ import { Element } from 'chart.js'; | ||
/** | ||
* @internal | ||
*/ | ||
export const baseDefaults = { | ||
@@ -205,2 +208,5 @@ borderWidth: 1, | ||
/** | ||
* @internal | ||
*/ | ||
export const baseRoutes = { | ||
@@ -215,2 +221,5 @@ outlierBackgroundColor: 'backgroundColor', | ||
/** | ||
* @internal | ||
*/ | ||
export const baseOptionKeys = /* #__PURE__ */ (() => Object.keys(baseDefaults).concat(Object.keys(baseRoutes)))(); | ||
@@ -231,8 +240,20 @@ | ||
> { | ||
/** | ||
* @internal | ||
*/ | ||
declare _datasetIndex: number; | ||
/** | ||
* @internal | ||
*/ | ||
declare horizontal: boolean; | ||
/** | ||
* @internal | ||
*/ | ||
declare _index: number; | ||
/** | ||
* @internal | ||
*/ | ||
isVertical(): boolean { | ||
@@ -242,2 +263,5 @@ return !this.horizontal; | ||
/** | ||
* @internal | ||
*/ | ||
protected _drawItems(ctx: CanvasRenderingContext2D): void { | ||
@@ -282,2 +306,5 @@ const vert = this.isVertical(); | ||
/** | ||
* @internal | ||
*/ | ||
protected _drawOutliers(ctx: CanvasRenderingContext2D): void { | ||
@@ -314,2 +341,5 @@ const vert = this.isVertical(); | ||
/** | ||
* @internal | ||
*/ | ||
protected _drawMeanDot(ctx: CanvasRenderingContext2D): void { | ||
@@ -342,2 +372,5 @@ const vert = this.isVertical(); | ||
/** | ||
* @internal | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,class-methods-use-this | ||
@@ -354,2 +387,5 @@ _getBounds(_useFinalPosition?: boolean): { left: number; top: number; right: number; bottom: number } { | ||
/** | ||
* @internal | ||
*/ | ||
_getHitBounds(useFinalPosition?: boolean): { left: number; top: number; right: number; bottom: number } { | ||
@@ -366,2 +402,5 @@ const padding = this.options.hitPadding; | ||
/** | ||
* @internal | ||
*/ | ||
inRange(mouseX: number, mouseY: number, useFinalPosition?: boolean): boolean { | ||
@@ -377,2 +416,5 @@ if (Number.isNaN(this.x) && Number.isNaN(this.y)) { | ||
/** | ||
* @internal | ||
*/ | ||
inXRange(mouseX: number, useFinalPosition?: boolean): boolean { | ||
@@ -383,2 +425,5 @@ const bounds = this._getHitBounds(useFinalPosition); | ||
/** | ||
* @internal | ||
*/ | ||
inYRange(mouseY: number, useFinalPosition?: boolean): boolean { | ||
@@ -389,2 +434,5 @@ const bounds = this._getHitBounds(useFinalPosition); | ||
/** | ||
* @internal | ||
*/ | ||
protected _outlierIndexInRange(mouseX: number, mouseY: number, useFinalPosition?: boolean): number { | ||
@@ -409,2 +457,5 @@ const props = this.getProps(['x', 'y'], useFinalPosition); | ||
/** | ||
* @internal | ||
*/ | ||
protected _boxInRange(mouseX: number, mouseY: number, useFinalPosition?: boolean): boolean { | ||
@@ -415,2 +466,5 @@ const bounds = this._getHitBounds(useFinalPosition); | ||
/** | ||
* @internal | ||
*/ | ||
getCenterPoint(useFinalPosition?: boolean): { x: number; y: number } { | ||
@@ -424,2 +478,5 @@ const props = this.getProps(['x', 'y'], useFinalPosition); | ||
/** | ||
* @internal | ||
*/ | ||
protected _getOutliers(useFinalPosition?: boolean): number[] { | ||
@@ -430,2 +487,5 @@ const props = this.getProps(['outliers'], useFinalPosition); | ||
/** | ||
* @internal | ||
*/ | ||
tooltipPosition( | ||
@@ -432,0 +492,0 @@ eventPosition?: { x: number; y: number } | boolean, |
import { BarElement, ChartType, CommonHoverOptions, ScriptableAndArrayOptions, ScriptableContext } from 'chart.js'; | ||
import { StatsBase, baseDefaults, baseOptionKeys, baseRoutes, IStatsBaseOptions, IStatsBaseProps } from './base'; | ||
import { | ||
StatsBase, | ||
baseDefaults, | ||
baseOptionKeys, | ||
baseRoutes, | ||
type IStatsBaseOptions, | ||
type IStatsBaseProps, | ||
} from './base'; | ||
/** | ||
* @internal | ||
*/ | ||
export const boxOptionsKeys = baseOptionKeys.concat(['medianColor', 'lowerBackgroundColor']); | ||
@@ -34,2 +43,5 @@ | ||
export class BoxAndWiskers extends StatsBase<IBoxAndWhiskerProps, IBoxAndWhiskersOptions> { | ||
/** | ||
* @internal | ||
*/ | ||
draw(ctx: CanvasRenderingContext2D): void { | ||
@@ -51,2 +63,5 @@ ctx.save(); | ||
/** | ||
* @internal | ||
*/ | ||
protected _drawBoxPlot(ctx: CanvasRenderingContext2D): void { | ||
@@ -60,2 +75,5 @@ if (this.isVertical()) { | ||
/** | ||
* @internal | ||
*/ | ||
protected _drawBoxPlotVertical(ctx: CanvasRenderingContext2D): void { | ||
@@ -124,2 +142,5 @@ const { options } = this; | ||
/** | ||
* @internal | ||
*/ | ||
protected _drawBoxPlotHorizontal(ctx: CanvasRenderingContext2D): void { | ||
@@ -185,2 +206,5 @@ const { options } = this; | ||
/** | ||
* @internal | ||
*/ | ||
_getBounds(useFinalPosition?: boolean): { left: number; top: number; right: number; bottom: number } { | ||
@@ -223,4 +247,10 @@ const vert = this.isVertical(); | ||
/** | ||
* @internal | ||
*/ | ||
static id = 'boxandwhiskers'; | ||
/** | ||
* @internal | ||
*/ | ||
static defaults = /* #__PURE__ */ { | ||
@@ -233,2 +263,5 @@ ...BarElement.defaults, | ||
/** | ||
* @internal | ||
*/ | ||
static defaultRoutes = /* #__PURE__ */ { ...BarElement.defaultRoutes, ...baseRoutes }; | ||
@@ -235,0 +268,0 @@ } |
@@ -1,3 +0,3 @@ | ||
export { IStatsBaseOptions, IStatsBaseProps, StatsBase } from './base'; | ||
export { BoxAndWiskers, IBoxAndWhiskerProps, IBoxAndWhiskersOptions } from './BoxAndWiskers'; | ||
export { IViolinElementOptions, IViolinElementProps, Violin } from './Violin'; | ||
export { type IStatsBaseOptions, type IStatsBaseProps, StatsBase } from './base'; | ||
export { BoxAndWiskers, type IBoxAndWhiskerProps, type IBoxAndWhiskersOptions } from './BoxAndWiskers'; | ||
export { type IViolinElementOptions, type IViolinElementProps, Violin } from './Violin'; |
@@ -1,5 +0,11 @@ | ||
import { BarElement, ChartType, CommonHoverOptions, ScriptableAndArrayOptions, ScriptableContext } from 'chart.js'; | ||
import { | ||
BarElement, | ||
type ChartType, | ||
type CommonHoverOptions, | ||
type ScriptableAndArrayOptions, | ||
type ScriptableContext, | ||
} from 'chart.js'; | ||
import { drawPoint } from 'chart.js/helpers'; | ||
import type { IKDEPoint } from '../data'; | ||
import { StatsBase, baseDefaults, baseRoutes, IStatsBaseOptions, IStatsBaseProps } from './base'; | ||
import { StatsBase, baseDefaults, baseRoutes, type IStatsBaseOptions, type IStatsBaseProps } from './base'; | ||
@@ -17,2 +23,5 @@ export type IViolinElementOptions = IStatsBaseOptions; | ||
export class Violin extends StatsBase<IViolinElementProps, IViolinElementOptions> { | ||
/** | ||
* @internal | ||
*/ | ||
draw(ctx: CanvasRenderingContext2D): void { | ||
@@ -52,2 +61,5 @@ ctx.save(); | ||
/** | ||
* @internal | ||
*/ | ||
protected _drawCoords( | ||
@@ -95,2 +107,5 @@ ctx: CanvasRenderingContext2D, | ||
/** | ||
* @internal | ||
*/ | ||
_getBounds(useFinalPosition?: boolean): { left: number; top: number; right: number; bottom: number } { | ||
@@ -117,6 +132,15 @@ if (this.isVertical()) { | ||
/** | ||
* @internal | ||
*/ | ||
static id = 'violin'; | ||
/** | ||
* @internal | ||
*/ | ||
static defaults = /* #__PURE__ */ { ...BarElement.defaults, ...baseDefaults }; | ||
/** | ||
* @internal | ||
*/ | ||
static defaultRoutes = /* #__PURE__ */ { ...BarElement.defaultRoutes, ...baseRoutes }; | ||
@@ -123,0 +147,0 @@ } |
export * from './elements'; | ||
export * from './controllers'; | ||
export type { | ||
IBaseOptions, | ||
IBaseStats, | ||
IBoxPlot, | ||
IBoxplotOptions, | ||
IKDEPoint, | ||
IViolin, | ||
IViolinOptions, | ||
QuantileMethod, | ||
} from './data'; | ||
export type { ExtendedTooltip } from './tooltip'; |
@@ -10,2 +10,5 @@ import { InteractionItem, TooltipItem, Tooltip, TooltipModel } from 'chart.js'; | ||
/** | ||
* @internal | ||
*/ | ||
export function patchInHoveredOutlier( | ||
@@ -22,3 +25,6 @@ this: TooltipModel<'boxplot' | 'violin'>, | ||
// based on average positioner but allow access to the tooltip instance | ||
/** | ||
* based on average positioner but allow access to the tooltip instance | ||
* @internal | ||
*/ | ||
export function outlierPositioner( | ||
@@ -25,0 +31,0 @@ this: TooltipModel<'boxplot' | 'violin'>, |
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
5417
363135
41