首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >puppeteer 渲染的echarts 饼图如上述效果,有个缺口?

puppeteer 渲染的echarts 饼图如上述效果,有个缺口?

提问于 2025-04-03 10:43:03
回答 0关注 0查看 41

const puppeteer = require('puppeteer'); const path = require('path'); //const puppeteer = require('C:\\Office\\Feishu\\workplace\\spring-boot-01-helloworld\\spring-boot-01-helloworld'); (async () => { const htmlFilePath = process.argv[2]; // 临时HTML路径 const outputPath = process.argv[3]; // 图片输出路径 const browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'], protocolTimeout: 1200000, }); //const browser = await puppeteer.launch(); const page = await browser.newPage(); //await page.goto('file://${htmlFilePath}', { waitUntil: 'networkidle0' }); await page.goto(`file://${htmlFilePath}`, { waitUntil: 'networkidle0' }); // 等待图表渲染完成(检查Canvas元素) await page.waitForSelector('#chart', { timeout: 1200000 }); // 截图 // await page.screenshot({ // path: outputPath, // clip: { x: 0, y: 0, width: 800, height: 650 } // }); try { const base64Image = await page.screenshot({ encoding: 'base64' }); console.log(base64Image); } catch (error) { console.error('Failed to take screenshot:', error); // 可以选择重试或执行其他错误处理逻辑 //await captureScreenshot(url); // 重试截图 } finally { await browser.close(); } })();

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档