HyJavaApex Quick Start Guide

the java api for apexcharts

OVERVIEW

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

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

HOW TO USE THE LIBRARY

Java

Include the HyJavaApex jar in your project.

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

Apexchart apexchart = new YourBarChart().configure();
String chartOptionsJs = apexchart.chartOptionsToJs();


The YourBarChart class will look something like this:

public class YourBarChart {

    public Apexchart configure() {
        Apexchart apexchart = new Apexchart();
        ChartOptions chartOptions = apexchart.getChartOptions();

        chartOptions.getChart().setHeight(450).setType(ChartType.BAR);
        chartOptions.getPlotOptions().getBar().setHorizontal(true);
        chartOptions.getDataLabels().setEnabled(false);

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

        return apexchart;
    }

}
Javascript

Include required Javascript on your page as per ApexCharts documentation.

var chart = new ApexCharts(document.querySelector("#chart"), ${chartOptionsJs});
chart.render();

Your Java code will pass the chartOptionsJs string to the markup variable ${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://cdn.jsdelivr.net/npm/apexcharts"></script>

<div id="chart" style="max-width: 650px; margin: 35px auto; height: 800px;"></div>

<script>
var chart = new ApexCharts(document.querySelector("#chart"), ${chartOptionsJs});
chart.render();
</script>


That is all that is required to get a working Bar chart 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