Skip to content

Type declarations #998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"type": "module",
"main": "src/index.js",
"module": "src/index.js",
"types": "src/index.d.ts",
"jsdelivr": "dist/plot.umd.min.js",
"unpkg": "dist/plot.umd.min.js",
"exports": {
Expand All @@ -22,10 +23,12 @@
},
"files": [
"dist/**/*.js",
"src/**/*.js"
"src/**/*.js",
"src/**/*.d.ts"
],
"scripts": {
"test": "mkdir -p test/output && mocha -r module-alias/register 'test/**/*-test.js' test/plot.js && eslint src test",
"test-types": "npx tsd",
"prepublishOnly": "rm -rf dist && rollup -c",
"postpublish": "git push && git push --tags",
"dev": "vite"
Expand All @@ -46,6 +49,7 @@
"module-alias": "2",
"rollup": "2",
"rollup-plugin-terser": "7",
"tsd": "^0.20.0",
"vite": "2"
},
"dependencies": {
Expand Down
45 changes: 45 additions & 0 deletions src/axes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
export function Axes({ x: xScale, y: yScale, fx: fxScale, fy: fyScale }: {
x: any;
y: any;
fx: any;
fy: any;
}, { x, y, fx, fy, axis, grid, line, label, facet: { axis: facetAxis, grid: facetGrid, label: facetLabel } }?: {
x?: {};
y?: {};
fx?: {};
fy?: {};
axis?: boolean;
grid: any;
line: any;
label: any;
facet?: {
axis?: any;
grid: any;
label?: any;
};
}): {
fy: AxisY;
fx: AxisX;
y: AxisY;
x: AxisX;
};
export function autoAxisTicks({ x, y, fx, fy }: {
x: any;
y: any;
fx: any;
fy: any;
}, { x: xAxis, y: yAxis, fx: fxAxis, fy: fyAxis }: {
x: any;
y: any;
fx: any;
fy: any;
}): void;
export function autoScaleLabels(channels: any, scales: any, { x, y, fx, fy }: {
x: any;
y: any;
fx: any;
fy: any;
}, dimensions: any, options: any): void;
export function inferFontVariant(scale: any): string;
import { AxisY } from "./axis.js";
import { AxisX } from "./axis.js";
97 changes: 97 additions & 0 deletions src/axis.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
export function maybeAutoTickFormat(tickFormat: any, domain: any): any;
export class AxisX {
constructor({ name, axis, ticks, tickSize, tickPadding, tickFormat, fontVariant, grid, label, labelAnchor, labelOffset, line, tickRotate, ariaLabel, ariaDescription }?: {
name?: string;
axis: any;
ticks: any;
tickSize?: number;
tickPadding?: number;
tickFormat: any;
fontVariant: any;
grid: any;
label: any;
labelAnchor: any;
labelOffset: any;
line: any;
tickRotate: any;
ariaLabel: any;
ariaDescription: any;
});
name: any;
axis: string;
ticks: any;
tickSize: any;
tickPadding: any;
tickFormat: any;
fontVariant: any;
grid: any;
label: any;
labelAnchor: string;
labelOffset: any;
line: any;
tickRotate: any;
ariaLabel: any;
ariaDescription: any;
render(index: any, { [this.name]: x, fy }: {
fy: any;
}, { width, height, marginTop, marginRight, marginBottom, marginLeft, offsetLeft, facetMarginTop, facetMarginBottom, labelMarginLeft, labelMarginRight }: {
width: any;
height: any;
marginTop: any;
marginRight: any;
marginBottom: any;
marginLeft: any;
offsetLeft?: number;
facetMarginTop: any;
facetMarginBottom: any;
labelMarginLeft?: number;
labelMarginRight?: number;
}): any;
}
export class AxisY {
constructor({ name, axis, ticks, tickSize, tickPadding, tickFormat, fontVariant, grid, label, labelAnchor, labelOffset, line, tickRotate, ariaLabel, ariaDescription }?: {
name?: string;
axis: any;
ticks: any;
tickSize?: number;
tickPadding?: number;
tickFormat: any;
fontVariant: any;
grid: any;
label: any;
labelAnchor: any;
labelOffset: any;
line: any;
tickRotate: any;
ariaLabel: any;
ariaDescription: any;
});
name: any;
axis: string;
ticks: any;
tickSize: any;
tickPadding: any;
tickFormat: any;
fontVariant: any;
grid: any;
label: any;
labelAnchor: string;
labelOffset: any;
line: any;
tickRotate: any;
ariaLabel: any;
ariaDescription: any;
render(index: any, { [this.name]: y, fx }: {
fx: any;
}, { width, height, marginTop, marginRight, marginBottom, marginLeft, offsetTop, facetMarginLeft, facetMarginRight }: {
width: any;
height: any;
marginTop: any;
marginRight: any;
marginBottom: any;
marginLeft: any;
offsetTop?: number;
facetMarginLeft: any;
facetMarginRight: any;
}): any;
}
25 changes: 25 additions & 0 deletions src/channel.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export declare function Channel(data: string | any[], { scale, type, value, filter, hint }: {
value: any;
scale: string;
}): {
scale: string;
type: any;
value: any;
label: undefined;
filter: any;
hint: any;
};
export declare function channelSort(channels: {
find: (arg0: ([, { scale }]: [any, {
scale: any;
}]) => boolean) => any;
}, facetChannels: {
find: (arg0: ([, { scale }]: [any, {
scale: any;
}]) => boolean) => any;
}, data: any, options: {
[x: string]: any;
reverse?: any;
reduce?: any;
limit?: any;
}): void;
1 change: 1 addition & 0 deletions src/curve.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export function Curve(curve: any, tension: any): any;
8 changes: 8 additions & 0 deletions src/defined.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export function defined(x: any): boolean;
export function ascendingDefined(a: any, b: any): any;
export function descendingDefined(a: any, b: any): any;
export function nonempty(x: any): boolean;
export function finite(x: any): any;
export function positive(x: any): any;
export function negative(x: any): any;
export function firstof(...values: any[]): any;
44 changes: 44 additions & 0 deletions src/dimensions.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
export declare function Dimensions(scales: {
y?: any;
fy?: any;
fx?: any;
}, { x: { axis: xAxis }, y: { axis: yAxis }, fx: { axis: fxAxis }, fy: { axis: fyAxis } }: {
x?: {
axis: any;
};
y?: {
axis: any;
};
fx?: {
axis: any;
};
fy?: {
axis: any;
};
}, { width, height, facet: { margin: facetMargin, marginTop: facetMarginTop, marginRight: facetMarginRight, marginBottom: facetMarginBottom, marginLeft: facetMarginLeft }, margin, marginTop, marginRight, marginBottom, marginLeft }?: {
width?: number;
height?: number;
facet?: {
margin: any;
marginTop?: any;
marginRight?: any;
marginBottom?: any;
marginLeft?: any;
};
margin: any;
marginTop?: any;
marginRight?: any;
marginBottom?: any;
marginLeft?: any;
}): {
width: number;
height: number;
marginTop: any;
marginRight: any;
marginBottom: any;
marginLeft: any;
facetMarginTop: any;
facetMarginRight: any;
facetMarginBottom: any;
facetMarginLeft: any;
};
6 changes: 6 additions & 0 deletions src/format.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export function formatNumber(locale?: string): (i: any) => any;
export function formatMonth(locale?: string, month?: string): (i: any) => any;
export function formatWeekday(locale?: string, weekday?: string): (i: any) => any;
export function formatIsoDate(date: any): any;
export function formatAuto(locale?: string): (v: any) => any;
export function formatDefault(v: any): any;
39 changes: 39 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export { scale } from "./scales.js";
export { legend } from "./legends.js";
export { plot, Mark, marks, MarkProperties, MarkChannelDefinition, StandardMarkOptions } from "./plot.js";
export { Area, area, areaX, areaY } from "./marks/area.js";
export { Arrow, arrow } from "./marks/arrow.js";
export { BarX, BarY, barX, barY } from "./marks/bar.js";
export { boxX, boxY } from "./marks/box.js";
export { Cell, cell, cellX, cellY } from "./marks/cell.js";
export { Dot, dot, dotX, dotY } from "./marks/dot.js";
export { Frame, frame } from "./marks/frame.js";
export { Image, image } from "./marks/image.js";
export { Line, line, lineX, lineY } from "./marks/line.js";
export { Link, link } from "./marks/link.js";
export { Rect, rect, rectX, rectY, RectOptions } from "./marks/rect.js";
export { RuleX, RuleY, ruleX, ruleY } from "./marks/rule.js";
export { Text, text, textX, textY } from "./marks/text.js";
export { TickX, TickY, tickX, tickY } from "./marks/tick.js";
export { tree, cluster } from "./marks/tree.js";
export { Vector, vector, vectorX, vectorY } from "./marks/vector.js";
export { valueof, column } from "./options.js";
export { AggregationMethod } from "./transforms";
export { filter, reverse, sort, shuffle, basic as transform } from "./transforms/basic.js";
export {
bin,
binX,
binY,
BinOptions,
ReduceMethod as BinReduceMethod,
ReduceMethodWithScope as BinReduceMethodWithScope,
ReducerObject as BinReducerObject,
ReduceMethodExtent as BinReduceMethodExtent } from "./transforms/bin.js";
export { group, groupX, groupY, groupZ } from "./transforms/group.js";
export { normalize, normalizeX, normalizeY } from "./transforms/normalize.js";
export { map, mapX, mapY } from "./transforms/map.js";
export { window, windowX, windowY } from "./transforms/window.js";
export { select, selectFirst, selectLast, selectMaxX, selectMaxY, selectMinX, selectMinY } from "./transforms/select.js";
export { stackX, stackX1, stackX2, stackY, stackY1, stackY2 } from "./transforms/stack.js";
export { treeNode, treeLink } from "./transforms/tree.js";
export { formatIsoDate, formatWeekday, formatMonth } from "./format.js";
9 changes: 9 additions & 0 deletions src/legends.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export declare function legend(options?: {}): any;
export declare function exposeLegends(scales: {
[x: string]: any;
}, defaults?: {}): (key: string, options: {} | undefined) => any;
export declare function Legends(scales: {
[x: string]: any;
}, options: {
[x: string]: any;
}): any[];
16 changes: 16 additions & 0 deletions src/legends/ramp.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export function legendRamp(color: any, { label, tickSize, width, height, marginTop, marginRight, marginBottom, marginLeft, style, ticks, tickFormat, fontVariant, round, className }: {
label?: any;
tickSize?: number;
width?: number;
height?: any;
marginTop?: number;
marginRight?: number;
marginBottom?: any;
marginLeft?: number;
style: any;
ticks?: number;
tickFormat: any;
fontVariant?: string;
round?: boolean;
className: any;
}): any;
9 changes: 9 additions & 0 deletions src/legends/swatches.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export function legendSwatches(color: any, options: any): any;
export function legendSymbols(symbol: any, { fill, fillOpacity, stroke, strokeOpacity, strokeWidth, r, ...options }: {
fill?: any;
fillOpacity?: number;
stroke?: any;
strokeOpacity?: number;
strokeWidth?: number;
r?: number;
}, scale: any): any;
14 changes: 14 additions & 0 deletions src/marks/area.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export function area(data: any, options: any): Area;
export function areaX(data: any, options: any): Area;
export function areaY(data: any, options: any): Area;
export class Area extends Mark<any, any[]> {
constructor(data: any, options?: {});
z: any;
curve: any;
filter(index: any): any;
render(I: any, { x, y }: {
x: any;
y: any;
}, channels: any, dimensions: any): any;
}
import { Mark } from "../plot.js";
21 changes: 21 additions & 0 deletions src/marks/arrow.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export function arrow(data: any, { x, x1, x2, y, y1, y2, ...options }?: {
x: any;
x1: any;
x2: any;
y: any;
y1: any;
y2: any;
}): Arrow;
export class Arrow extends Mark<any, any[]> {
constructor(data: any, options?: {});
bend: number;
headAngle: number;
headLength: number;
insetStart: number;
insetEnd: number;
render(index: any, { x, y }: {
x: any;
y: any;
}, channels: any, dimensions: any): any;
}
import { Mark } from "../plot.js";
Loading