HyJavaStock Quick Start Guide

the java api for highcharts stock


The HyJavaStock Java library is a pure Java wrapper for the Highcharts Stock JavaScript library. It allows your Java-based web applications to configure Highcharts Stock charts using only Java methods. There is no need to write any JavaScript.

The library will generate the required JavaScript code that Highcharts Stock needs to render the charts.

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



Include the HyJavaStock jar in your project.

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

Highstock hs = new HighstockChart().configure();
String globalOptionsJs = hs.globalOptionsToJs();
String chartOptionsJs = hs.chartOptionsToJs();

The HighstockChart class will look something like this:

public class HighstockChart {

	public Highstock configure() {
		Highstock highStock = new Highstock();
		ChartOptions chartOptions = highStock.getChartOptions();
		chartOptions.getTitle().setText("AAPL Stock Volume");

		set all your required chart options......
		return highStock;

Include required JavaScript on your page as per Highcharts Stock documentation.

Highcharts.stockChart('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/stock/highstock.js></script>

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

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

That is all that is required to get a working Highcharts Stock example.

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:




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