Merge branch 'master' of https://github.com/antvis/g6 into dev3.1.0

This commit is contained in:
baizn 2019-10-28 10:51:22 +08:00
commit 8984d308ad
5 changed files with 1426 additions and 9 deletions

View File

@ -1,7 +1,7 @@
# Contribution Guide # Contribution Guide
If you have any comment or advice, please report your [issue](https://github.com/antvis/g2/issues), If you have any comment or advice, please report your [issue](https://github.com/antvis/g6/issues),
or make any change as you wish and submit an [PR](https://github.com/antvis/g2/pulls). or make any change as you wish and submit an [PR](https://github.com/antvis/g6/pulls).
## Reporting New Issues ## Reporting New Issues
@ -30,14 +30,14 @@ $ git commit -m "fix(role): role.use must xxx"
$ git push origin branch-name $ git push origin branch-name
``` ```
Then you can create a Pull Request at [g2](https://github.com/antvis/g2/pulls). Then you can create a Pull Request at [g6](https://github.com/antvis/g6/pulls).
No one can guarantee how much will be remembered about certain PR after some time. To make sure we can easily recap what happened previously, please provide the following information in your PR. No one can guarantee how much will be remembered about certain PR after some time. To make sure we can easily recap what happened previously, please provide the following information in your PR.
1. Need: What function you want to achieve (Generally, please point out which issue is related). 1. Need: What function you want to achieve (Generally, please point out which issue is related).
2. Updating Reason: Different with issue. Briefly describe your reason and logic about why you need to make such modification. 2. Updating Reason: Different with issue. Briefly describe your reason and logic about why you need to make such modification.
3. Related Testing: Briefly describe what part of testing is relevant to your modification. 3. Related Testing: Briefly describe what part of testing is relevant to your modification.
4. User Tips: Notice for g2 users. You can skip this part, if the PR is not about update in API or potential compatibility problem. 4. User Tips: Notice for g6 users. You can skip this part, if the PR is not about update in API or potential compatibility problem.
### Style Guide ### Style Guide
@ -95,7 +95,7 @@ Older IEs serialize html uppercased, but IE9 does not...
Would be better to expect case insensitive, unfortunately jasmine does Would be better to expect case insensitive, unfortunately jasmine does
not allow to user regexps for throw expectations. not allow to user regexps for throw expectations.
Document change on antvis/g2#123 Document change on antvis/g6#123
Closes #392 Closes #392

View File

@ -1,7 +1,7 @@
# 代码贡献规范 # 代码贡献规范
有任何疑问,欢迎提交 [issue](https://github.com/antvis/g2/issues) 有任何疑问,欢迎提交 [issue](https://github.com/antvis/g6/issues)
或者直接修改提交 [PR](https://github.com/antvis/g2/pulls)! 或者直接修改提交 [PR](https://github.com/antvis/g6/pulls)!
## 提交 issue ## 提交 issue
@ -31,7 +31,7 @@ $ git commit -m "fix(role): role.use must xxx"
$ git push origin branch-name $ git push origin branch-name
``` ```
提交后就可以在 [g2](https://github.com/antvis/g2/pulls) 创建 Pull Request 了。 提交后就可以在 [g6](https://github.com/antvis/g6/pulls) 创建 Pull Request 了。
由于谁也无法保证过了多久之后还记得多少,为了后期回溯历史的方便,请在提交 MR 时确保提供了以下信息。 由于谁也无法保证过了多久之后还记得多少,为了后期回溯历史的方便,请在提交 MR 时确保提供了以下信息。
@ -97,7 +97,7 @@ Older IEs serialize html uppercased, but IE9 does not...
Would be better to expect case insensitive, unfortunately jasmine does Would be better to expect case insensitive, unfortunately jasmine does
not allow to user regexps for throw expectations. not allow to user regexps for throw expectations.
Document change on antvis/g2#12 Document change on antvis/g6#12
Closes #392 Closes #392

View File

@ -3,6 +3,7 @@
"version": "3.1.3", "version": "3.1.3",
"description": "graph visualization frame work", "description": "graph visualization frame work",
"main": "build/g6.js", "main": "build/g6.js",
"types": "types/index.d.ts",
"homepage": "https://github.com/antvis/g6", "homepage": "https://github.com/antvis/g6",
"author": "https://github.com/orgs/antvis/people", "author": "https://github.com/orgs/antvis/people",
"repository": { "repository": {

256
types/g.d.ts vendored Normal file
View File

@ -0,0 +1,256 @@
export namespace G {
export type ShapeType =
| 'arc'
| 'circle'
| 'dom'
| 'ellipse'
| 'fan'
| 'image'
| 'line'
| 'marker'
| 'path'
| 'polygon'
| 'polyline'
| 'rect'
| 'text';
type Item = Shape | Group;
type Cfg = { [k in string]: any };
type Attrs = { [k in string]: any };
interface Box {
x: number;
y: number;
minX: number;
minY: number;
maxX: number;
maxY: number;
}
export interface Group extends Element {
new (cfg: Cfg): Group;
isGroup: true;
type: 'group';
canFill: boolean;
canStroke: boolean;
getDefaultCfg(): Cfg;
addShape(type: ShapeType, cfg: Cfg): Shape;
/**
* @param {Function|Object|undefined} param
* @param {Object} cfg
* @return {Object} rst
*/
addGroup(param: Function | Cfg | undefined, cfg: Cfg): Group;
/**
* @param {Array} padding
* @param {Attrs} attrs
* @return {Object}
*/
renderBack(padding: [number, number, number, number], attrs: Attrs): Shape;
removeChild(item: Item, destroy: boolean): this;
/**
* shape或者group
* @param {Object} items
* @return {Object} group
*/
add(items: Item[]): this;
contain(item: Item): boolean;
getChildByIndex(index: number): any;
getFirst(): Item;
getLast(): Item;
getBBox(): Box;
getCount(): number;
sort(): this;
findById(): Item;
/**
*
* @param {Function} fn
* @return {Canvas.Base}
*/
find(fn: Function | string): Item;
/**
* @param {Function} fn filter mathod
* @return {Array} all the matching shapes and groups
*/
findAll(fn: (...args: any[]) => boolean): Item[];
/**
* @Deprecated
*/
findBy: Function;
/**
* @Deprecated
*/
findAllBy: Function;
getShape(x: any, y: any): Shape;
clearTotalMatrix(): void;
clear(delayRemove?: boolean): this;
destroy(): void;
clone(): Group;
}
export interface Shape extends Element {
new (cfg: Cfg): Shape;
isPointInPath(x: number, y: number): boolean;
isShape: true;
drawInner(context: any): void;
/**
*
* @return {Boolean} [description]
*/
isHitBox(): boolean;
/**
*
* @param {Number} x x坐标
* @param {Number} y y坐标
* @return {Boolean}
*/
isHit(x: number, y: number): boolean;
/**
* 线线
*/
getHitLineWidth(): number;
/**
*
*/
clearTotalMatrix(): void;
clearBBox(): void;
getBBox(): Box;
clone(): Shape;
}
interface Element extends Attribute, Transform, Animate, AdvancedEventEmitter {
new (): Element;
init(): void;
getParent(): Element;
/**
*
* @protected
* @return {Object}
*/
getDefaultCfg(): Cfg;
set(name: string, value: any): this;
/**
* @deprecated
*/
setSilent: Function;
get(name: string): any;
show(): this;
hide(): this;
remove(destroy: boolean | undefined, delayRemove?: boolean): this;
destroy(): void;
toFront(): void;
toBack(): void;
setZIndex(zIndex: number): number;
clone(): Element;
getBBox(): any;
}
interface Attribute {
canFill: boolean;
canStroke: boolean;
initAttrs(attrs: Attrs): this;
/**
* @protected
*/
getDefaultAttrs(): any;
/**
* 4
* - name ,
* - name value
* - name value this
* - name value
*
* @param {String | Object} name
* @param {*} value
* @return {*}
*/
attr(): Attrs;
attr(name: string): any;
attr(name: string, value: any): this;
attr(attrs: Attrs): this;
clearBBox(): void;
hasFill(): boolean;
hasStroke(): boolean;
}
interface Transform {
initTransform(): void;
resetMatrix(): void;
translate(tx: number, ty: number): this;
rotate(radian: number): this;
scale(s1: number, s2: number): this;
rotateAtStart(rotate: number): this;
move(x: number, y: number): this;
transform(ts: [string, number, number?]): this;
setTransform(ts: [string, number, number?]): this;
getMatrix(): any;
setMatrix(m: any): this;
apply(v: any, root: any): this;
getTotalMatrix(): any;
clearTotalMatrix: Function;
invert(v: any): this;
resetTransform(context: any): void;
}
interface Animate {
/**
*
* @param {Object} toProps
* @param {Number} duration
* @param {String} easing
* @param {Function} callback
* @param {Number} delay
*/
animate(
toProps: { onFrame?: any; repeat?: any },
duration: number,
easing: string,
callback: Function,
delay: number,
): void;
stopAnimate(): void;
pauseAnimate(): this;
resumeAnimate(): this;
}
interface AdvancedEventEmitter extends EventEmitter {
new (): AdvancedEventEmitter;
emit(evt: string, e?: Event): void;
}
interface EventEmitter {
new (): EventEmitter;
on(evt: string, callback: Function, one: any): this;
one(evt: string, callback: Function): this;
emit(evt: string): void;
trigger(): void;
off(evt: string, callback: Function): this | undefined;
removeEvent(): this;
}
}

1160
types/index.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff