Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
browser automation

How to Capture Chart.js Charts with Puppeteer (Reliable Screenshots and Canvas Exports)

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The reliable way to capture a Chart.js chart with Puppeteer is to control the viewport and chart container, wait for a chart-specific ready signal, then call page.screenshot(). Disable Chart.js animation for deterministic output, or wait for animation.onComplete when the animation must remain. If you need only the canvas, export it with Chart.js toBase64Image() instead of capturing the surrounding page.

Choose the capture boundary first

Your output requirement determines the API you should use:

Need Recommended path What it includes
Chart, page background, HTML headings, labels, or other DOM page.screenshot(), optionally with clip The rendered browser page or a selected rectangle
Only the chart canvas chart.toBase64Image() The current canvas pixels, without surrounding HTML
Animation-free, repeatable files options.animation: false, then capture A frame that does not depend on animation timing
Animated chart that must finish naturally Set an application ready flag in animation.onComplete and wait with page.waitForFunction() The completed frame, synchronized to Chart.js

These choices follow the boundaries documented by Chart.js’s API and Puppeteer’s screenshot method.

Prepare a capture-friendly Chart.js page

Use a dedicated, sized container

Chart.js responsive sizing follows the parent container, while a canvas has separate CSS display and internal render dimensions. Put each canvas in a relatively positioned container with explicit dimensions for automated captures. If the desired height should not be derived from the width, set maintainAspectRatio: false. See the responsive charts guidance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Guermok Video Capture Card, 4K USB3.0 HDMI to USB C, 1080P 60FPS & 2K 30FPS
  • 【1080P 60FPS Video Capture Card】 This HDMI game capture card is based on USB3.0 high speed transmission port, input resolution up to 4K@30HZ, output resolution up to 2K@30Hz or 1920×1080@60Hz. Type c and USB interface can meet most of the devices in daily life. Easily meet the online capture, real-time recording, online meetings, live gaming and other functions, so you have a better visual enjoyment. Note: For capture use only; requires capture software to function and is not intended for direct screen casting to a monitor or TV
  • 【Ultra Low Latency Screen Sharing】 HDMI capture card is made of good quality aluminum alloy with strong heat dissipation, allowing you to enjoy ultra low latency while live gaming or video recording or live streaming, avoiding blue screens and lag. This HDMI to USBC capture card supports easy recording of good quality audio or HD video and transferring it to your computer or streaming platform, allowing you to record 60 fps HD video directly on your hard drive and real-time preview
  • 【Plug and Play, Easy to Carry】 This HDMI 1080P video capture card does not require any additional drivers or external power supply, just plug and play for fast capture. The capture card is small and lightweight, so you can put it in your bag for emergencies, making it very portable for outdoor live streaming. It's also a great way to share content in game recording, video conference, video recorder and online teaching
  • 【Wide Compatibility USB Capture Card】 Easily streams to Facebook, Youtube or Twitch. With the connection, this HDMI to USB C/3.0 video capture devices can be working on several Operating Systems and various software: Windows 7/ 8/ 10, Mac OS or above, Linux, Android, Laptop, Xbox One, PS3/PS4/PS5, Camera, DVDs, Set Top Box, Webcame, DSLR, Switch/Switch 2, TV BOX, HDTV, Potplayer/VLC, ZOOM, OBS Studio etc.
  • 【Package Content & Note】 1x HD Audio Capture Card , 1x USB 3.0 to USB C Adapter (A-side 3.0, B-side 2.0), 1x user manual. Please note that you need to restart the OBS Studio software after the audio setup is complete, otherwise it will result in no sound output. When using an adapter, if the device is recognized as USB 2.0, try using the other side with the USB-C port. Simply flip the capture card and reconnect it to be recognized as USB 3.0
<div id="chart-wrap" style="position:relative;width:900px;height:500px">
  <canvas id="sales-chart"></canvas>
</div>
<script>
  const ctx = document.getElementById('sales-chart');
  window.chartReady = false;
  window.salesChart = new Chart(ctx, {
    type: 'line',
    data: {
      labels: ['Jan', 'Feb', 'Mar', 'Apr'],
      datasets: [{
        label: 'Sales',
        data: [12, 19, 14, 24],
        borderColor: '#2563eb',
        backgroundColor: 'rgba(37,99,235,.15)',
        fill: true,
        tension: .25
      }]
    },
    options: {
      responsive: true,
      maintainAspectRatio: false,
      animation: false
    }
  });
  window.chartReady = true;
</script>

Set the viewport before loading or rendering the page. A known viewport makes responsive breakpoints and the resulting image dimensions predictable. Puppeteer exposes viewport control on its Page API.

Confirm the installed major versions

The current Chart.js usage documentation covers v4, while the project documentation notes that v3 changed the API substantially from v2. Check your installed Chart.js major version and use matching configuration and API examples. Puppeteer’s Page and screenshot references displayed version 25.12.0 in the documentation state consulted here; verify the package version in your own project before relying on defaults.

Complete Puppeteer example: deterministic page screenshot

This Node.js script opens a local HTML file, fixes the viewport, waits for the page’s explicit chart-ready flag, and writes a PNG. The chart disables animation, so the flag can be set immediately after construction.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch({ headless: true });
try {
  const page = await browser.newPage();
  await page.setViewport({ width: 1200, height: 800, deviceScaleFactor: 1 });
  await page.goto('http://localhost:3000/chart.html', {
    waitUntil: 'domcontentloaded'
  });

  await page.waitForFunction(() => window.chartReady === true);
  await page.screenshot({
    path: 'chart-page.png',
    type: 'png',
    fullPage: false
  });
} finally {
  await browser.close();
}

fullPage: false captures the viewport. Use fullPage: true when the page extends below it, but remember that the image then includes all page content, not just the chart.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Capture a chart region with a clip

A clip is useful when you want page-rendered labels and styling but not the rest of the document. Query the element’s bounding box after readiness and pass its coordinates to screenshot().

Rank #2
Video Capture Card, 4K USB3.0 HDMI to USB C, 1080P60FPS HDMI Capture Card for Streaming, Gaming, Video Recording Compatible with Switch, Xbox, PS4/5, OBS,iPad Mac OS Windows,Camera, Zoom(Silver)
  • 【4K HDMI Input, 2K@30Hz Recording】Powered by a true USB 3.0 high-speed interface, the capture card supports up to 4K@30Hz HDMI input and records at 2K@30Hz or 1080P@60Hz. Perfect for gamers, streamers, and professionals who need crisp, smooth video for live streaming, gameplay recording, or online meetings.
  • 【Ultra Low Latency Screen Sharing】Built with a premium aluminum alloy shell and advanced chipset for stable heat dissipation, ensuring ultra-low latency transmission. Capture high-quality video and dual-channel audio in real time—no lag, no frame drop—ideal for Twitch, YouTube, or OBS streaming.
  • 【Easy Plug and Play, Compact & Portable】No driver or external power required—just plug and play via USB 3.0 or Type-C connection to your Windows or macOS computer. Lightweight and compact design makes it easy to carry for outdoor streaming, live shows, or mobile recording setups.
  • 【Wide Compatibility & Multi-Device Support】Compatible with Windows 7 8 10 11, macOS, Linux,Android and supports most popular software such as OBS, Zoom, VLC, Twitch Studio, and more. Works seamlessly with PS4, PS5, Xbox, Switch, DSLR cameras, TV boxes, and other HDMI-output devices for streaming to YouTube, Twitch, etc.
  • 【What You Get】Includes: HDMI Capture Card, USB 3.0 to USB-C Adapter, User Manual. Tips: Make sure your tablet’s OTG function is enabled before connecting. Test your HDMI device with a monitor first to confirm video and audio output, then connect to the Video Capture Card for recording.
const box = await page.locator('#chart-wrap').boundingBox();
if (!box) throw new Error('Chart container is not visible');
await page.screenshot({
  path: 'chart-region.png',
  type: 'png',
  clip: box
});

Check that the rectangle contains axes, tick labels, legends, and any HTML annotations you need. A canvas-only clip can omit content positioned just outside the canvas.

Wait for Chart.js to finish rendering

Preferred option: disable animation

Chart.js animates by default. Navigation completion, a visible canvas, or network idleness does not prove that the final frame has been drawn. For static artifacts, options.animation: false removes that timing variable. Chart.js documents this switch in its animations documentation and discusses related capture considerations in its performance guidance.

When animation must remain

Expose an application-owned flag from the animation callback, then wait for that flag in Puppeteer:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
window.chartReady = false;
window.salesChart = new Chart(ctx, {
  type: 'bar',
  data,
  options: {
    responsive: true,
    maintainAspectRatio: false,
    animation: {
      onComplete() {
        window.chartReady = true;
      }
    }
  }
});
await page.waitForFunction(
  () => window.chartReady === true,
  { timeout: 30000 }
);
await page.screenshot({ path: 'animated-chart-final.png' });

This waits on the chart’s actual completion signal rather than guessing a delay.

Why network idle is not enough

page.waitForNetworkIdle() only observes network activity. A chart can continue animating after scripts, data, and fonts have loaded. The current Puppeteer API documentation lists a default idleTime of 500 ms; confirm the default for your installed version and treat it as a network condition, not a render-complete condition. If you use it, combine it with the chart-ready wait:

Rank #3
UGREEN 2K@30Hz 1080P 60FPS Video Capture Card 4K Input HDMI to USB 3.0
  • 2K 30FPS & 1080p 60FPS HDMI Capture Card: The 4K@30Hz input and 2K@30Hz output resolutions offer dual benefits. The high input resolution preserves original video quality for post-production editing, while the 2K output provides an optimal balance between clarity and compatibility. At the same time, this HDMI to USB-C capture card is also backward compatible with 1080p 60FPS, to fulfill a variety of daily needs. Note: Ensure your HDMI source device and the capture device support 2K resolution
  • Low Latency 5 Gbps High Data Transfer Speed: With high-speed USB 3.0 technology for optimal performance and low delay, you can easily stream video from the Switch/Switch 2/PS4/PS5 to Twitch, YouTube, Facebook, Twitter, OBS, Potplayer, and VLC on a computer. It's also backward compatible with USB 2.0. Note: This capture card for streaming only supports HDMI input sources, as well as iPadOS devices need to be updated to 17 or higher to use it
  • USB A and USB C ports: Featuring both USB-A and USB-C interfaces, this streaming capture card ensures broad compatibility with modern devices, including smartphones, laptops, tablets, desktops, and Quest 3. Perfect for multi-scenario streaming—whether you're broadcasting camera footage, mobile gaming, or PC live streams. Note: This capture card only supports unidirectional signal flow—HDMI input to USB output
  • Universal Compatibility: This Driver-Free HDMI capture card for streaming supports Windows 11/10/8.1/7, MacOS, Linux, and phones/tablets. This capture card effortlessly livestreams gameplay from Switch, Switch 2, PS4/PS4 Pro/PS5 (Disable HDCP mode), Xbox Series X, and Meta Quest 3/2 directly to your iPad, laptop, or PC. Fully support OBS Studio, XSplit, PotPlayer, QuickTime Player, and more for streaming, recording, editing, and high-res video transfer. Note: iPadOS 17 or later is required for USB-C iPad compatibility. Switch / Xbox / PS5/ PS4 work fine when HDCP is turned off
  • Durable USB Capture Card: The aluminum alloy casing easily dissipates heat and is lightweight while effectively shielding against EMI, ensuring stable signal transmission. The built-in cable features 26AWG (2C) + 30AWG (1P) tinned copper conductors, ensuring excellent conductivity and corrosion resistance, enhancing durability, and reducing signal loss
await page.waitForNetworkIdle({ idleTime: 500, timeout: 30000 });
await page.waitForFunction(() => window.chartReady === true);

Export only the canvas with Chart.js

When the deliverable is only the plotted canvas, call toBase64Image() in the page after readiness. Chart.js returns a PNG data URL by default and supports JPEG with a quality argument.

const dataUrl = await page.evaluate(() => {
  if (!window.chartReady) throw new Error('Chart is not ready');
  return window.salesChart.toBase64Image();
});

const base64 = dataUrl.replace(/^data:image/png;base64,/, '');
await import('node:fs/promises').then(fs =>
  fs.writeFile('chart-canvas.png', Buffer.from(base64, 'base64'))
);

For JPEG output, request window.salesChart.toBase64Image('image/jpeg', 0.92) and remove the corresponding JPEG data-URL prefix before decoding. Canvas export excludes HTML labels, page backgrounds, and overlays; use a Puppeteer screenshot when those matter.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Control dimensions, density, and responsive redraws

Viewport and device scale

Set width, height, and deviceScaleFactor deliberately. A higher device scale factor produces more physical pixels for the same CSS viewport, while changing the output dimensions. Keep it fixed in batch jobs so files are comparable.

Resize before capture

If you change the viewport or container after creating the chart, allow Chart.js to resize and redraw before capturing. You can invoke the chart API explicitly:

await page.setViewport({ width: 1600, height: 900, deviceScaleFactor: 1 });
await page.evaluate(() => window.salesChart.resize());
await page.waitForFunction(() => window.chartReady === true);
await page.screenshot({ path: 'wide.png' });

For print-oriented layouts, browser print mode and resize-event timing can conflict. Set the intended dimensions explicitly and coordinate the redraw rather than assuming the chart has adapted synchronously. The responsive documentation describes these resize behaviors.

Rank #4
WARRKY Video Capture Card with 100W Power Delivery, USB 3.0 1080P 60HZ HD
  • [Exclusively Design] The L-shaped USB-C connector fits perfectly with Quest and iPad, while the extended cable design allows quick access to the connection port without removing the headset. Elevate your content with the WARRKY capture card through 4K@30fps input and 1080P@60fps recording. The YUY2 format delivers richer colors than MJPEG, eliminating banding with vibrant gradients for true-to-life streaming.
  • [100W High Speed Charging] Engineered for uninterrupted creativity, this capture card unleashes 100W ultra-fast charging through PD3.0 technology - simultaneously powering your Quest 3 and iPad while capturing gameplay or live streams. Never let a low battery interrupt your winning streak: the intelligent power management sustains stable voltage even during graphic-intensive VR battles or multi-hour broadcasts.
  • [Engineered for Excellence] The WARRKY capture card redefines reliability with aerospace-grade aluminum housing and braided nylon cabling, housing the flagship MS2130 chipset that achieves industry-leading 0.05s transmission latency. Precision-machined aluminum alloy dissipates heat 40% faster than plastic shells, maintaining stability during VR marathons, while triple-shielded nylon cables resist tangling across mobile studio setups.
  • [Universal Compatibility] The capture card is compatible with Switch, PS5/4, cameras, laptops, and tablets. It supports a wide range of capture software and platforms like HDMI Link, MoniCon, OBS Studio, QuickTime, and YouTube, and works with Windows 7/8/8.1/10, MacOS, Linux, Android, and iPadOS 17+. Enjoy seamless integration and exceptional performance across almost all your devices.
  • [WARRKY] We are committed to delivering exceptional quality products that combine sophisticated design with affordable pricing, offering you the best solutions for seamlessly connecting your work and life. If you have any issues, please reach out to us at your convenience. Your satisfaction is our top priority.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common failures and fixes

Blank or partially drawn chart

  • Cause: The canvas exists before Chart.js finishes drawing.
  • Fix: Disable animation or wait for animation.onComplete; do not use canvas existence as the readiness test.

Screenshot is the wrong size or blurry

  • Cause: The canvas render size and CSS display size differ, or the parent has no fixed dimensions.
  • Fix: Size a relatively positioned parent, set the viewport explicitly, use maintainAspectRatio: false when appropriate, and keep deviceScaleFactor consistent.

Labels or legend are missing

  • Cause: A clip covers only the canvas or is calculated before layout completes.
  • Fix: Wait for chart readiness, recalculate the container’s bounding box, and enlarge the clip to include external HTML labels.

Capture times out despite a loaded page

  • Cause: The application never sets its ready flag, a script error prevents chart construction, or a selector/data request is still pending.
  • Fix: Listen for browser console and page errors, verify the flag in DevTools, increase the timeout only after fixing the readiness path, and ensure every code path sets a success or failure state.

Network-idle wait never settles

  • Cause: Analytics, polling, WebSockets, or other long-lived requests keep the page active.
  • Fix: Do not make network idle your sole condition. Wait for the chart-specific flag; optionally block irrelevant requests in your test page.

Different output after a viewport change

  • Cause: Responsive redraw has not completed.
  • Fix: Call chart.resize(), wait for the next ready signal, and capture only after the new dimensions are applied.

Reliability and performance practices

  • Use a local or staging page with deterministic data for scheduled captures; live data and third-party fonts can change layout between runs.
  • Wait for fonts and images that affect layout before measuring a clip. A ready flag should be set only after those dependencies are available.
  • Reuse one browser process for a batch of URLs, but create a fresh page per capture to isolate viewport, cookies, and application state.
  • Close pages and browsers in finally blocks so failed jobs do not leak Chromium processes.
  • Prefer animation-free charts for reports and regression artifacts. Keep animation only when the final visual specifically depends on it.
  • Choose PNG for lossless text and line work; choose JPEG when a smaller photographic-style file is acceptable. Canvas export and Puppeteer screenshot options should match the consumer’s format requirements.

Or skip the browser setup

ScreenshotNeo is the quickest alternative when you need a rendered website image without maintaining Puppeteer. Send one GET request to its API; pass your chart page URL and choose PNG, JPEG, WebP, or PDF as needed. Its cleanup step accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture, with each step switchable. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a page that already renders your Chart.js chart, the one-call cURL example is:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/chart.html -o chart.webp

See the ScreenshotNeo documentation for all capture options, including viewport and device presets, full-page and CSS-selector captures, custom JavaScript and CSS, waits, blocked resources, headers, cookies, geolocation, caching, signed links, asynchronous webhooks, bulk capture, and PDF settings.

Equivalent Python request

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://example.com/chart.html"},
    timeout=90,
)
r.raise_for_status()
open("chart.webp", "wb").write(r.content)

Equivalent Node.js request

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com/chart.html' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
await Bun.write('chart.webp', res);

The Free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan, and yearly billing gives two months free. Create a free ScreenshotNeo account to try the capture.

Frequently asked questions

Can Puppeteer capture a Chart.js chart rendered inside an iframe?

Yes, but you must obtain the appropriate frame and wait for the chart-ready condition inside that frame. A screenshot of the top-level page includes the iframe’s rendered pixels, while canvas export must execute in the frame that owns the Chart.js instance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why does a transparent canvas look black in my output?

Canvas export preserves transparency when the chart background is transparent. A page screenshot may show the page’s background behind it. Set an explicit canvas or container background when the consumer requires a solid color.

Best Value
Anker USB C to HDMI Adapter (4K@60Hz), USB Type C to HDMI Cable Adapter
  • The Anker Advantage: Join the 80 million+ powered by our leading technology.
  • Vivid Video: The HDMI adapter lets you connect to any TV or display with an HDMI port to stream video in up to 4K resolution.
  • Plug and Play: Instantly turn your laptop’s USB-C port into an HDMI port, with no installation necessary. This product does not support charging or Power Delivery (PD).
  • Premium Construction: A lightweight aluminum casing allows for greater heat dissipation, while the reinforced braided-nylon cable is designed to withstand the twists and tugs of daily use.
  • Compatibility: Supports USB-C DP Alt mode, USB4, and Thunderbolt connections.

Should I use a full-page screenshot for a dashboard?

Use it only when the dashboard’s complete vertical layout is the artifact. For a chart tile, a selector clip is smaller and less sensitive to unrelated content below the chart.

Frequently Asked Questions

Can Puppeteer capture a Chart.js chart rendered inside an iframe?

Yes. Wait for the chart-ready state in the owning frame; page screenshots include the iframe pixels, while canvas export must run in that frame.

Why does a transparent canvas look black in my output?

Canvas export preserves transparency. Set an explicit chart or container background when a solid color is required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Should I use a full-page screenshot for a dashboard?

Only when the entire vertical dashboard is the intended artifact; otherwise clip the chart tile.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.