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!

CHROME HEADLESS

The library will start a Chrome headless server/or connect to an existing running Chrome headless server. It then establishes a Web Socket connection to the Chrome headless server and 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, "11.2.0", "highcharts.js");
base64 = img.toBase64Image("{your chart options...}");

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

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

// ApexCharts png example - (3)
img.setJavaScript(LibraryType.APEXCHARTS, "3.44.0");
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.

LIBRARY PERFORMANCE TESTING

See the HyJavaImages performance testing results.

REQUIREMENTS

Chrome

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

Highcharts

If you wish to to render Highcharts chart images, the HyJavaImages library requires a commercial or free Non-commercial license for the Highcharts JavaScript library.

Highcharts Stock

If you wish to 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 meets 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