Skip to content
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

Fix/59 - TS typedef #67

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
67 changes: 50 additions & 17 deletions types/d3-svg-annotation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ type Components = any[];
type Orientation = 'topBottom' | 'leftRight' | 'fixed';
type Align = 'dynamic' | 'left' | 'right' | 'top' | 'bottom' | 'middle';
type LineType = 'horizontal' | 'vertical' | 'none';
type AnnotationEvent =
| 'subjectover'
| 'subjectout'
| 'subjectclick'
| 'connectorover'
| 'connectorout'
| 'connectorclick'
| 'noteover'
| 'noteout'
| 'noteclick'
| 'dragend'
| 'dragstart';

type BBox = {
x: number,
Expand All @@ -19,6 +31,36 @@ type BBox = {
height: number
};

interface AnnotationConfig {
classname: string;
color?: string;
connector?: {
end?: string;
endScale?: number;
type?: string;
points?: any[];
};
data: any;
disable?: Array<'connector' | 'subject' | 'note'>;
dx?: number;
dy?: number;
id: string | number;
note?: {
label?: string | number;
title?: string | number;
wrap?: number;
align?: Align;
};
nx?: number;
ny?: number;
subject?: {
radius?: number;
};
type?: any;
x?: number;
y?: number;
}

export default class Annotation<T> {

className: string;
Expand All @@ -45,31 +87,22 @@ export default class Annotation<T> {
dy: number;
};

constructor({ x, y, dy, dx, data, type, subject, connector, note, disable, id, className }: {
x?: number;
y?: number;
dy?: number;
dx?: number;
data: any;
type: any;
subject: any;
connector: any;
note: any;
disable: any;
id: any;
className: string;
});
constructor(args: AnnotationConfig);

annotations(anotations: any[]): Annotation<T>;
annotations(anotations: AnnotationConfig[]): Annotation<T>;
accessors(accessors: { x?: (datum: T) => any, y?: (datum: T) => any }): Annotation<T>;
accessorsInverse(accessors: any): Annotation<T>;
editMode(editMode: boolean): Annotation<T>;
notePadding(padding: number): Annotation<T>;
type(type: any): Annotation<T>;
updatePosition(): void;
updateOffset(): void;
update(): void;
updatedAccessors(): void;
update(): Annotation<T>;
updatedAccessors(): Annotation<T>;
on(
event: AnnotationEvent,
callback: (target: Annotation<T>) => void
): Annotation<T>;
}

export class Type<T> {
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ are-we-there-yet@~1.1.2:

argparse@^1.0.7:
version "1.0.10"
resolved "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==
dependencies:
sprintf-js "~1.0.2"
Expand Down Expand Up @@ -1978,7 +1978,7 @@ esprima@^3.1.3:

esprima@^4.0.0:
version "4.0.1"
resolved "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==

esrecurse@^4.1.0:
Expand Down Expand Up @@ -3366,9 +3366,9 @@ js-tokens@^3.0.2:
integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls=

js-yaml@^3.5.1, js-yaml@^3.7.0:
version "3.13.0"
resolved "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.0.tgz#38ee7178ac0eea2c97ff6d96fff4b18c7d8cf98e"
integrity sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ==
version "3.13.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"
integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
dependencies:
argparse "^1.0.7"
esprima "^4.0.0"
Expand Down Expand Up @@ -5037,7 +5037,7 @@ split-string@^3.0.1, split-string@^3.0.2:

sprintf-js@~1.0.2:
version "1.0.3"
resolved "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=

sshpk@^1.7.0:
Expand Down