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

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Pass chart data from Node.js to the browser with Puppeteer’s page.evaluate(), then have a page-side function update the React state or props that feed the React-Vis series. Wait for a chart-specific completion signal before taking a screenshot or PDF; resolving the evaluation call alone does not prove the chart has finished rendering. This approach is best suited to an existing React-Vis application: the React-Vis project says the library is deprecated and will receive no patches or new features.

How the data handoff works

Node.js and the browser page run in separate JavaScript contexts. A variable in your Puppeteer script is not automatically available to the page. Pass serializable data explicitly as an argument to page.evaluate(), and let code already running in the page update the mounted React application.

  1. Node prepares the records. For a React-Vis series, the common shape is an array of objects with x and y values.
  2. Puppeteer transfers the records. Its page.evaluate(pageFunction, ...args) API executes a function in the page context and passes arguments to it. Puppeteer waits for a Promise returned by that function to resolve.
  3. The page updates React. A page-side function invokes the application’s normal update path so the series receives the new array through its data prop.
  4. Puppeteer waits for the visual result. Wait for an application-specific signal that means the updated chart is ready, then capture it.

React-Vis’s project example supplies an array of {x, y} objects to LineSeries, and its scales-and-data documentation describes a series’ data property as an array of objects. See the React-Vis repository.

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

Make the React app accept new data

Expose an update function from the page application, or use another explicit bridge that calls the same application update path. The function name and implementation are yours; React-Vis does not provide a built-in global setData or draw function. In a typical component, the series receives data from React state:

#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
function Chart({ rows }) {
  return (
    <XYPlot width={600} height={300}>
      <LineSeries data={rows} />
    </XYPlot>
  );
}

Arrange for the mounted application to update rows through its existing state or props mechanism. The exact wiring depends on your React version, root setup, bundler, and application architecture. Do not try to pass a component instance or React state setter from Node into the browser: pass the data and invoke browser-side application code instead.

For example, an application might assign a function that updates its chart state to window.updateChartData. That global is application-specific, not a React or React-Vis API. Define it only after the app’s update mechanism is available, and ensure it signals completion only after the chart update relevant to your capture has finished.

Runnable Puppeteer-side pattern

The following Node.js example shows the browser-side contract the page must provide: window.updateChartData(rows) updates the React app, and window.chartRenderComplete becomes true when the new chart is ready. Implement those two page-side behaviors in your app; they are not supplied by React-Vis. This example assumes the page has already loaded and the function is installed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({ headless: true });
  try {
    const page = await browser.newPage();
    await page.goto('http://localhost:3000/chart', {
      waitUntil: 'domcontentloaded',
    });

    const rows = [
      { x: 1, y: 8 },
      { x: 2, y: 13 },
      { x: 3, y: 9 },
    ];

    await page.waitForFunction(
      () => typeof window.updateChartData === 'function',
    );

    await page.evaluate(async (data) => {
      await window.updateChartData(data);
    }, rows);

    await page.waitForFunction(
      () => window.chartRenderComplete === true,
    );

    await page.screenshot({ path: 'chart.png' });
  } finally {
    await browser.close();
  }
})();

Replace the local URL, data and completion contract with those for your app. If the page function returns a Promise, resolve it only when its own update work is complete. Still use a chart-ready condition if rendering or other visual work continues after that Promise resolves. A completion flag should be reset when a new update starts and set only when the corresponding update is ready; otherwise an old true value can make the wait finish too early.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Wait for the chart, not merely for JavaScript to return

page.evaluate() resolving tells you the evaluated function returned or its Promise resolved. It does not establish that the browser has completed every asynchronous state update, layout pass, font or image load, or other visual dependency. Choose a condition tied to the output you need.

  • Application completion flag: wait for a flag your update path sets after the relevant chart update.
  • Expected rendered element: wait for a selector or visible chart element that appears only when the updated view is ready. Puppeteer’s current interaction guidance recommends locators for element interactions because they wait for element presence and the appropriate state.
  • Expected content: where meaningful, wait for a rendered label, point, or other DOM output associated with the incoming dataset.

Puppeteer documents page.waitForFunction() for a page-context condition and selector waits for elements. Avoid using a fixed sleep as the main readiness test: it can be unnecessarily slow on a fast run and too short on a slow one. Network idleness alone may also be unrelated to whether React has committed the chart update.

Capture a screenshot or PDF

Once the chart-specific wait succeeds, use the page’s screenshot or PDF method. For a screenshot:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.screenshot({ path: 'chart.png' });

Set the viewport before capture if chart dimensions depend on it, and check that your page’s responsive layout produces the intended size. If the chart relies on external fonts or images, include those in the page’s readiness condition where necessary.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

For PDF output:

await page.pdf({ path: 'chart.pdf', printBackground: true });

Puppeteer’s PDF API uses print CSS media by default. If the PDF should reflect screen media styles instead, call await page.emulateMediaType('screen') before page.pdf(). Print styles can change chart dimensions, colors, or visibility, so verify the media mode matches the output you intend.

Common failures and fixes

window.updateChartData is not a function

The app has not installed the page-side bridge when the evaluation runs, or the function is scoped inside a module rather than exposed on window. Install the bridge as part of app initialization and wait for it before calling it. Alternatively, call an available page-side mechanism that reaches the app’s update path.

The screenshot shows the old chart

The data reached the page, but capture happened before the updated React output was ready, or the update function did not change the state or props used by the rendered series. Confirm the chart reads the new array, reset any completion flag at the start of each update, and wait for a signal tied to the new data.

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.

The data argument is missing or malformed

Pass the records as an argument to page.evaluate(); do not reference a Node variable from inside the browser callback unless it is passed in. Keep the payload to data that can cross the evaluation boundary, and verify that the series receives objects in the shape it expects, such as {x, y} records for the documented line-series example.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

The wait times out

A timeout means the condition did not become true within the configured wait period; it does not identify the cause by itself. Check whether the app installed the bridge, whether the update path ran, whether the completion signal can be set, and whether the chart output selector matches the rendered page. Also inspect browser-console errors and page navigation or load failures.

The PDF differs from the screenshot

PDF output uses print media by default, so print CSS may alter the chart. Use page.emulateMediaType('screen') before generating the PDF when screen styles are wanted, or adjust print styles for the PDF layout.

Old React examples do not fit the app

The community answer associated with the original question dates to 2019 and uses React 15-era patterns. Treat its exposed-function idea as a sketch rather than current boilerplate; use the root and update APIs supported by the versions already installed in your project.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What to know before using React-Vis for a new project

The React-Vis repository’s deprecation notice says the project has no active maintainers and will receive no patches or new features. That makes this integration pattern most appropriate when maintaining an existing React-Vis application. For a new charting project, choose a library with maintenance and compatibility that meet your project’s requirements rather than treating the old examples as evidence of ongoing support.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Or skip the browser setup

If your goal is to capture a URL rather than pass a dataset into a mounted React app, ScreenshotNeo offers a website screenshot API and MCP server. For this React-Vis workflow, it does not replace the page-side data update: use the Puppeteer pattern above when your chart must receive runtime data. For a URL capture, one GET request can return an image or PDF. See the ScreenshotNeo API documentation.

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

ScreenshotNeo removes cookie banners, newsletter popups and chat widgets before capture; bot checks, blank pages and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots per month with no card, and paid plans start at $5 for 3,000 shots. Sign up for free and get 1,000 screenshots a month with no card.

Frequently Asked Questions

Can Puppeteer pass a JavaScript array to page.evaluate()?

Yes. Supply it as an argument after the page function, then use it in the browser-side function.

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.

Does React-Vis provide a built-in function for Puppeteer to update chart data?

No. The page-side bridge and the React state or props update are application wiring; React-Vis receives the resulting array through a series’ data prop.

Is this pattern suitable for an application that must adopt a maintained chart library?

It solves the data handoff, not the library-maintenance question. React-Vis’s repository states that the project is deprecated and will receive no patches or new features.

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.