When we create a visualization and we want to export it, we can use two different approaches. We can export it as a bitmap image (for example, PNG) or we can export it as a vector image (SVG format). In this section, we'll look at both approaches.
Exporting visualizations
Exporting visualizations as PNG
To export an SVG element as a PNG, we need to take a couple of steps. Let's first get one of our visualizations that we want to export. We'll work with one of the geographic examples from Chapter 5, Working with Geo Data (D05-01.html):
To export this map, we'll take the following steps:
- Create a separate CSS for the styles we want to apply.
- Convert the SVG element to a string.
- Use the canvas to get a PNG file.
- Save the content from the canvas...