Renders bar and line charts as PNG images using JFreeChart, and builds regression-based forecasts and anomaly detectors from time series data. Registered as the chartManager service and reached from JS via services.chartManager. Use newChartBuilder() to configure and render a chart as PNG bytes, or newRegressionBuilder() to accumulate date-value observations ahead of forecasting or anomaly detection.

Group: Managers


Methods

newChartBuilder()

Returns: ChartBuilder

Creates a new, empty chart builder for configuring and rendering a chart.

renderChart(String specJson)

Returns: byte[]

Renders a chart from a declarative JSON specification, as PNG bytes. The builder above is the API to use from Java. This one exists for callers that are handed a whole chart to draw rather than building one up - an agent tool, most obviously, where the specification arrives as JSON already and every builder call in between is a chance for a number to be coerced into something else on its way across Nashorn.

ParameterDescription
specJson{@code {chartType, title, xLabel, yLabel, width, height, categories:[..], series:[{name, values:[..]}]}}. chartType is one of bar, horizontalBar, stackedBar, line or pie, and defaults to bar; only categories and series are required

newRegressionBuilder()

Returns: RegressionBuilder

Creates a new regression builder named "default", for accumulating date-value observations ahead of forecasting or anomaly detection.

newRegressionBuilder(String name)

Returns: RegressionBuilder

Creates a new, named regression builder for accumulating date-value observations ahead of forecasting or anomaly detection.

ParameterDescription
nameidentifies the resulting model in log messages; has no effect on the data

toBase64(byte[] data)

Returns: String

Encodes the given bytes as a base64 string, for embedding a chart's image bytes directly in HTML or JSON.

ParameterDescription
datathe bytes to encode

buildBarChart(ChartBuilder b)

Returns: byte[]

Renders the data points added to the given builder as a JFreeChart bar chart and returns the PNG image bytes. Only CategoryDataPoint entries in the builder's data are plotted; other data point types are ignored.

ParameterDescription
bthe builder holding the chart's title, axis labels, dimensions and data

buildXYLineChart(ChartBuilder b)

Returns: byte[]

Renders the data points added to the given builder as a JFreeChart XY line chart and returns the PNG image bytes. Only XYDataPoint entries in the builder's data are plotted; other data point types are ignored. If the builder's date range flag is set, the x-axis is rendered with date-formatted tick units.

ParameterDescription
bthe builder holding the chart's title, axis labels, dimensions and data
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.