October 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 NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
C3.js

How to Render C3.js Charts Correctly with wkhtmltopdf

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

If a PDF made with wkhtmltopdf contains the page text but not its C3.js chart, the first fix is to wait for the chart’s actual render-complete event—not just to assume that JavaScript is enabled. C3.js provides an onrendered callback; wkhtmltopdf provides --window-status. You can connect them by setting window.status after C3 finishes drawing, then asking wkhtmltopdf to wait for that status. This is a practical combination of documented features, not a guarantee that every installed wkhtmltopdf build supports every chart or script used by a page.

Why a C3.js chart can be missing from a wkhtmltopdf PDF

wkhtmltopdf converts a web page, but the page may not be ready to print as soon as its initial HTML has loaded. A C3.js chart depends on JavaScript, D3, a target element in the DOM, and often data that is fetched or processed asynchronously. The conversion can therefore reach its print step before the chart is drawn.

JavaScript is enabled by default in the upstream wkhtmltopdf usage documentation; --disable-javascript turns it off. The documented default JavaScript delay is 200 milliseconds. That delay is only a short timing allowance: it does not know whether a data request has completed or whether C3 has finished rendering. A longer delay can help when the page is simply slow, but it can also waste time and still be too short on a slower run.

The better signal is the event that corresponds to the outcome you need. C3 documents onrendered as the callback for chart rendering. Set a known page status there, then have wkhtmltopdf wait for that status. The upstream usage document describes wkhtmltopdf 0.12.6 with patched Qt; check the options supported by the exact binary you run, since the available sources do not establish a current compatibility matrix across builds and platforms.

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

Check the chart page before changing the PDF command

First make sure the page itself can produce a chart. wkhtmltopdf cannot print a chart that its page never successfully creates. C3 depends on D3, and its setup guide demonstrates loading D3 and C3 scripts as well as the C3 stylesheet. Confirm the following in the page’s normal browser environment:

  • D3 loads before C3, and neither script returns an error or fails to load.
  • The C3 stylesheet is present if the chart depends on its styles.
  • The element named by bindto exists when the chart is initialized.
  • Any chart data is available to the page, whether it is embedded or loaded separately.
  • The page’s JavaScript does not stop on an error before chart generation.

A successful page view in a modern browser is useful evidence, but it does not prove the installed wkhtmltopdf build can execute every feature used by that page. If the chart fails in wkhtmltopdf, inspect the page’s scripts, data access and JavaScript diagnostics in that rendering environment where possible; do not assume the problem is only the wait duration.

Use C3’s render callback as wkhtmltopdf’s readiness signal

In the page code, make the status value distinctive and set it from C3’s onrendered callback. The example below assumes that the page already loads D3 and C3, includes the C3 stylesheet, and contains an element with id="chart". Replace the sample data with the data your page actually uses.

<div id="chart"></div>
<script>
  var chart = c3.generate({
    bindto: '#chart',
    data: {
      columns: [
        ['Revenue', 12, 18, 15, 22]
      ]
    },
    onrendered: function () {
      window.status = 'c3-render-complete';
    }
  });
</script>

Have wkhtmltopdf wait for the same literal value:

wkhtmltopdf --window-status c3-render-complete https://example.com/report.html report.pdf

Replace https://example.com/report.html with the page you need to convert and report.pdf with the destination filename. The two strings must match exactly. If the page is local, use the local file path or URL form supported by your installed build and verify that it can read all local scripts, styles and data files. A status wait can only work if the page reaches the callback and sets the expected value.

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

Set the status after the work that affects the chart

Use onrendered rather than a data-load completion callback as the readiness marker. C3’s API reference warns that data loading may finish before chart rendering does. If your application modifies the chart again after its initial draw, set the signal only after the final change that must appear in the PDF. Otherwise wkhtmltopdf may correctly observe the first render while the page still has further work to do.

Keep fixed delays as a fallback, not the definition of readiness

For a quick diagnostic, try a longer fixed delay than wkhtmltopdf’s documented 200-millisecond default:

wkhtmltopdf --javascript-delay 2000 https://example.com/report.html report.pdf

The example uses two seconds as a test value, not as a universal recommendation. Choose a value based on the page, data source and runtime conditions. No universally sufficient delay is established here. If the delay appears to improve results but remains inconsistent, add a true readiness signal instead of repeatedly increasing the number.

When using both --window-status and a delay, treat the status as the meaningful condition and the delay as an additional timing allowance. Do not assume that adding a delay will repair missing scripts, failed data access or JavaScript errors.

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.

Choose between a delay and an explicit signal

Approach What it does Best fit Trade-off
--javascript-delay Waits for a fixed interval before conversion proceeds. The upstream usage documentation gives 200 milliseconds as the default. A simple test when the page’s work finishes predictably and quickly. Can wait longer than necessary or still finish too early when load time varies.
--window-status plus a page signal Waits for the page’s window.status to equal the requested value. Asynchronous pages where the application can signal that its required chart work is complete. Requires page code to set the correct value, and to set it only when the intended work is actually done.

This comparison describes how the documented mechanisms work; it is not a measured performance or compatibility test. A status signal better expresses readiness when data and drawing take variable time, while a delay is easier to try when you cannot change the page. Neither proves that the rendering engine supports every script feature your chart uses.

Run a repeatable troubleshooting sequence

  1. Confirm JavaScript is enabled. Remove --disable-javascript if it is present. JavaScript is enabled by default in the upstream usage documentation, but a wrapper or command line can change that behavior.
  2. Verify C3’s prerequisites. Check the D3 and C3 script load order, the stylesheet, the chart container, the data and the page’s JavaScript errors.
  3. Test with a longer delay. Use --javascript-delay to see whether extra time changes the output. A changed result suggests timing may matter; it does not establish a sufficient value for every run.
  4. Add an explicit readiness marker. Set window.status inside C3’s onrendered callback and pass the matching value to --window-status.
  5. Check the actual output and build. Inspect the generated PDF, confirm the status is reachable, and verify the flags against the installed wkhtmltopdf binary and deployment environment.
  6. Use a static artifact if the renderer remains unreliable. As a general engineering fallback, render the visualization as static SVG or an image in an environment known to support the page, then convert that artifact. This is a workflow option, not a verified universal C3-to-wkhtmltopdf procedure.

Common failure symptoms and what to check

Symptom Likely check Next step
Text and layout print, but the chart area is empty. JavaScript execution, C3/D3 script loading, chart container and data access. Fix page errors first; then use the render callback and status wait.
A longer delay sometimes works but results vary. Asynchronous loading or variable time to complete chart drawing. Signal readiness from onrendered rather than relying on a guessed fixed interval.
The status wait never completes as expected. The callback may not run, the status string may not match, or an earlier script/data error may prevent chart generation. Confirm the exact value is set by the page and that the chart reaches its callback.
The chart appears in a browser but not in the PDF. Differences between the browser used for inspection and the installed wkhtmltopdf rendering environment. Validate with the exact binary, page, data and deployment setup. The reviewed documentation does not establish a universal compatible version combination.

A 2014 issue titled “wkhtmltopdf does not print charts from original html page” reports a missing-chart problem; a commenter mentions C3.js among libraries they could not get to display. That report is anecdotal: it is useful as a recognizable symptom, but it does not prove that all C3 charts fail in wkhtmltopdf or that a longer wait fixes them.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What to know about reliability, runtime and deployment

A fixed delay spends the chosen interval even when a page finishes sooner, and it may still be insufficient when the page or its data takes longer. An explicit callback is more closely tied to chart completion, but it is only as reliable as the page code that emits it. In either case, a failed script, inaccessible data source, or unsupported browser-engine feature needs a separate fix.

Test the exact page in the same environment that will generate the production PDF. Include the actual data route, local-file permissions if relevant, installed wkhtmltopdf binary and command-line flags. The upstream usage material describes version 0.12.6 with patched Qt; that is not a claim that every distribution or build behaves identically. The available documentation does not supply a cross-platform comparison against alternative PDF renderers, so select or replace a renderer based on validation of your own page rather than a blanket compatibility claim.

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.

Or skip the browser setup

If you need a clean capture of a rendered webpage rather than to debug a wkhtmltopdf installation, ScreenshotNeo offers a website screenshot API and MCP server. Its API can return a screenshot or PDF. For a screenshot of a chart page, the documented one-call pattern is:

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

See the ScreenshotNeo API documentation for request options, including PDF output. ScreenshotNeo is a separate capture route, not a guarantee that every page’s chart code will render identically to wkhtmltopdf. Its stated features include removing cookie banners, newsletter popups and chat widgets before the shot; bot checks, blank pages and failed loads are not billed; and an MCP server lets AI agents take screenshots. The Free plan includes 1,000 shots per month with no card, and paid plans start at $5 for 3,000 shots.

Sign up for 1,000 free screenshots a month with no card.

Frequently Asked Questions

Does the documented 200 ms JavaScript delay guarantee that a C3 chart will appear?

No. It is a default timing allowance, not proof that the page’s data and chart rendering have finished.

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

Does the 2014 missing-chart report prove C3.js is incompatible with wkhtmltopdf?

No. It is an anecdotal report, not a compatibility test across C3 charts, wkhtmltopdf builds or environments.

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 *

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

Read next

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

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.