The Windward Studio

Windward Blog Home

How to Generate HTML Charts in Reports

by
Posted on 02/19/2015

Please Share This

 

Recently a customer contacted support because he wanted to render HTML charts on the fly in a Web app, but the output wasn’t rendering properly. If you find yourself in the same situation — when you have generated a report and you would like to access the images before they are written out to the output — here’s what you need to know.

The Quick Overview

HTMLWhen generating images while using HTML output in Windward, Windward creates an image of the rendered chart. You then have to insert this image into your final report output.

Windward does this by saving the image as a bitmap stream. This stream can then be accessed by your calling application in order to display the image of the rendered chart properly.

How the Process Works

First, your image will be stored in memory as an array. Typically, these images would be written out as image files, although the option also exists to write these images as Base64 strings embedded in the HTML code.

Before the output is written to a file, you can access the image byte array directly through Windward’s API.

The .NET Engine

MSDotNETlogo

For .NET, this is ReportHTML.Bitmaps, which is an array of HtmlBitmap objects.  The bitmap can be accessed directly as a byte array (after the report has been processed) with:

myReportHtml.Bitmaps[0].Filedata

The Java Engine

java-logo

For Java, the same array can be accessed with ProcessHtmlAPI.getImageNames () which returns an array of HtmlImage objects.  So the equivalent code to access the bitmap stream directly is:

myProcessHtml.getImageNames().getStream()

NOTE: In the Java Engine, this will return an OutputStream.

Sample Code, Sample Template and More

For more details on how this works and to see sample code and a sample template, head on over to our wiki article on HTML Charts.

 

Please Share This



Author: Marcus Johnson

Marcus recently became a full-time employee after working 3 years as an intern at Windward. He has worked on a variety of projects such as sample code and videos, HTML output, and ensuring compatibility with App Engine and Android. He is now working hard with his team to release Windward's next product! When he’s not at work, he can be found in his apartment hanging out with his beautiful wife, reading or playing with the Phaser javascript library.

Other posts by