mirror of
https://gitee.com/antv/g6.git
synced 2024-12-04 12:49:04 +08:00
lint: fix lint
This commit is contained in:
parent
1370d65e37
commit
559220b698
@ -22,6 +22,7 @@ module.exports = {
|
||||
'guard-for-in': 0,
|
||||
'no-restricted-globals': 0,
|
||||
'max-classes-per-file': 0,
|
||||
"@typescript-eslint/no-this-alias": 0,
|
||||
// 后面需要去掉
|
||||
'no-restricted-syntax': 0,
|
||||
'prefer-spread': 0,
|
||||
|
@ -18,15 +18,15 @@ export default {
|
||||
};
|
||||
},
|
||||
setAllItemStates(e: IG6GraphEvent) {
|
||||
const self = this;
|
||||
const item: INode = e.item as INode;
|
||||
const graph = this.graph;
|
||||
this.item = item;
|
||||
if (!this.shouldUpdate(e.item, { event: e, action: 'activate' })) {
|
||||
const graph = self.graph;
|
||||
self.item = item;
|
||||
if (!self.shouldUpdate(e.item, { event: e, action: 'activate' })) {
|
||||
return;
|
||||
}
|
||||
const self = this;
|
||||
const activeState = this.activeState;
|
||||
const inactiveState = this.inactiveState;
|
||||
const activeState = self.activeState;
|
||||
const inactiveState = self.inactiveState;
|
||||
const nodes = graph.getNodes();
|
||||
const edges = graph.getEdges();
|
||||
const nodeLength = nodes.length;
|
||||
|
@ -174,7 +174,7 @@ export default {
|
||||
this.updateViewport(e);
|
||||
}
|
||||
e.type = 'dragend';
|
||||
//graph.emit('canvas:dragend', e);
|
||||
// graph.emit('canvas:dragend', e);
|
||||
this.endDrag();
|
||||
},
|
||||
endDrag() {
|
||||
|
@ -252,10 +252,10 @@ export default {
|
||||
* @param evt
|
||||
*/
|
||||
onDropNode(evt: IG6GraphEvent) {
|
||||
if (!this.targets || this.targets.length === 0) return;
|
||||
const self = this;
|
||||
if (!self.targets || self.targets.length === 0) return;
|
||||
const item = evt.item as INode;
|
||||
this.updatePositions(evt);
|
||||
self.updatePositions(evt);
|
||||
const graph: IGraph = self.graph;
|
||||
|
||||
const comboId = item.getModel().comboId as string;
|
||||
@ -265,7 +265,7 @@ export default {
|
||||
if (self.comboActiveState) {
|
||||
graph.setItemState(combo, self.comboActiveState, false);
|
||||
}
|
||||
this.targets.map((node: INode) => {
|
||||
self.targets.map((node: INode) => {
|
||||
const nodeModel = node.getModel();
|
||||
if (comboId !== nodeModel.comboId) {
|
||||
graph.updateComboTree(node, comboId);
|
||||
@ -273,7 +273,7 @@ export default {
|
||||
});
|
||||
graph.updateCombo(combo as ICombo);
|
||||
} else {
|
||||
this.targets.map((node: INode) => {
|
||||
self.targets.map((node: INode) => {
|
||||
const model = node.getModel();
|
||||
if (model.comboId) {
|
||||
graph.updateComboTree(node);
|
||||
@ -283,7 +283,7 @@ export default {
|
||||
|
||||
// 将节点拖动到另外个节点上面,emit 事件抛出当前操作的节点及目标节点
|
||||
graph.emit('dragnodeend', {
|
||||
items: this.targets,
|
||||
items: self.targets,
|
||||
targetItem: item,
|
||||
});
|
||||
},
|
||||
|
@ -1,8 +1,4 @@
|
||||
import { G6Event, IG6GraphEvent } from '@antv/g6-core';
|
||||
import { mat3 } from '@antv/matrix-util';
|
||||
import { clone } from '@antv/util';
|
||||
|
||||
const DELTA = 0.05;
|
||||
import { G6Event } from '@antv/g6-core';
|
||||
|
||||
export default {
|
||||
firstScale: null,
|
||||
@ -37,8 +33,8 @@ export default {
|
||||
};
|
||||
},
|
||||
onPinch(evt) {
|
||||
evt.preventDefault || evt.preventDefault();
|
||||
evt.originalEvent.preventDefault || evt.originalEvent.preventDefault();
|
||||
if (evt.preventDefault) evt.preventDefault();
|
||||
if (evt.originalEvent.preventDefault) evt.originalEvent.preventDefault();
|
||||
|
||||
const pointers = evt.originalEvent.pointers;
|
||||
if (pointers.length < 2) return;
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { addEventListener } from '@antv/dom-util';
|
||||
import { ICanvas, IGroup, IShape } from '@antv/g-base';
|
||||
import { each, isNil, wrapBehavior } from '@antv/util';
|
||||
import { each, wrapBehavior } from '@antv/util';
|
||||
import { AbstractEvent, IG6GraphEvent, Matrix, Item, Util } from '@antv/g6-core';
|
||||
import Graph from '../graph';
|
||||
|
||||
const { cloneEvent, isViewportChanged } = Util;
|
||||
|
||||
type Fun = () => void;
|
||||
|
@ -138,7 +138,7 @@ export default class LayoutController extends AbstractLayout {
|
||||
private execLayoutMethod(layoutCfg, order): Promise<void> {
|
||||
return new Promise((reslove, reject) => {
|
||||
const { graph } = this;
|
||||
let layoutType = layoutCfg.type;
|
||||
const layoutType = layoutCfg.type;
|
||||
|
||||
// 每个布局方法都需要注册
|
||||
layoutCfg.onLayoutEnd = () => {
|
||||
|
@ -261,7 +261,7 @@ export default class Graph extends AbstractGraph implements IGraph {
|
||||
context.globalCompositeOperation = compositeOperation;
|
||||
}
|
||||
}
|
||||
callback && callback(dataURL);
|
||||
if (callback) callback(dataURL);
|
||||
}, 16);
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,23 @@ import Util from './util';
|
||||
import './element';
|
||||
import './behavior';
|
||||
|
||||
const G6 = {
|
||||
version: Global.version,
|
||||
Graph,
|
||||
Util,
|
||||
Layout,
|
||||
registerLayout,
|
||||
Global,
|
||||
registerBehavior,
|
||||
registerCombo,
|
||||
registerEdge,
|
||||
registerNode,
|
||||
Algorithm,
|
||||
Arrow,
|
||||
Marker,
|
||||
Shape
|
||||
};
|
||||
|
||||
function registerExtenderWrapper<T1, T2>(
|
||||
registerExtender: (registerName: T1, registerFunction: T2, global: Object) => Object,
|
||||
): (registerName: T1, registerFunction: T2) => Object {
|
||||
@ -26,23 +43,8 @@ function registerExtenderWrapper<T1, T2>(
|
||||
|
||||
const registerGraph = registerExtenderWrapper(oRegisterGraph);
|
||||
|
||||
const G6 = {
|
||||
version: Global.version,
|
||||
Graph,
|
||||
Util,
|
||||
Layout,
|
||||
registerLayout,
|
||||
registerGraph,
|
||||
Global,
|
||||
registerBehavior,
|
||||
registerCombo,
|
||||
registerEdge,
|
||||
registerNode,
|
||||
Algorithm,
|
||||
Arrow,
|
||||
Marker,
|
||||
Shape,
|
||||
};
|
||||
(G6 as any).registerGraph = registerGraph;
|
||||
|
||||
|
||||
export * from '@antv/g6-core';
|
||||
export * from './types';
|
||||
|
@ -9,13 +9,13 @@ export interface IGraph extends IAbstractGraph {
|
||||
/**
|
||||
* 返回图表的 dataUrl 用于生成图片
|
||||
*/
|
||||
toDataURL(): string;
|
||||
toDataURL: () => string;
|
||||
|
||||
/**
|
||||
* 画布导出图片
|
||||
* @param {String} name 图片的名称
|
||||
*/
|
||||
downloadImage(name?: string, type?: DataUrlType, backgroundColor?: string): void;
|
||||
downloadImage: (name?: string, type?: DataUrlType, backgroundColor?: string) => void;
|
||||
|
||||
/**
|
||||
* 导出包含全图的图片
|
||||
@ -23,11 +23,11 @@ export interface IGraph extends IAbstractGraph {
|
||||
* @param {String} type 图片类型,可选值:"image/png" | "image/jpeg" | "image/webp" | "image/bmp"
|
||||
* @param {Object} imageConfig 图片配置项,包括背景色和上下左右的 padding
|
||||
*/
|
||||
downloadFullImage(
|
||||
downloadFullImage: (
|
||||
name?: string,
|
||||
type?: DataUrlType,
|
||||
imageConfig?: { backgroundColor?: string; padding?: number | number[] },
|
||||
): void;
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* 返回整个图(包括超出可见区域的部分)的 dataUrl,用于生成图片
|
||||
@ -35,37 +35,37 @@ export interface IGraph extends IAbstractGraph {
|
||||
* @param {String} type 图片类型,可选值:"image/png" | "image/jpeg" | "image/webp" | "image/bmp"
|
||||
* @param {Object} imageConfig 图片配置项,包括背景色和上下左右的 padding
|
||||
*/
|
||||
toFullDataURL(
|
||||
toFullDataURL: (
|
||||
callback: (res: string) => any,
|
||||
type?: DataUrlType,
|
||||
imageConfig?: { backgroundColor?: string; padding?: number | number[] },
|
||||
): void;
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* 添加插件
|
||||
* @param {object} plugin 插件实例
|
||||
*/
|
||||
addPlugin(plugin: PluginBase): void;
|
||||
addPlugin: (plugin: PluginBase) => void;
|
||||
|
||||
/**
|
||||
* 添加插件
|
||||
* @param {object} plugin 插件实例
|
||||
*/
|
||||
removePlugin(plugin: PluginBase): void;
|
||||
removePlugin: (plugin: PluginBase) => void;
|
||||
|
||||
/**
|
||||
* 设置图片水印
|
||||
* @param {string} imgURL 图片水印的url地址
|
||||
* @param {WaterMarkerConfig} config 文本水印的配置项
|
||||
*/
|
||||
setImageWaterMarker(imgURL: string, config: WaterMarkerConfig);
|
||||
setImageWaterMarker: (imgURL: string, config: WaterMarkerConfig) => void;
|
||||
|
||||
/**
|
||||
* 设置文本水印
|
||||
* @param {string[]} texts 水印的文本内容
|
||||
* @param {WaterMarkerConfig} config 文本水印的配置项
|
||||
*/
|
||||
setTextWaterMarker(texts: string[], config?: WaterMarkerConfig);
|
||||
setTextWaterMarker: (texts: string[], config?: WaterMarkerConfig) => void;
|
||||
}
|
||||
|
||||
export interface ITreeGraph extends IGraph {
|
||||
@ -74,20 +74,20 @@ export interface ITreeGraph extends IGraph {
|
||||
* @param {TreeGraphData} data 子树数据模型
|
||||
* @param {string | Item} parent 子树的父节点id
|
||||
*/
|
||||
addChild(data: TreeGraphData, parent: string | Item): void;
|
||||
addChild: (data: TreeGraphData, parent: string | Item) => void;
|
||||
|
||||
/**
|
||||
* 更新源数据,差量更新子树
|
||||
* @param {TreeGraphData} data 子树数据模型
|
||||
* @param {string} parent 子树的父节点id
|
||||
*/
|
||||
updateChild(data: TreeGraphData, parent?: string): void;
|
||||
updateChild: (data: TreeGraphData, parent?: string) => void;
|
||||
|
||||
/**
|
||||
* 删除子树
|
||||
* @param {string} id 子树根节点id
|
||||
*/
|
||||
removeChild(id: string): void;
|
||||
removeChild: (id: string) => void;
|
||||
|
||||
/**
|
||||
* 根据id获取对应的源数据
|
||||
@ -95,14 +95,14 @@ export interface ITreeGraph extends IGraph {
|
||||
* @param {TreeGraphData | undefined} parent 从哪个节点开始寻找,为空时从根节点开始查找
|
||||
* @return {TreeGraphData} 对应源数据
|
||||
*/
|
||||
findDataById(id: string, parent?: TreeGraphData | undefined): TreeGraphData | null;
|
||||
findDataById: (id: string, parent?: TreeGraphData | undefined) => TreeGraphData | null;
|
||||
|
||||
/**
|
||||
* 布局动画接口,用于数据更新时做节点位置更新的动画
|
||||
* @param {TreeGraphData} data 更新的数据
|
||||
* @param {function} onFrame 定义节点位置更新时如何移动
|
||||
*/
|
||||
layoutAnimate(
|
||||
layoutAnimate: (
|
||||
data: TreeGraphData,
|
||||
onFrame?: (
|
||||
item: Item,
|
||||
@ -110,18 +110,18 @@ export interface ITreeGraph extends IGraph {
|
||||
originAttrs?: ShapeStyle,
|
||||
data?: TreeGraphData,
|
||||
) => unknown,
|
||||
): void;
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* 立即停止布局动画
|
||||
*/
|
||||
stopLayoutAnimate(): void;
|
||||
stopLayoutAnimate: () => void;
|
||||
|
||||
/**
|
||||
* 是否在布局动画
|
||||
* @return {boolean} 是否有布局动画
|
||||
*/
|
||||
isLayoutAnimating(): boolean;
|
||||
isLayoutAnimating: () => boolean;
|
||||
}
|
||||
|
||||
export class G6GraphEvent extends GraphEvent implements IG6GraphEvent {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import * as ColorUtil from './color';
|
||||
import * as LayoutUtil from './layout';
|
||||
import { Util } from '@antv/g6-core';
|
||||
|
||||
const G6Util: any = { ...Util, ...ColorUtil, ...LayoutUtil };
|
||||
|
||||
export default G6Util;
|
||||
|
Loading…
Reference in New Issue
Block a user