Image output

Convert highcharts.js into an image

Generate charts and graphs using Highcharts.js

You can generate images of charts using Highcharts.js + the HTML/CSS to Image API. When making charts, be sure to disable any animations. They may cause issues when creating the image.
Preview of Convert highcharts.js into an image

Interactive example

Edit and render this image

This example depends on browser behavior that cannot run reliably in the inline iframe. Edit the source and options, then select regenerate image to preview the real API output.
Current output for Convert highcharts.js into an image

Example code

Use this request in your app

Choose a language and copy a complete request using this example's HTML, CSS, and API options.

# pip install requests
import os
import requests

request = {
    "html": """<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/series-label.js"></script>

<div id="container"></div>

<script>  
Highcharts.chart('container', {
  chart: {
    animation: false
  },
  title: {
    text: 'Solar Employment Growth by Sector, 2010-2016'
  },

  subtitle: {
    text: 'Source: thesolarfoundation.com'
  },

  yAxis: {

    title: {
      text: 'Number of Employees'
    }
  },
  legend: {
    layout: 'vertical',
    align: 'right',
    verticalAlign: 'middle'
  },

  plotOptions: {
    series: {
      animation: false,
      label: {
        connectorAllowed: false
      },
      pointStart: 2010
    }
  },

  series: [{
    name: 'Installation',
    data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
  }, {
    name: 'Manufacturing',
    data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434]
  }, {
    name: 'Sales & Distribution',
    data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387]
  }, {
    name: 'Project Development',
    data: [null, null, 7988, 12169, 15112, 22452, 34400, 34227]
  }, {
    name: 'Other',
    data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111]
  }],

  responsive: {
    rules: [{
      condition: {
        maxWidth: 500
      },
      chartOptions: {
        legend: {
          layout: 'horizontal',
          align: 'center',
          verticalAlign: 'bottom'
        }
      }
    }]
  }
});
</script>""",
    "ms_delay": 200,
    "transparent_background": True,
}

response = requests.post(
    "https://hcti.io/v1/image",
    auth=(os.environ["HCTI_API_ID"], os.environ["HCTI_API_KEY"]),
    json=request,
    timeout=30,
)
response.raise_for_status()
result = response.json()
print(result["url"])

Request configuration

Options used in this example

These values are sent with the HTML and CSS to control how HCTI loads the page and captures the final screenshot. You can change each one in the editor above.

Transparent Background

transparent_background
True
If set to true, the background of the rendered image will be transparent.
Learn about this option

Ms Delay

ms_delay
200
Adds extra time before taking the screenshot, like if you need to wait for Javascript to execute
Learn about this option

From code to screenshot

How HCTI examples work

HTML/CSS to Image renders HTML and CSS in hosted Chrome, then captures the result as an image or PDF. Each example combines real source code with the API options used for the render, so it is both a working demo and a starting point for your own request.

Edit the source and options above to test changes in the browser, then render through the API to see the production result.

Common questions

Can I use the HTML and CSS from these examples?

Yes. Open an example to inspect and edit its complete HTML, CSS, and render options. Use it as a starting point, then send the resulting request from your application.

What is the difference between an example and a template?

Examples are complete API requests built from HTML and CSS. Templates are saved, reusable designs created in the visual editor and rendered repeatedly with different variable values.

Does HCTI create screenshots and PDFs?

Yes. HCTI can render HTML and CSS or capture a public webpage as an image, and it can generate PDFs when you need document output instead of a screenshot.

Keep exploring

Related examples

View all examples