Class ChartsHelper

java.lang.Object
io.keikaiex.util.ChartsHelper

public class ChartsHelper extends Object
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 Details

  • Constructor Details

    • ChartsHelper

      public ChartsHelper()
  • Method Details

    • getAllCharts

      public static List<ZssCharts> getAllCharts(Spreadsheet spreadsheet)
      Retrieves all ZssCharts instances from the given Spreadsheet.
      Parameters:
      spreadsheet - the spreadsheet containing chart widgets
      Returns:
      a list of all chart components in the spreadsheet
    • getChartsByName

      public static ZssCharts getChartsByName(Spreadsheet spreadsheet, String name)
      Retrieves a ZssCharts instance from the given Spreadsheet by matching the widget's name.
      Parameters:
      spreadsheet - the spreadsheet containing chart widgets
      name - the name of the chart widget to retrieve
      Returns:
      the matching chart component, or null if not found
    • updateChart

      public static void updateChart(Spreadsheet spreadsheet, SChart sChart)
      Updates the specified SChart in the spreadsheet. This method uses the default setting of not enabling data labels.
      Parameters:
      spreadsheet - the spreadsheet containing the chart
      sChart - the chart model containing updated configuration and data
    • updateChart

      public static void updateChart(Spreadsheet spreadsheet, SChart sChart, boolean dataLabelsEnabled)
      Updates the specified SChart in the spreadsheet with an option to enable data labels.
      Parameters:
      spreadsheet - the spreadsheet containing the chart
      sChart - the chart model containing updated configuration and data
      dataLabelsEnabled - whether to enable data labels in the rendered chart
    • setCustomizer

      public static void setCustomizer(Spreadsheet spreadsheet, ChartsCustomizer customizer)
      Associates a ChartsCustomizer instance with the given Spreadsheet.

      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 customizer
      customizer - the customizer instance to apply