Interface Plugin

  • All Known Implementing Classes:
    AbstractPlugin

    public interface Plugin
    This interface is defining the extension hook for Chart.JS plugin implementation (both for inline and global plugins).
    Plugins are the most efficient way to customize or change the default behavior of a chart.
    Author:
    Andrea "Stock" Stocchero
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      String getId()
      Plugins must define a unique id in order to be configurable.
      Returns the plugin id.
      default void onAfterBuildTicks​(IsChart chart, PluginScaleArgument argument)
      Called after scale has build its ticks.
      This hook is called separately for each scale in the chart.
      default void onAfterDataLimits​(IsChart chart, PluginScaleArgument argument)
      Called after scale data limits are calculated.
      This hook is called separately for each scale in the chart.
      default void onAfterDatasetDraw​(IsChart chart, PluginDatasetArgument item)
      Called after the 'chart' datasets at the given 'args.index' have been drawn (datasets are drawn in the reverse order).
      Note that this hook will not be called if the datasets drawing has been previously cancelled.
      default void onAfterDatasetsDraw​(IsChart chart)
      Called after the 'chart' datasets have been drawn.
      Note that this hook will not be called if the datasets drawing has been previously cancelled.
      default void onAfterDatasetsUpdate​(IsChart chart, PluginUpdateArgument argument)
      Called after the 'chart' datasets have been updated.
      Note that this hook will not be called if the datasets update has been previously cancelled.
      default void onAfterDatasetUpdate​(IsChart chart, PluginDatasetArgument item)
      Called after the 'chart' datasets at the given 'args.index' has been updated.
      Note that this hook will not be called if the datasets update has been previously cancelled.
      default void onAfterDestroy​(IsChart chart)
      Called after the chart has been destroyed.
      default void onAfterDraw​(IsChart chart)
      Called after the 'chart' has been drawn.
      Note that this hook will not be called if the drawing has been previously cancelled.
      default void onAfterEvent​(IsChart chart, PluginEventArgument argument)
      Called after the 'event' has been consumed.
      Note that this hook will not be called if the 'event' has been previously discarded.
      default void onAfterInit​(IsChart chart, Chart nativeChart)
      Called after 'chart' has been initialized and before the first update.
      default void onAfterLayout​(IsChart chart)
      Called after the 'chart' has been layed out.
      Note that this hook will not be called if the layout update has been previously cancelled.
      default void onAfterRender​(IsChart chart)
      Called after the 'chart' has been fully rendered (and animation completed).
      Note that this hook will not be called if the rendering has been previously cancelled.
      default void onAfterTooltipDraw​(IsChart chart, PluginTooltipArgument item)
      Called after drawing the 'tooltip'.
      Note that this hook will not be called if the tooltip drawing has been previously cancelled.
      default void onAfterUpdate​(IsChart chart, PluginUpdateArgument argument)
      Called after 'chart' has been updated and before rendering.
      Note that this hook will not be called if the chart update has been previously cancelled.
      default void onBeforeBuildTicks​(IsChart chart, PluginScaleArgument argument)
      Called before scale builds its ticks.
      This hook is called separately for each scale in the chart.
      default void onBeforeDataLimits​(IsChart chart, PluginScaleArgument argument)
      Called before scale data limits are calculated.
      This hook is called separately for each scale in the chart.
      default boolean onBeforeDatasetDraw​(IsChart chart, PluginDatasetArgument item)
      Called before drawing the 'chart' dataset at the given 'args.index' (datasets are drawn in the reverse order).
      If any plugin returns false, the datasets drawing is cancelled until another 'render' is triggered.
      default boolean onBeforeDatasetsDraw​(IsChart chart)
      Called before drawing the 'chart' datasets.
      default boolean onBeforeDatasetsUpdate​(IsChart chart, PluginUpdateArgument argument)
      Called before updating the 'chart' datasets.
      If any plugin returns false, the datasets update is cancelled until another 'update' is triggered.
      default boolean onBeforeDatasetUpdate​(IsChart chart, PluginDatasetArgument item)
      Called before updating the 'chart' dataset at the given 'args.index'.
      If any plugin returns false, the datasets update is cancelled until another 'update' is triggered.
      default void onBeforeDestroy​(IsChart chart)
      Called before the chart is being destroyed.
      default boolean onBeforeDraw​(IsChart chart)
      Called before drawing 'chart' at every animation frame.
      If any plugin returns false, the frame drawing is cancelled until another 'render' is triggered.
      default void onBeforeElementsUpdate​(IsChart chart)
      Called during the update process, before any chart elements have been created.
      default boolean onBeforeEvent​(IsChart chart, PluginEventArgument argument)
      Called before processing the specified 'event'.
      If any plugin returns false, the event will be discarded.
      default void onBeforeInit​(IsChart chart)
      Called before initializing 'chart'.
      default boolean onBeforeLayout​(IsChart chart)
      Called before laying out 'chart'.
      If any plugin returns false, the layout update is cancelled until another 'update' is triggered.
      default boolean onBeforeRender​(IsChart chart)
      Called before rendering 'chart'.
      default boolean onBeforeTooltipDraw​(IsChart chart, PluginTooltipArgument item)
      Called before drawing the 'tooltip'.
      If any plugin returns false, the tooltip drawing is cancelled until another 'render' is triggered.
      default boolean onBeforeUpdate​(IsChart chart, PluginUpdateArgument argument)
      Called before updating 'chart'.
      If any plugin returns false, the update is cancelled (and thus subsequent render(s)) until another 'update' is triggered.
      default void onBeginDrawing​(IsChart chart, boolean overridePreviousUpdate)
      Called before every drawing cycle, coming from initialization, updating or rendering of chart.
      default void onConfigure​(IsChart chart)
      Called before initializing configuration of 'chart'.
      default void onEndDrawing​(IsChart chart)
      Called after every drawing cycle, coming from initialization, updating or rendering of chart.
      default void onInstall​(IsChart chart)
      Called when plugin is installed for this chart instance.
      This hook is also invoked for disabled plugins (options equals to false).
      default void onReset​(IsChart chart)
      Called during chart reset.
      default void onResize​(IsChart chart, PluginResizeArgument argument)
      Called after the chart as been resized.
      default void onStart​(IsChart chart)
      Called when a plugin is starting.
      This happens when chart is created or plugin is enabled.
      default void onStop​(IsChart chart)
      Called when a plugin stopping.
      This happens when chart is destroyed or plugin is disabled.
      default void onUninstall​(IsChart chart)
      Called after chart is destroyed on all plugins that were installed for that chart.
      This hook is also invoked for disabled plugins (options equals to false).
    • Method Detail

      • getId

        String getId()
        Plugins must define a unique id in order to be configurable.
        Returns the plugin id. A plugin id
        • can not start with a dot or an underscore
        • can not contain any non-URL-safe characters
        • cannot contain upper-case letters
        • should be something short, but also reasonably descriptive
        Returns:
        the plugin id.
      • onConfigure

        default void onConfigure​(IsChart chart)
        Called before initializing configuration of 'chart'.
        Parameters:
        chart - the chart instance.
      • onBeginDrawing

        default void onBeginDrawing​(IsChart chart,
                                    boolean overridePreviousUpdate)
        Called before every drawing cycle, coming from initialization, updating or rendering of chart.
        Parameters:
        chart - the chart instance
        overridePreviousUpdate - if true the drawing was already running.
      • onEndDrawing

        default void onEndDrawing​(IsChart chart)
        Called after every drawing cycle, coming from initialization, updating or rendering of chart.
        Parameters:
        chart - the chart instance
      • onBeforeInit

        default void onBeforeInit​(IsChart chart)
        Called before initializing 'chart'.
        Parameters:
        chart - the chart instance.
      • onAfterInit

        default void onAfterInit​(IsChart chart,
                                 Chart nativeChart)
        Called after 'chart' has been initialized and before the first update.
        Parameters:
        chart - the chart instance.
        nativeChart - CHART.JS chart instance
      • onBeforeUpdate

        default boolean onBeforeUpdate​(IsChart chart,
                                       PluginUpdateArgument argument)
        Called before updating 'chart'.
        If any plugin returns false, the update is cancelled (and thus subsequent render(s)) until another 'update' is triggered.
        Parameters:
        chart - the chart instance.
        argument - the argument passed for update
        Returns:
        false to cancel the chart update.
      • onAfterUpdate

        default void onAfterUpdate​(IsChart chart,
                                   PluginUpdateArgument argument)
        Called after 'chart' has been updated and before rendering.
        Note that this hook will not be called if the chart update has been previously cancelled.
        Parameters:
        chart - the chart instance.
        argument - the argument passed for update
      • onBeforeElementsUpdate

        default void onBeforeElementsUpdate​(IsChart chart)
        Called during the update process, before any chart elements have been created.
        Parameters:
        chart - the chart instance.
      • onBeforeLayout

        default boolean onBeforeLayout​(IsChart chart)
        Called before laying out 'chart'.
        If any plugin returns false, the layout update is cancelled until another 'update' is triggered.
        Parameters:
        chart - the chart instance.
        Returns:
        false to cancel the chart layout.
      • onAfterLayout

        default void onAfterLayout​(IsChart chart)
        Called after the 'chart' has been layed out.
        Note that this hook will not be called if the layout update has been previously cancelled.
        Parameters:
        chart - the chart instance.
      • onBeforeDatasetsUpdate

        default boolean onBeforeDatasetsUpdate​(IsChart chart,
                                               PluginUpdateArgument argument)
        Called before updating the 'chart' datasets.
        If any plugin returns false, the datasets update is cancelled until another 'update' is triggered.
        Parameters:
        chart - the chart instance.
        argument - the argument passed for update
        Returns:
        false to cancel the datasets update.
      • onAfterDatasetsUpdate

        default void onAfterDatasetsUpdate​(IsChart chart,
                                           PluginUpdateArgument argument)
        Called after the 'chart' datasets have been updated.
        Note that this hook will not be called if the datasets update has been previously cancelled.
        Parameters:
        chart - the chart instance.
        argument - the argument passed for update
      • onBeforeDatasetUpdate

        default boolean onBeforeDatasetUpdate​(IsChart chart,
                                              PluginDatasetArgument item)
        Called before updating the 'chart' dataset at the given 'args.index'.
        If any plugin returns false, the datasets update is cancelled until another 'update' is triggered.
        Parameters:
        chart - the chart instance.
        item - the dataset item.
        Returns:
        false to cancel the chart datasets drawing.
      • onAfterDatasetUpdate

        default void onAfterDatasetUpdate​(IsChart chart,
                                          PluginDatasetArgument item)
        Called after the 'chart' datasets at the given 'args.index' has been updated.
        Note that this hook will not be called if the datasets update has been previously cancelled.
        Parameters:
        chart - the chart instance.
        item - the dataset item.
      • onBeforeRender

        default boolean onBeforeRender​(IsChart chart)
        Called before rendering 'chart'.
        If any plugin returns false, the rendering is cancelled until another 'render' is triggered.
        Parameters:
        chart - the chart instance.
        Returns:
        false to cancel the chart rendering.
      • onAfterRender

        default void onAfterRender​(IsChart chart)
        Called after the 'chart' has been fully rendered (and animation completed).
        Note that this hook will not be called if the rendering has been previously cancelled.
        Parameters:
        chart - the chart instance.
      • onBeforeDraw

        default boolean onBeforeDraw​(IsChart chart)
        Called before drawing 'chart' at every animation frame.
        If any plugin returns false, the frame drawing is cancelled until another 'render' is triggered.
        Parameters:
        chart - the chart instance.
        Returns:
        false to cancel the chart drawing.
      • onAfterDraw

        default void onAfterDraw​(IsChart chart)
        Called after the 'chart' has been drawn.
        Note that this hook will not be called if the drawing has been previously cancelled.
        Parameters:
        chart - the chart instance.
      • onBeforeDatasetsDraw

        default boolean onBeforeDatasetsDraw​(IsChart chart)
        Called before drawing the 'chart' datasets.
        If any plugin returns false, the datasets drawing is cancelled until another 'render' is triggered.
        Parameters:
        chart - the chart instance.
        Returns:
        false to cancel the chart datasets drawing.
      • onAfterDatasetsDraw

        default void onAfterDatasetsDraw​(IsChart chart)
        Called after the 'chart' datasets have been drawn.
        Note that this hook will not be called if the datasets drawing has been previously cancelled.
        Parameters:
        chart - the chart instance.
      • onBeforeDatasetDraw

        default boolean onBeforeDatasetDraw​(IsChart chart,
                                            PluginDatasetArgument item)
        Called before drawing the 'chart' dataset at the given 'args.index' (datasets are drawn in the reverse order).
        If any plugin returns false, the datasets drawing is cancelled until another 'render' is triggered.
        Parameters:
        chart - the chart instance.
        item - the dataset item.
        Returns:
        false to cancel the chart datasets drawing.
      • onAfterDatasetDraw

        default void onAfterDatasetDraw​(IsChart chart,
                                        PluginDatasetArgument item)
        Called after the 'chart' datasets at the given 'args.index' have been drawn (datasets are drawn in the reverse order).
        Note that this hook will not be called if the datasets drawing has been previously cancelled.
        Parameters:
        chart - the chart instance.
        item - the dataset item.
      • onBeforeTooltipDraw

        default boolean onBeforeTooltipDraw​(IsChart chart,
                                            PluginTooltipArgument item)
        Called before drawing the 'tooltip'.
        If any plugin returns false, the tooltip drawing is cancelled until another 'render' is triggered.
        Parameters:
        chart - the chart instance.
        item - The tooltip instance.
        Returns:
        false to cancel the chart tooltip drawing.
      • onAfterTooltipDraw

        default void onAfterTooltipDraw​(IsChart chart,
                                        PluginTooltipArgument item)
        Called after drawing the 'tooltip'.
        Note that this hook will not be called if the tooltip drawing has been previously cancelled.
        Parameters:
        chart - the chart instance.
        item - The tooltip instance.
      • onBeforeEvent

        default boolean onBeforeEvent​(IsChart chart,
                                      PluginEventArgument argument)
        Called before processing the specified 'event'.
        If any plugin returns false, the event will be discarded.
        Parameters:
        chart - the chart instance.
        argument - instance which contains event context
        Returns:
        false to discard the event.
      • onAfterEvent

        default void onAfterEvent​(IsChart chart,
                                  PluginEventArgument argument)
        Called after the 'event' has been consumed.
        Note that this hook will not be called if the 'event' has been previously discarded.
        Parameters:
        chart - the chart instance.
        argument - instance which contains event context
      • onResize

        default void onResize​(IsChart chart,
                              PluginResizeArgument argument)
        Called after the chart as been resized.
        Parameters:
        chart - the chart instance.
        argument - argument of method which contains the new canvas display size (eq. canvas.style width and height).
      • onReset

        default void onReset​(IsChart chart)
        Called during chart reset.
        Parameters:
        chart - the chart instance.
      • onBeforeDestroy

        default void onBeforeDestroy​(IsChart chart)
        Called before the chart is being destroyed.
        Parameters:
        chart - the chart instance.
      • onAfterDestroy

        default void onAfterDestroy​(IsChart chart)
        Called after the chart has been destroyed.
        Parameters:
        chart - the chart instance.
      • onInstall

        default void onInstall​(IsChart chart)
        Called when plugin is installed for this chart instance.
        This hook is also invoked for disabled plugins (options equals to false).
        Parameters:
        chart - the chart instance.
      • onStart

        default void onStart​(IsChart chart)
        Called when a plugin is starting.
        This happens when chart is created or plugin is enabled.
        Parameters:
        chart - the chart instance.
      • onStop

        default void onStop​(IsChart chart)
        Called when a plugin stopping.
        This happens when chart is destroyed or plugin is disabled.
        Parameters:
        chart - the chart instance.
      • onUninstall

        default void onUninstall​(IsChart chart)
        Called after chart is destroyed on all plugins that were installed for that chart.
        This hook is also invoked for disabled plugins (options equals to false).
        Parameters:
        chart - the chart instance.
      • onBeforeDataLimits

        default void onBeforeDataLimits​(IsChart chart,
                                        PluginScaleArgument argument)
        Called before scale data limits are calculated.
        This hook is called separately for each scale in the chart.
        Parameters:
        chart - the chart instance.
        argument - argument of method which contains the scale instance.
      • onAfterDataLimits

        default void onAfterDataLimits​(IsChart chart,
                                       PluginScaleArgument argument)
        Called after scale data limits are calculated.
        This hook is called separately for each scale in the chart.
        Parameters:
        chart - the chart instance.
        argument - argument of method which contains the scale instance.
      • onBeforeBuildTicks

        default void onBeforeBuildTicks​(IsChart chart,
                                        PluginScaleArgument argument)
        Called before scale builds its ticks.
        This hook is called separately for each scale in the chart.
        Parameters:
        chart - the chart instance.
        argument - argument of method which contains the scale instance.
      • onAfterBuildTicks

        default void onAfterBuildTicks​(IsChart chart,
                                       PluginScaleArgument argument)
        Called after scale has build its ticks.
        This hook is called separately for each scale in the chart.
        Parameters:
        chart - the chart instance.
        argument - argument of method which contains the scale instance.