Class HTMLChart
java.lang.Object
com.amalgamasimulation.desktop.html.HTMLTag
com.amalgamasimulation.desktop.html.charts.HTMLChart
- All Implemented Interfaces:
HTMLConvertable
- Direct Known Subclasses:
HTMLBarChart,HTMLHistogramChart,HTMLLineChart
The HTMLChart class provides base functionality for creating HTML-based charts
using the ApexCharts library (https://apexcharts.com/). Handles chart container
initialization, visual set processing, and JavaScript rendering configuration.
- Author:
- Alexey Glazyrin
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs a new HTMLChart instance.HTMLChart(AbstractVisualSetContainer<?> visualSetContrainer) Constructs a new HTMLChart instance with the specified chart.HTMLChart(IAbstractChartVisualSet... visualSets) Constructs a new HTMLChart instance from individual visual sets.HTMLChart(List<IAbstractChartVisualSet> listVS) Constructs a new HTMLChart instance from a list of visual sets. -
Method Summary
Modifier and TypeMethodDescriptionCreates a deep copy of this HTMLConvertable element, preserving the element's structure while substituting text content using the provided translation mapping.font(FontDescriptor fontDescriptor) Sets the font of the chart.protected StringgenerateScript(List<IAbstractChartVisualSet> listVS, String id, Set<String> outStrings) Generates the JavaScript code required to render the chart.protected voidpreRenderJS(Set<String> outStrings) relativeHeight(double height) Sets the relative height of the chart container as a percentage.relativeWidth(double width) Sets the relative width of the chart container as a percentage.stacked(boolean stacked) Configures stacked display mode for chart elements.Sets the title of the chart.titleAlignment(com.amalgamasimulation.desktop.html.charts.ApexOptions.ApexAlign alignment) Sets the alignment of the chart title.titleColor(Color color) Sets the color of the chart title.titleFont(FontDescriptor fontDescriptor) Sets the font of the chart title.Generates the HTML representation of the chart, including the script to render it.xAxisTitle(String title) Sets the title for the X-axis.xAxisValueConverter(Function<Object, String> xAxisValueConverter) Sets a converter function for X-axis values formatting.yAxisLabelsDecimalSigns(int decimalSignsCount) Configures the number of decimal places to display on Y-axis labels.yAxisTitle(String title) Sets the title for the Y-axis.Methods inherited from class com.amalgamasimulation.desktop.html.HTMLTag
append, attr, backgroundColor, colorToRGBA, fillCopy, fontColor, fontFamily, fontSizeInPx, fontStyle, fontWeight, getAttributes, getChildren, lineHeight, marginInPx, maxHeightInPx, maxWidthInPx, paddingInPx, removeChildren, style, tag, tag, textAlignment, toCSSMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.amalgamasimulation.desktop.html.HTMLConvertable
copy, toHTML
-
Field Details
-
options
protected com.amalgamasimulation.desktop.html.charts.ApexOptions options -
processor
protected final com.amalgamasimulation.desktop.html.charts.ApexConfigProcessor processor
-
-
Constructor Details
-
HTMLChart
Constructs a new HTMLChart instance with the specified chart.- Parameters:
visualSetContrainer- the visualSetContrainer to render
-
HTMLChart
Constructs a new HTMLChart instance from individual visual sets.- Parameters:
visualSets- array of visual sets to display in the chart
-
HTMLChart
Constructs a new HTMLChart instance from a list of visual sets.- Parameters:
listVS- list of visual sets to configure chart data and appearance
-
HTMLChart
protected HTMLChart()Constructs a new HTMLChart instance. Initializes the chart container and script tag.
-
-
Method Details
-
toHTML
Generates the HTML representation of the chart, including the script to render it.- Specified by:
toHTMLin interfaceHTMLConvertable- Overrides:
toHTMLin classHTMLTag- Parameters:
outStrings- set of unique strings of text content- Returns:
- the HTML string representation of the chart
-
preRenderJS
-
copy
Description copied from interface:HTMLConvertableCreates a deep copy of this HTMLConvertable element, preserving the element's structure while substituting text content using the provided translation mapping.- Specified by:
copyin interfaceHTMLConvertable- Overrides:
copyin classHTMLTag- Parameters:
stringsSubstitutionMap- a map where keys are original text strings (as collected byHTMLConvertable.toHTML(Set)) and values are their translations. During copying, any encountered text content present in this map will be replaced with its translated version.- Returns:
- a new independent copy of this HTMLConvertable instance with translated content
-
relativeWidth
Sets the relative width of the chart container as a percentage.- Overrides:
relativeWidthin classHTMLTag- Parameters:
width- the width as a percentage (e.g., 0.5 for 50%)- Returns:
- this HTMLChart instance for method chaining
-
relativeHeight
Sets the relative height of the chart container as a percentage.- Overrides:
relativeHeightin classHTMLTag- Parameters:
height- the height as a percentage (e.g., 0.5 for 50%)- Returns:
- this HTMLChart instance for method chaining
-
title
Sets the title of the chart.- Parameters:
title- the title text- Returns:
- this HTMLChart instance for method chaining
-
titleColor
Sets the color of the chart title.- Parameters:
color- the color of the title- Returns:
- this HTMLChart instance for method chaining
-
titleFont
Sets the font of the chart title.- Parameters:
fontDescriptor- the font descriptor to use for the title- Returns:
- this HTMLChart instance for method chaining
-
xAxisValueConverter
Sets a converter function for X-axis values formatting.- Parameters:
xAxisValueConverter- function to convert raw X-values to display strings- Returns:
- this HTMLChart instance for method chaining
-
xAxisTitle
Sets the title for the X-axis.- Parameters:
title- axis label text- Returns:
- this HTMLChart instance for method chaining
-
yAxisTitle
Sets the title for the Y-axis.- Parameters:
title- axis label text- Returns:
- this HTMLChart instance for method chaining
-
yAxisLabelsDecimalSigns
Configures the number of decimal places to display on Y-axis labels.- Parameters:
decimalSignsCount- the number of decimal digits to display on Y-axis labels. Must be a non-negative integer- Returns:
- this HTMLChart instance for method chaining
-
titleAlignment
public HTMLChart titleAlignment(com.amalgamasimulation.desktop.html.charts.ApexOptions.ApexAlign alignment) Sets the alignment of the chart title.- Parameters:
alignment- the alignment of the title- Returns:
- this HTMLChart instance for method chaining
-
font
Sets the font of the chart. -
stacked
Configures stacked display mode for chart elements.- Parameters:
stacked- true to enable stacked visualization, false for grouped- Returns:
- this HTMLChart instance for method chaining
-
generateScript
protected String generateScript(List<IAbstractChartVisualSet> listVS, String id, Set<String> outStrings) Generates the JavaScript code required to render the chart. Processes visual sets and converts configuration to ApexCharts format.- Parameters:
listVS- list of visual sets defining chart data and stylesid- unique DOM element ID for chart container- Returns:
- JavaScript code that initializes and renders the chart
-