-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(wordcloud): accept custom canvas #6354
Conversation
5b23574
to
9d0a4a4
Compare
不是这样的,应该是还是用 G 的 canvas,这样在 g2-ssr 中直接传入 node-canvas 就可以了,这样用户不敢感知了,不然对于 ssr,用户还需要对 词云图的 mark 做特殊的配置。 |
这里需要一个新的 canvas 吧?不应该是 G 的 canvas,毕竟这里会对传入的 canvas 操作。ssr 应该传入一个新的 node-canvas 才对? |
9f4d18b
to
921e242
Compare
Pull Request Test Coverage Report for Build 9888515796Details
💛 - Coveralls |
是的,渲染的时候是使用 renderChart 方法,透传了 createCanvas 方法 // https://github.com/pearmini/g2-ssr-node/blob/main/src/render.js
import { stdlib, render as renderChart, G2Context } from '@antv/g2';
export function render(type?: 'pdf' | 'svg') {
return async (options: any) => {
const { width = 640, height = 480, ...rest } = options;
const [gCanvas, canvas] = createGCanvas(width, height, type);
const spec = { ...rest, width, height };
const context: G2Context = {
canvas: gCanvas,
library: updateLight(stdlib),
createCanvas: () => createCanvas(300, 150),
};
await new Promise((resolve: any) => renderChart(spec, context, resolve));
return canvas;
};
} |
@hustcc 我重构了一下 runtime,可以把 context(包括 createCanvas)透穿给各个可视化组件。 |
WordCloud Mark 支持传入自定义的 Canvas,可以用于服务端渲染。