Class ChartsHelper


  • public class ChartsHelper
    extends java.lang.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
    • 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 all ZssCharts instances from the given Spreadsheet.
      static ZssCharts getChartsByName​(io.keikai.ui.Spreadsheet spreadsheet, java.lang.String name)
      Retrieves a ZssCharts instance from the given Spreadsheet by matching the widget's name.
      static void setCustomizer​(io.keikai.ui.Spreadsheet spreadsheet, ChartsCustomizer customizer)
      Associates a ChartsCustomizer instance with the given Spreadsheet.
      static void updateChart​(io.keikai.ui.Spreadsheet spreadsheet, io.keikai.model.SChart sChart)
      Updates the specified SChart in the spreadsheet.
      static void updateChart​(io.keikai.ui.Spreadsheet spreadsheet, io.keikai.model.SChart sChart, boolean dataLabelsEnabled)
      Updates the specified SChart in the spreadsheet with an option to enable data labels.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ChartsHelper

        public ChartsHelper()
    • Method Detail

      • getAllCharts

        public static java.util.List<ZssCharts> getAllCharts​(io.keikai.ui.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​(io.keikai.ui.Spreadsheet spreadsheet,
                                                java.lang.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​(io.keikai.ui.Spreadsheet spreadsheet,
                                       io.keikai.model.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​(io.keikai.ui.Spreadsheet spreadsheet,
                                       io.keikai.model.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​(io.keikai.ui.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