Package io.keikaiex.util
Class ChartsHelper
- java.lang.Object
-
- io.keikaiex.util.ChartsHelper
-
public class ChartsHelper extends java.lang.ObjectUtility class for retrieving and updatingZssChartscomponents from aSpreadsheet, and for setting aChartsCustomizerto 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
Fields Modifier and Type Field Description static java.lang.StringCUSTOMIZER_ATTR_CLZSpreadsheet attribute key for storing aChartsCustomizerinstance.
-
Constructor Summary
Constructors Constructor Description ChartsHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<ZssCharts>getAllCharts(io.keikai.ui.Spreadsheet spreadsheet)Retrieves allZssChartsinstances from the givenSpreadsheet.static ZssChartsgetChartsByName(io.keikai.ui.Spreadsheet spreadsheet, java.lang.String name)Retrieves aZssChartsinstance from the givenSpreadsheetby matching the widget's name.static voidsetCustomizer(io.keikai.ui.Spreadsheet spreadsheet, ChartsCustomizer customizer)Associates aChartsCustomizerinstance with the givenSpreadsheet.static voidupdateChart(io.keikai.ui.Spreadsheet spreadsheet, io.keikai.model.SChart sChart)Updates the specifiedSChartin the spreadsheet.static voidupdateChart(io.keikai.ui.Spreadsheet spreadsheet, io.keikai.model.SChart sChart, boolean dataLabelsEnabled)Updates the specifiedSChartin the spreadsheet with an option to enable data labels.
-
-
-
Field Detail
-
CUSTOMIZER_ATTR_CLZ
public static final java.lang.String CUSTOMIZER_ATTR_CLZ
Spreadsheet attribute key for storing aChartsCustomizerinstance.- See Also:
- Constant Field Values
-
-
Method Detail
-
getAllCharts
public static java.util.List<ZssCharts> getAllCharts(io.keikai.ui.Spreadsheet spreadsheet)
Retrieves allZssChartsinstances from the givenSpreadsheet.- Parameters:
spreadsheet- the spreadsheet containing chart widgets- Returns:
- a list of all chart components in the spreadsheet
-
getChartsByName
public static ZssCharts getChartsByName(io.keikai.ui.Spreadsheet spreadsheet, java.lang.String name)
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
public static void updateChart(io.keikai.ui.Spreadsheet spreadsheet, io.keikai.model.SChart sChart)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
public static void updateChart(io.keikai.ui.Spreadsheet spreadsheet, io.keikai.model.SChart sChart, boolean dataLabelsEnabled)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
public static void setCustomizer(io.keikai.ui.Spreadsheet spreadsheet, ChartsCustomizer customizer)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
-
-