Package io.keikaiex.util
Class ChartsHelper
java.lang.Object
io.keikaiex.util.ChartsHelper
Utility class for retrieving and updating
ZssCharts components from a
Spreadsheet, and for setting a ChartsCustomizer to intercept
and modify chart rendering.
Typical usage includes:
// Get all charts in a spreadsheet
List<ZssCharts> charts = ChartsHelper.getAllCharts(spreadsheet);
// Update a specific chart
ChartsHelper.updateChart(spreadsheet, sChart, true);
// Apply a custom chart customizer
ChartsHelper.setCustomizer(spreadsheet, new MyChartCustomizer());
- Since:
- 6.2.0
- Author:
- jameschu
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSpreadsheet attribute key for storing aChartsCustomizerinstance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAllCharts(Spreadsheet spreadsheet) Retrieves allZssChartsinstances from the givenSpreadsheet.static ZssChartsgetChartsByName(Spreadsheet spreadsheet, String name) Retrieves aZssChartsinstance from the givenSpreadsheetby matching the widget's name.static voidsetCustomizer(Spreadsheet spreadsheet, ChartsCustomizer customizer) Associates aChartsCustomizerinstance with the givenSpreadsheet.static voidupdateChart(Spreadsheet spreadsheet, SChart sChart) Updates the specifiedSChartin the spreadsheet.static voidupdateChart(Spreadsheet spreadsheet, SChart sChart, boolean dataLabelsEnabled) Updates the specifiedSChartin the spreadsheet with an option to enable data labels.
-
Field Details
-
CUSTOMIZER_ATTR_CLZ
Spreadsheet attribute key for storing aChartsCustomizerinstance.- See Also:
-
-
Constructor Details
-
ChartsHelper
public ChartsHelper()
-
-
Method Details
-
getAllCharts
Retrieves allZssChartsinstances from the givenSpreadsheet.- Parameters:
spreadsheet- the spreadsheet containing chart widgets- Returns:
- a list of all chart components in the spreadsheet
-
getChartsByName
Retrieves aZssChartsinstance from the givenSpreadsheetby matching the widget's name.- Parameters:
spreadsheet- the spreadsheet containing chart widgetsname- the name of the chart widget to retrieve- Returns:
- the matching chart component, or
nullif not found
-
updateChart
Updates the specifiedSChartin the spreadsheet. This method uses the default setting of not enabling data labels.- Parameters:
spreadsheet- the spreadsheet containing the chartsChart- the chart model containing updated configuration and data
-
updateChart
Updates the specifiedSChartin the spreadsheet with an option to enable data labels.- Parameters:
spreadsheet- the spreadsheet containing the chartsChart- the chart model containing updated configuration and datadataLabelsEnabled- whether to enable data labels in the rendered chart
-
setCustomizer
Associates aChartsCustomizerinstance with the givenSpreadsheet.The customizer will be applied during chart rendering to modify chart data or styling before display.
Configuration via Library Property
You can also configure a customizer globally using a library property:
<library-property> <name>io.keikai.chart.customizer.class</name> <value>com.example.MyChartCustomizer</value> </library-property>- Parameters:
spreadsheet- the spreadsheet to associate with the customizercustomizer- the customizer instance to apply
-