Class Defaults


  • public final class Defaults
    extends Object
    This singleton is a wrapper to defaults object that CHART.JS (by CHART object) provides to get defaults values.
    Author:
    Andrea "Stock" Stocchero
    • Field Detail

      • ID

        public static final String ID
        Plugin ID "charbanativecharthandler", for an internal plugin to track native chart instances.
        See Also:
        Constant Field Values
    • Method Detail

      • get

        public static Defaults get()
        Singleton method to get static instance.
        Returns:
        defaults instance
      • getGlobal

        public GlobalOptions getGlobal()
        Returns the global options.
        Returns:
        the global options.
      • getScale

        public GlobalScale getScale()
        Returns the global scale.
        Returns:
        the global scale.
      • getScale

        public Scale getScale​(AxisType axisType)
        Returns the global scale by axis type.
        Parameters:
        axisType - the axis type to use to get defaults.
        Returns:
        a global scale for that axis type.
      • getPlugins

        public GlobalPlugins getPlugins()
        Returns the global plugins manager.
        Returns:
        the global plugins manager.
      • getControllers

        public Controllers getControllers()
        Returns the controllers.
        Returns:
        the controllers.
      • getOptions

        public ChartOptions getOptions​(Type type)
        Returns the default options by a chart type, by defaults of CHART.JS.
        If the type is not consistent, throws an exception.
        Parameters:
        type - chart type.
        Returns:
        the default options or throws an exception if type is not consistent.
      • generateLabels

        public List<LegendLabelItem> generateLabels​(Chart chart)
        Returns an unmodifiable list of legend labels for that chart with the callback provided by CHART.JS out of the box.
        Parameters:
        chart - chart instance to use to get legend labels
        Returns:
        an unmodifiable list of legend labels or an empty list if chart is not initialized.
      • generateLabels

        public List<LegendLabelItem> generateLabels​(IsChart chart)
        Returns an unmodifiable list of legend labels for that chart with the callback provided by CHART.JS out of the box.
        Parameters:
        chart - chart instance to use to get legend labels
        Returns:
        an unmodifiable list of legend labels or an empty list if chart is not initialized.
      • invokeChartOnClick

        public void invokeChartOnClick​(ChartClickEvent event)
        Invokes the onClick chart function provided out of the box by CHART.JS.
        Parameters:
        event - original event generated to invoke a chart click handler.
      • invokeChartOnHover

        public void invokeChartOnHover​(ChartHoverEvent event)
        Invokes the onHover chart function provided out of the box by CHART.JS.
        Parameters:
        event - original event generated to invoke a chart hover handler.
      • invokeLegendOnClick

        public void invokeLegendOnClick​(LegendClickEvent event)
        Invokes the onClick legend function provided out of the box by CHART.JS.
        Parameters:
        event - original event generated to invoke a legend click handler.
      • invokeLegendOnHover

        public void invokeLegendOnHover​(LegendHoverEvent event)
        Invokes the onHover legend function provided out of the box by CHART.JS.
        Parameters:
        event - original event generated to invoke a legend hover handler.
      • invokeLegendOnLeave

        public void invokeLegendOnLeave​(LegendLeaveEvent event)
        Invokes the onLeave legend function provided out of the box by CHART.JS.
        Parameters:
        event - original event generated to invoke a legend leave handler.
      • invokeTooltipsCallbackOnTitle

        public List<String> invokeTooltipsCallbackOnTitle​(IsChart chart,
                                                          List<TooltipItem> items)
        Returns the default text to render as the title of the tooltip.
        Parameters:
        chart - chart instance
        items - list of all tooltip items
        Returns:
        a list of labels to apply to the title.
      • invokeTooltipsCallbackOnLabel

        public List<String> invokeTooltipsCallbackOnLabel​(IsChart chart,
                                                          TooltipItem item)
        Returns the default text to render for an individual item in the tooltip.
        Parameters:
        chart - chart instance
        item - tooltip item
        Returns:
        labels to be applied.
      • invokeTooltipsCallbackOnLabelColor

        public TooltipLabelColor invokeTooltipsCallbackOnLabelColor​(IsChart chart,
                                                                    TooltipItem item)
        Returns the default colors to render for the tooltip item.
        Parameters:
        chart - chart instance
        item - tooltip item
        Returns:
        label color to be applied or null if arguments are not consistent
      • invokeTooltipsCallbackOnLabelPointStyle

        public TooltipLabelPointStyle invokeTooltipsCallbackOnLabelPointStyle​(IsChart chart,
                                                                              TooltipItem item)
        Returns the default point style to render for the tooltip item.
        Parameters:
        chart - chart instance
        item - tooltip item
        Returns:
        point style to be applied or null if arguments are not consistent