NuclearDispersionSystem/ant-design-vue-jeecg/node_modules/@antv/g2/lib/index.d.ts

1020 lines
25 KiB
TypeScript
Raw Normal View History

2023-09-14 14:47:11 +08:00
// Type definitions for g2 3.0.x
// Project: https://github.com/antvis/g2
// Last module patch version validated against: 3.0.4
export = G2;
export as namespace G2;
declare namespace G2 {
function track(option: boolean): void;
const version: string;
const Animate: Animate;
const Util: Util;
const Shape: Shape;
class Global {
setTheme(option: 'default' | 'dark'): void;
setTheme(option: string): void;
setTheme(option: object): void;
registerTheme(name: string, option: object): void;
version: string;
trackable: boolean;
animate: boolean;
snapArray: number[];
/**
* tick
*/
snapCountArray: number[];
/**
*
*/
widthRatio: {
/**
* 1/2
*/
column: number;
/**
* 1
*/
rose: number;
/**
*
*/
multiplePie: number;
};
/**
* 线path
*/
showSinglePoint: boolean;
connectNulls: boolean;
/**
* --
*/
colors: string[];
colors_16: string[];
colors_24: string[];
colors_pie: string[];
colors_pie_16: string[];
fontFamily: string;
renderer: 'canvas' | 'svg';
}
/**
* base Style interface []
*/
namespace Styles {
interface common {
/**
*
*/
fill?: string;
/**
*
*/
stroke?: string | number;
/**
*
*/
shadowColor?: string;
/**
*
*/
shadowBlur?: string | number;
/**
*
*/
shadowOffsetX?: string | number;
/**
*
*/
shadowOffsetY?: string | number;
/**
* alpha
*/
opacity?: string | number;
/**
*
*/
globalCompositeOperation?: string;
}
interface text extends common {
font?: string;
/**
*
*/
textAlign?: 'center' | 'end' | 'left' | 'right' | 'start';
/**
*
*/
rotate?: number;
/**
* 线`middle`
*/
textBaseline?: 'top' | 'middle' | 'bottom';
/**
*
*/
fontStyle?: 'normal' | 'italic' | 'oblique';
/**
*
*/
fontVariant?: 'normal' | 'small-caps';
/**
*
*/
fontWeight?: string | number;
/**
*
*/
fontSize?: string | number;
/**
*
*/
fontFamily?: string;
}
interface line extends common {
strokeOpacity?: string | number;
/**
* 线
*/
lineDash?: number[];
lineCap?: string;
lineJoin?: string;
lineWidth?: string | number;
miterLimit?: string | number;
startArrow?: boolean;
endArrow?: boolean;
arrowAngle?: number;
arrowRadius?: number;
}
interface tickLine extends line {
/**
* 线
*/
length?: number;
}
interface background extends common {
/**
*
*/
fillOpacity?: number;
/**
*
*/
strokeOpacity?: number;
/**
*
*/
lineWidth?: number;
/**
*
*/
radius?: number;
}
interface path extends common {
/**
*
*/
fillOpacity?: number;
/**
*
*/
strokeOpacity?: number;
}
}
/**
* base type
*/
type EventParams = {
x?: number;
y?: number;
target?: HTMLCanvasElement;
toElement?: HTMLElement;
shape?: Shape;
views?: View[];
data?: any;
geom?: any;
};
/**
*
*/
interface ChartProps {
container: string | HTMLDivElement;
width?: number;
height: number;
padding?:
| {
top?: number | string;
right?: number | string;
bottom?: number | string;
left?: number | string;
}
| number
| string
| [
number | string,
number | string,
number | string,
number | string
]
| [string, string];
background?: Styles.background;
plotBackground?: Styles.background;
forceFit?: boolean;
animate?: boolean;
pixelRatio?: number;
data?: Object | any;
/**
*
*/
theme?: Object | string;
}
interface Coordinate {
/**
* angle
*/
rotate(angle: number): Coordinate;
/**
* sx x sy y
*/
scale(sx: number, sy: number): Coordinate;
/**
* x y
*/
reflect(xy?: 'x' | 'y'): Coordinate;
/**
* x y
*/
transpose(): Coordinate;
}
interface Geom {
position(pos: string): this;
position(pos: string[]): this;
color(col: string): this;
color(type: string, colors: string[]): this;
color(type: string, fun: Function): this;
shape(shape: string): this;
shape(type: string, colors: string[]): this;
shape(type: string, fun: Function): this;
size(size: number): this;
size(col: string): this;
size(type: string, colors: number[]): this;
size(type: string, func: Function): this;
opacity(op: number): this;
opacity(col: string): this;
opacity(type: string, func: Function): this;
adjust(adj: string): this;
adjust(adjs: any[]): this;
label(field: string): this;
label(exe: string, func: Function): this;
label(
exe: string,
opt: {
offset?: number;
textStyle?: Styles.text;
[key: string]: any;
}
): this;
tooltip(open: boolean): this;
tooltip(field: string): this;
tooltip(exe: string, func: Function): this;
style(style: any): this;
style(exe: string, style: any): this;
select(open: boolean): this;
select(opt: {
/**
*
*/
mode: 'single' | 'multiple';
/**
* shape
*/
style: {};
/**
*
*/
cancelable: boolean;
/**
*
*/
animate: boolean;
}): this;
select(
open: boolean,
opt: {
/**
*
*/
mode: 'single' | 'multiple';
/**
* shape
*/
style: {};
/**
*
*/
cancelable: boolean;
/**
*
*/
animate: boolean;
}
): this;
setSelected(record: any): this;
clearSelected(): void;
active(open: boolean): Geom;
animate(opt: any): Geom;
}
/**
*
*/
interface AxisLabel {
/**
* label 线
*/
offset?: number | number[];
/**
*
*
*/
textStyle?: ((text?: string) => Styles.text) | Styles.text;
/**
* true
*/
autoRotate?: boolean;
/**
*
* @param text
* @param item
* @param index
* @return
*/
formatter?(text: string, item: any, index: number): string;
/**
* 使 html
* @param text
* @param item
* @param index
* @return html
*/
htmlTemplate?(text: string, item: any, index: number): string;
}
/**
* 线
*/
interface AxisTitle {
/**
* `true`
*/
autoRotate?: boolean;
/**
* 线
*/
offset?: number;
/**
*
*/
textStyle?: Styles.text;
/**
* 线
*/
position?: 'start' | 'center' | 'end';
}
const markerAction: (
x: number,
y: number,
r: number,
ctx: CanvasRenderingContext2D
) => void;
interface LegendConfig {
position?:
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'left-top'
| 'left-center'
| 'left-bottom'
| 'right-top'
| 'right-center'
| 'right-bottom'
| 'top-left'
| 'top-center'
| 'top-right'
| 'bottom-left'
| 'bottom-center'
| 'bottom-right';
layout?: 'vertical' | 'horizontal';
title?: Styles.text;
offsetX?: number;
offsetY?: number;
itemGap?: number;
itemMarginBottom?: number;
itemWidth?: number;
unCheckColor?: string;
background?: {
fill?: string;
fillOpacity?: number;
};
allowAllCanceled?: number;
itemFormatter?(value: string): string;
marker?: string | Function;
textStyle?: Styles.text;
clickable?: boolean;
hoverable?: boolean;
defaultClickHandlerEnabled?: boolean;
selectedMode?: 'single' | 'multiple';
onHover?(e: MouseEvent): void;
onClick?(e: MouseEvent): void;
useHtml?: boolean;
container?: string;
containerTpl?: string;
itemTpl?: string;
slidable?: boolean;
width?: number;
height?: number;
custom?: number;
items?: Array<{
/**
*
*/
value: string;
/**
* marker
*/
fill: string;
marker?: string | Function;
}>;
}
interface TooltipItem {
color: string;
title: string;
name: string;
value: string;
x: number;
y: number;
point: any;
marker: any;
showMarker: boolean;
}
type TooltipConfig =
| HtmlTooltipConfig
| CanvasTooltipConfig
| MiniTooltipConfig;
interface CommonTooltipConfig {
triggerOn?: 'mousemove' | 'click' | 'none';
showTitle?: boolean;
title?: string;
crosshairs?: {
/**
* rect x 线y 线cross 线
*/
type?: 'rect' | 'x' | 'y' | 'cross' | 'line';
style?: Styles.background | Styles.line;
};
offset?: number;
inPlot?: boolean;
follow?: boolean;
shared?: boolean;
position?: 'left' | 'right' | 'top' | 'bottom';
hideMarkers?: boolean;
useHtml?: boolean;
type?: 'default' | 'mini';
}
interface HtmlTooltipConfig extends CommonTooltipConfig {
useHtml?: true;
type?: 'default';
htmlContent?(title: string, items: TooltipItem[]): string;
containerTpl?: string;
itemTpl?: string;
'g2-tooltip'?: Record<string, any>;
'g2-tooltip-title'?: Record<string, any>;
'g2-tooltip-list-item'?: Record<string, any>;
'g2-tooltip-list'?: Record<string, any>;
'g2-tooltip-marker'?: Record<string, any>;
'g2-tooltip-value'?: Record<string, any>;
enterable?: boolean;
}
interface CanvasTooltipConfig extends CommonTooltipConfig {
useHtml: false;
type?: 'default';
boardStyle?: Styles.background;
titleStyle?: Styles.text;
nameStyle?: Styles.text;
valueStyle?: Styles.text;
itemGap?: number;
}
interface MiniTooltipConfig extends CommonTooltipConfig {
type: 'mini';
boardStyle?: Styles.background;
valueStyle?: Styles.text;
triangleWidth?: number;
triangleHeight?: number;
}
class ChartGuide {
line(option: {
/**
* guide canvas false,
*/
top?: boolean;
/**
* 线 callback
*/
start?: any | Function | Array<string | number>;
/**
* 线 callback
*/
end?: any | Function | Array<string | number>;
/**
*
*/
lineStyle?: Styles.line;
text?: {
/**
*
*/
position?: 'start' | 'center' | 'end' | '39%' | 0.5;
/**
* 沿线 true
*/
autoRotate?: boolean;
/**
*
*/
style?: any;
/**
*
*/
content?: string;
/**
* x
*/
offsetX?: number;
/**
* y
*/
offsetY?: number;
};
}): void;
text(option: {
/**
* guide canvas false,
*/
top?: boolean;
/**
* callback
*/
position?: any | Function | Array<string | number>;
/**
*
*/
content?: string;
/**
*
*/
style?: G2.Styles.text;
/**
* x
*/
offsetX?: number;
/**
* y
*/
offsetY?: number;
}): void;
image(option: {
/**
* giude canvas false,
*/
top?: boolean;
/**
* callback
*/
start?: any | Function | Array<string | number>;
/**
* callback
*/
end?: any | Function | Array<string | number>;
/**
*
*/
src?: string;
/**
* x
*/
offsetX?: number;
/**
* y
*/
offsetY?: number;
width?: number;
height?: number;
}): void;
region(option: {
/**
* giude canvas false,
*/
top?: boolean;
/**
* callback
*/
start?: any | Function | Array<string | number>;
/**
* callback
*/
end?: any | Function | Array<string | number>;
style?: {
/**
*
*/
lineWidth?: number;
/**
*
*/
fill?: string;
/**
*
*/
fillOpacity?: number;
stroke?: string;
};
}): void;
html(option: {
/**
* html的起始位置 callback
*/
position?: any | Function | Array<string | number>;
alignX?: 'left' | 'middle' | 'right';
alignY?: 'top' | 'middle' | 'bottom';
offsetX?: number;
offsetY?: number;
/**
* html
*/
html?: string;
zIndex?: number;
}): void;
arc(option: {
top?: boolean;
/**
* callback
*/
start?: any | Function | Array<string | number>;
/**
* callback
*/
end?: any | Function | Array<string | number>;
style?: object;
}): void;
}
class ChartAxisConfig {
position?: 'top' | 'bottom' | 'left' | 'right';
line?: Styles.line;
label?: AxisLabel;
title?: AxisTitle;
tickLine?: Styles.tickLine | null;
subTickCount?: number;
subTickLine?: Styles.tickLine | null;
grid?: AxisGrid | null;
}
type AxisGrid = {
/**
*
*/
align?: 'center';
/**
* line 线polygon
*/
type?: 'line' | 'polygon';
/**
* type line 使 lineStyle
*/
lineStyle?: Styles.line;
/**
* type polygon 使 alternateColor
*
*/
alternateColor?: string | [string, string];
/**
* 线 false
*/
hideFirstLine?: boolean;
/**
* 线 false
*/
hideLastLine?: boolean;
};
class BashView {
source(data: any): this;
source(data: any, scaleConfig: any): this;
getXScale<T>(): T;
getYScales<T>(): T[];
getXY(): {
/**
*
*/
x: number;
/**
*
*/
y: number;
};
filter(
field: string,
callback: (value: string | number) => boolean
): this;
axis(option: boolean): this;
axis(field: string, option: boolean): this;
axis(field: string, axisConfig: ChartAxisConfig): this;
guide(): ChartGuide;
scale(scaleConfig: any): this;
scale(field: string, scaleConfig: any): this;
coord(
type: 'rect' | 'polar' | 'theta' | 'helix',
coordConfig?: {
/**
* 0 1
*/
radius?: number;
/**
* 0 1
*/
innerRadius?: number;
/**
*
*/
startAngle?: number;
/**
*
*/
endAngle?: number;
}
): Coordinate;
animate(option: boolean): void;
clear(): void;
changeData(data: any): void;
changeVisible(visible: string): void;
repaint(): void;
destroy(): void;
line(): Geom;
path(): Geom;
area(): Geom;
point(): Geom;
interval(): Geom;
polygon(): Geom;
schema(): Geom;
edge(): Geom;
heatmap(): Geom;
pointStack(): Geom;
pointJitter(): Geom;
pointDodge(): Geom;
intervalStack(): Geom;
intervalDodge(): Geom;
intervalSymmetric(): Geom;
areaStack(): Geom;
schemaDodge(): Geom;
}
class View extends BashView {
tooltip(option: boolean): this;
}
class Chart extends BashView {
constructor(config: Partial<ChartProps>);
legend(option: boolean | LegendConfig): this;
legend(field: string, option: boolean): this;
legend(field: string, legendConfig: LegendConfig): this;
tooltip(tooltipConfig: TooltipConfig | boolean): this;
view(option?: {
start?: { x: number; y: number };
end?: { x: number; y: number };
padding?: number;
animate?: boolean;
}): View;
forceFit(): this;
render(): void;
changeSize(width: number, height: number): this;
changeWidth(width: number): this;
changeHeight(height: number): this;
getSnapRecords(ponit: { x: number; y: number }): number[];
getAllGeoms(): Geom[];
toDataURL(): string;
downloadImage(name: string): string;
showTooltip(ponit: { x: number; y: number }): any;
hideTooltip(): any;
on(eventNane: string, event: any): any;
facet(
type: 'rect' | 'list' | 'tree' | 'mirror' | 'matrix',
option: {
fields?: string[];
/**
*
*/
showTitle?: boolean;
/**
*
*/
autoSetAxis?: boolean;
/**
* view
*/
padding?: number;
/**
*
* @param view
* @param facet data rows cols rowIndex colIndex rowField colField
*/
eachView?(view: View, facet: any): void;
/**
*
*/
colTitle?: {
offsetY?: number;
style?: G2.Styles.text;
} | null;
/**
*
*/
rowTitle?: {
offsetX?: number;
style?: G2.Styles.text;
} | null;
}
): void;
get<K extends keyof ChartProps>(prop: K): ChartProps[K];
}
/**
* config interface
*/
class Scale<T> {
type?:
| 'identity'
| 'linear'
| 'cat'
| 'time'
| 'timeCat'
| 'log'
| 'pow';
formatter?(value: T): string;
range?: [number, number];
alias?: string | number;
tickCount?: number;
ticks?: any[];
scale?(value: T): number;
invert?(n: number): T;
getTicks?(): any[];
getText?(value: any): string;
}
class ScaleLinear extends Scale<number> {
nice?: boolean;
min?: number;
max?: number;
/**
* tickCount tickInterval
*/
tickInterval?: number;
}
class ScaleCat<T> extends Scale<T> {
range?: [number, number];
values?: T[];
}
class ScaleLog extends Scale<number> {
nice?: boolean;
min?: number;
max?: number;
base?: number;
tickInterval?: number;
}
class ScalePow extends Scale<number> {
nice?: boolean;
min?: number;
max?: number;
exponent?: number;
tickInterval?: number;
}
class ScaleTime extends Scale<number | string> {
nice?: boolean;
min?: number | string;
max?: number | string;
mask?: string;
tickInterval?: number;
}
class scaleTimeCat extends Scale<number | string> {
nice?: boolean;
mask?: string;
values?: number[] | string[];
}
interface Shape {
getLinearValue?(percent: any): any;
registerShape?(
chartType: string,
shapeName: string,
config:
| {
getPoints?: any;
getMarkerCfg?: any;
draw: any;
}
| {
getPoints?: any;
getMarkerCfg?: any;
drawShape: any;
}
): {
parsePoint: any;
parsePoints: any;
parsePath: any;
};
}
interface Animate {
registerAnimation(
animationType: string,
animationName: string,
animationFun: any
): void;
}
type lodashFn = any;
interface Util {
each: lodashFn;
map: lodashFn;
isObject: lodashFn;
isNumber: lodashFn;
isString: lodashFn;
isFunction: lodashFn;
[other: string]: lodashFn;
}
class DomUtil {
getBoundingClientRect(
node: Element
): { top: number; bottom: number; left: number; right: number };
getStyle(dom: HTMLElement, name: string): any;
modifyCSS(dom: HTMLElement, css: any): HTMLElement;
createDom(str: string): HTMLElement;
getRatio(): number;
getWidth(el: HTMLElement): number;
getHeight(el: HTMLElement): number;
getOuterWidth(el: HTMLElement): number;
getOuterHeight(el: HTMLElement): number;
addEventListener<K extends keyof HTMLElementEventMap>(
target: HTMLElement,
eventType: K,
listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any
): void;
addEventListener(
target: HTMLElement,
eventType: string,
listener: (ev: Event) => any
): void;
requestAnimationFrame(fn: () => void): void;
}
class MatrixUtil {
mat3: any;
vec2: any;
vec3: any;
transform: any;
}
class PathUtil {
parsePathString(pathString: string): any[];
parsePathArray(pathArray: any): any;
pathTocurve(path: any[]): any;
pathToAbsolute(path: any[]): any;
catmullRomToBezier(pointsArray: any[]): any;
intersection(path1: any[], path2: any[]): any;
}
}