antvis/G2


The issue has been closed
render()返回值类型错误 #4853
15802980231 posted onGitHub
export interface Chart extends Composition, Mark {
render(): void;
node(): HTMLElement;
data: ValueAttribute<ChartProps['data'], Chart>;
width: ValueAttribute<ChartProps['width'], Chart>;
height: ValueAttribute<ChartProps['height'], Chart>;
coordinate: ValueAttribute<ChartProps['coordinate'], Chart>;
interaction: ObjectAttribute<ChartProps['interaction'], Chart>;
key: ValueAttribute<ChartProps['key'], Chart>;
transform: ArrayAttribute<ChartProps['transform'], Chart>;
theme: ObjectAttribute<ChartProps['theme'], Chart>;
title: ValueAttribute<ChartProps['title'], Chart>;
scale: ObjectAttribute<ChartOptions['scale'], Chart>;
axis: ObjectAttribute<ChartOptions['axis'], Chart>;
legend: ObjectAttribute<ChartOptions['legend'], Chart>;
style: ObjectAttribute<ChartOptions['style'], Chart>;
labelTransform: ArrayAttribute<ChartOptions['labelTransform'], Chart>;
}
render(): Promise<Chart> {
if (!this._context.canvas) {
// Init width and height.
const {
width = 640,
height = 480,
renderer,
plugins,
autoFit,
} = this.options();
const { width: adjustedWidth, height: adjustedHeight } = getChartSize(
this._container,
autoFit,
width,
height,
);
this.width(adjustedWidth);
this.height(adjustedHeight);
// Create canvas if it does not exist.
this._context.canvas = Canvas(
this._container,
width,
height,
renderer,
plugins,
);
}
return new Promise((resolve, reject) => {
try {
reneder(this.options(), this._context, () => resolve(this), reject);
} catch (e) {
reject(e);
}
});
}