Quick Start Guide

the highcharts java api


The HyJavaCharts Java library is a pure Java wrapper for the Highcharts Javascript library.
It allows your Java-based web applications to configure Highcharts charts using only Java methods. There is no need to write any Javascript.
The library will generate the required Javascript code that Highcharts needs to render the charts.

To define the contents of a chart, you simply have to instantiate the Highchart class and use its setter methods to define the chart options and chart data as required.



Include the HyJavaCharts jar in your project.

Configure your chart and generate the Javascript code for the global and chart options.

Highchart hc = new YourBarChart().configure();
String globalOptionsJs = hc.globalOptionsToJs();
String chartOptionsJs = hc.chartOptionsToJs();

The YourBarChart class will look something like this:

public class YourBarChart {

 public Highchart configure() {
  Highchart highChart = new Highchart();
  ChartOptions chartOptions = highChart.getChartOptions();

  chartOptions.title().text("Historic World Population by Region");
  chartOptions.subtitle().text("Source: Wikipedia.org");

  set all your required chart options......

  return highChart;


Include required Javascript on your page as per Highcharts documentation.

Highcharts.chart('container', ${chartOptionsJs});

Your Java code will pass the globalOptionsJs and chartOptionsJs strings to the markup variables ${globalOptionsJs} and ${chartOptionsJs}.
The method used to pass the generated chart options from the java to the web page will vary depending on your Java web framework.

Web Page

Your markup will look something like this:

<script src=https://code.highcharts.com/highcharts.js></script>

<div id="container" style="min-width: 310px; max-width: 800px; height: 400px; margin: 0 auto"></div>

Highcharts.chart('container', ${chartOptionsJs});

That is all that is required to get a working Bar chart example.