HyJavaImages Library

the java api for highcharts

Take screenshots of your web pages and JavaScript charts in Java all on the server.

The HyJavaImages library is a pure Java library that allows you to create PNG, JPEG, WEBP and PDF images of your JavaScript charts on the server.
There is built-in support for Highcharts, Highcharts Stock and ApexCharts JavaScript charting libraries.

The library also allows you to create an image of any web page or supplied HTML text.
This allows you to create images of charts generated using any JavaScript charting library.

CODE ONLY IN JAVA

There are Java methods to convert:

  • Highcharts, Highcharts Stock and Apexcharts chart options to a base64 encoded image in PNG, JPEG, WEBP or PDF format
  • HTML to a base64 encoded image in PNG, JPEG, WEBP or PDF format
  • A URL to a base64 encoded image in PNG, JPEG, WEBP or PDF format

The chart options method above allows for direct integration with HyJavaCharts, HyJavaStock and HyJavaApex.
You are now able to generate JavaScript charts and create an image, all from within a Java application, with no JavaScript coding!

The library will start a Chrome headless server/or connect to an existing running Chrome headless server.
It then uses the DevTools Protocol to control Chrome.

There are methods to tune Chrome in high volume applications. See the Chrome.setPoolSize() method in the API.

DATA PRIVACY

Keep your confidential data secure. Chrome headless is running locally on your system. Your chart data used to generate the chart images does not leave your system.

EXAMPLE CODE

// Startup Chrome headless - (1)
Chrome chrome = Chrome.getInstance();
chrome.start();

// Generate as many chart images as needed - (2)
String base64;
ImageGenerator img = new ImageGenerator();

// Highchart png example - (3)
img.setJavaScript(LibraryType.HIGHCHARTS, null, "highcharts.js");
base64 = img.toBase64Image("{your chart options...}");

// Highstock png example - (3)
img.setJavaScript(LibraryType.HIGHCHARTS_STOCK, null, "stock/highstock.js");
base64 = img.toBase64Image("{your chart options...}");

// ApexCharts png example - (3)
img.setJavaScript(LibraryType.APEXCHARTS, null);
base64 = img.toBase64Image("{your chart options...}");

// HTML text png example
base64 = img.htmlToBase64Image("<html> your html... </html>");

// URL png example
base64 = img.toBase64Image(new URL("https://www.google.com"));

// Close down Chrome headless - (4)
chrome.stop();

Code description:

(1) Get the instance of Chrome and start the Chrome headless server using all defaults.
In a web servlet application chrome.start() should be called once in Servlet.init().

(2) The ImageGenerator class provides all methods to generate chart images.

(3) The setJavaScript method tells the library which JavaScript libraries to use to render the chart. The 2nd parameter is the library version or null for the latest.

(4) Stop the Chrome headless server.
In a web servlet application chrome.stop() should be called once in Servlet.destroy().

EXAMPLE APPLICATION

Download an example Java application showing usage of the HyJavaImages library.

API DOCUMENTATION

View the API for the HyJavaImages library.

DEMO APPLICATION

Start a demonstration Java web application using the HyJavaImages library.

REQUIREMENTS

You must have Chrome 71 or later installed on your system. The library requires a Chrome version that supports the DevTools protocol v1.3.

To render Highcharts chart images the HyJavaImages library requires a commercial or free Non-commercial license for the Highcharts JavaScript library.
To render Highcharts Stock chart images the HyJavaImages library requires a commercial or free Non-commercial license for the Highcharts Stock JavaScript library.

Please refer to the Highcharts license page for further details.

LIBRARY EVALUATION

A 30 day evaluation version of the HyJavaImages library is available to ensure the library meet your requirements.

The evaluation version is suitable for:

  • Proof of Concept testing
  • Integration testing
  • Performance testing

If you have any further questions on the library or wish to test the evaluation version, please contact our support team via the Contact Us area on the home page.

The Java API’s fully support all chart types and chart options in Highcharts v5.x, v6.x, v7.x, v8.x, v9.x;  Highcharts Stock v8.x, v9.x and ApexCharts v3.x.


Current versions supported are:

HyJavaCharts

HyJavaStock

HyJavaApex

Start the HyJavaCharts demo Java web application


Start the HyJavaStock demo Java web application


Start the HyJavaApex demo Java web application


Start the HyJavaImages demo Java web application