HyJavaStock Quick Start Guide

the java api for highcharts stock

OVERVIEW

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.

HOW TO USE THE LIBRARY

Java

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.getChart().setAlignTicks(false);
		chartOptions.getTitle().setText("AAPL Stock Volume");

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

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

Highcharts.setOptions(${globalOptionsJs});
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>

<script>
Highcharts.setOptions(${globalOptionsJs});
Highcharts.stockChart('container', ${chartOptionsJs});
</script>


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;  Highcharts Stock v8.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