Class Dataset

    • Constructor Detail

      • Dataset

        protected Dataset​(Type type,
                          IsDefaultOptions defaultValues,
                          boolean hidden)
        Creates the data set using a default and chart type related to the data set, adding patterns and gradients element.
        Parameters:
        type - chart type related to the data set
        defaultValues - default options
        hidden - if true, it will be initially hidden.
    • Method Detail

      • getDataCount

        public final int getDataCount()
        Returns the amount of data.
        Returns:
        the amount of data
      • getId

        public final int getId()
        Returns the unique id of data sets.
        Returns:
        the unique id of data sets
      • getScope

        public final String getScope()
        Returns the scope of the data set, which is the options are used for defaults, chart defaults or chart.
        Specified by:
        getScope in interface HasCallbackScope
        Returns:
        the scope of the data set
      • getDataType

        public final DataType getDataType()
        Returns the data type of data sets.
        Returns:
        the data type of data sets
      • getDefaultValues

        protected final IsDefaultOptions getDefaultValues()
        Returns the default options instance.
        Returns:
        the default options instance.
      • getTypedDataset

        protected final IsDefaultTypedDataset getTypedDataset()
        Returns the typed data set for the type of the data set.
        Returns:
        the typed data set for the type of the data set
      • getBackgroundColorCallback

        public ColorCallback<DatasetContext> getBackgroundColorCallback()
        Returns the background color callback, if set, otherwise null.
        Returns:
        the background color callback, if set, otherwise null.
      • setBackgroundColor

        public void setBackgroundColor​(ColorCallback<DatasetContext> backgroundColorCallback)
        Sets the background color callback.
        Parameters:
        backgroundColorCallback - the background color callback.
      • setBackgroundColor

        public void setBackgroundColor​(NativeCallback backgroundColorCallback)
        Sets the background color callback.
        Parameters:
        backgroundColorCallback - the background color callback.
      • getBorderColorCallback

        public ColorCallback<DatasetContext> getBorderColorCallback()
        Returns the border color callback, if set, otherwise null.
        Returns:
        the border color callback, if set, otherwise null.
      • setBorderColor

        public void setBorderColor​(ColorCallback<DatasetContext> borderColorCallback)
        Sets the border color callback.
        Parameters:
        borderColorCallback - the border color callback.
      • setBorderColor

        public void setBorderColor​(NativeCallback borderColorCallback)
        Sets the border color callback.
        Parameters:
        borderColorCallback - the border color callback.
      • createContext

        protected final DatasetContext createContext​(NativeObject context)
        Creates a data set context for callback.
        Parameters:
        context - native context, passed by CHART.JS
        Returns:
        a data set context for callback
      • getHoverBackgroundColorCallback

        public ColorCallback<DatasetContext> getHoverBackgroundColorCallback()
        Returns the hover background color callback, if set, otherwise null.
        Returns:
        the hover background color callback, if set, otherwise null.
      • setHoverBackgroundColor

        public void setHoverBackgroundColor​(ColorCallback<DatasetContext> hoverBackgroundColorCallback)
        Sets the hover background color callback.
        Parameters:
        hoverBackgroundColorCallback - the hover background color callback.
      • setHoverBackgroundColor

        public void setHoverBackgroundColor​(NativeCallback hoverBackgroundColorCallback)
        Sets the hover background color callback.
        Parameters:
        hoverBackgroundColorCallback - the hover background color callback.
      • getHoverBorderColorCallback

        public ColorCallback<DatasetContext> getHoverBorderColorCallback()
        Returns the hover border color callback, if set, otherwise null.
        Returns:
        the hover border color callback, if set, otherwise null.
      • setHoverBorderColor

        public void setHoverBorderColor​(ColorCallback<DatasetContext> hoverBorderColorCallback)
        Sets the hover border color callback.
        Parameters:
        hoverBorderColorCallback - the hover border color callback.
      • setHoverBorderColor

        public void setHoverBorderColor​(NativeCallback hoverBorderColorCallback)
        Sets the hover border color callback.
        Parameters:
        hoverBorderColorCallback - the hover border color callback.
      • getDefaultBackgroundColorAsString

        protected String getDefaultBackgroundColorAsString()
        Returns the default background color value based on type of chart.
        Returns:
        the default background color value based on type of chart.
      • getDefaultBorderColorAsString

        protected String getDefaultBorderColorAsString()
        Returns the default border color value based on type of chart.
        Returns:
        the default border color value based on type of chart.
      • getDefaultBorderWidth

        protected int getDefaultBorderWidth()
        Returns the default border width value based on type of chart.
        Returns:
        the default border width value based on type of chart.
      • getDefaultHoverBackgroundColorAsString

        protected String getDefaultHoverBackgroundColorAsString()
        Returns the default background color value based on type of chart.
        Returns:
        the default background color value based on type of chart.
      • getDefaultHoverBorderColorAsString

        protected String getDefaultHoverBorderColorAsString()
        Returns the default border color value based on type of chart.
        Returns:
        the default border color value based on type of chart.
      • getDefaultHoverBorderWidth

        protected int getDefaultHoverBorderWidth()
        Returns the default border width value based on type of chart.
        Returns:
        the default border width value based on type of chart.
      • setHidden

        protected final void setHidden​(boolean hidden)
        Sets if the data set will appear or not.
        Parameters:
        hidden - if the data set will appear or not.
      • isHidden

        public final boolean isHidden()
        Returns if the data set at first drawing will appear or not.
        Returns:
        if the data set at first drawing will appear or not.
      • setParsing

        public void setParsing​(boolean parsing)
        Sets how to parse the data set.
        The parsing can be disabled by specifying parsing: false at chart options or data set.
        If parsing is disabled, data must be sorted and in the formats the associated chart type and scales use internally.
        Parameters:
        parsing - how to parse the data set.
        The parsing can be disabled by specifying parsing: false at chart options or data set.
        If parsing is disabled, data must be sorted and in the formats the associated chart type and scales use internally.
      • isParsing

        public boolean isParsing()
        Returns how to parse the data set.
        The parsing can be disabled by specifying parsing: false at chart options or data set.
        If parsing is disabled, data must be sorted and in the formats the associated chart type and scales use internally.
        Returns:
        how to parse the data set.
        The parsing can be disabled by specifying parsing: false at chart options or data set.
        If parsing is disabled, data must be sorted and in the formats the associated chart type and scales use internally.
      • setNormalized

        public void setNormalized​(boolean normalized)
        Sets if you provide data with indices that are unique, sorted, and consistent across data sets and provide the normalized: true option to let CHARBA know that you have done so.
        Parameters:
        normalized - if you provide data with indices that are unique, sorted, and consistent across data sets and provide the normalized: true option to let CHARBA know that you have done so.
      • isNormalized

        public boolean isNormalized()
        Returns if you provide data with indices that are unique, sorted, and consistent across data sets and provide the normalized: true option to let CHARBA know that you have done so.
        Returns:
        if you provide data with indices that are unique, sorted, and consistent across data sets and provide the normalized: true option to let CHARBA know that you have done so.
      • setLabel

        public void setLabel​(String label)
        Sets the label for the data set which appears in the legend and tooltips.
        Parameters:
        label - the label for the data set which appears in the legend and tooltips.
      • getLabel

        public String getLabel()
        Returns the label for the data set which appears in the legend and tooltips.
        Returns:
        the label for the data set which appears in the legend and tooltips.
      • setClip

        public void setClip​(boolean clip)
        Sets how to clip relative to the chart area.
        If false allows overflow, otherwise true clips that many pixels inside the chart area.
        Parameters:
        clip - If false allows overflow, otherwise true clips that many pixels inside the chart area.
      • setClip

        public void setClip​(double clip)
        Sets how to clip relative to the chart area.
        Positive value allows overflow, negative value clips that many pixels inside the chart area. 0 = clip at the chart area.
        Parameters:
        clip - positive value allows overflow, negative value clips that many pixels inside the chart area. 0 = clip at the chart area
      • setClip

        public void setClip​(Clip clip)
        Sets how to clip relative to the chart area, by an object which configures clipping per side.
        Positive value allows overflow, negative value clips that many pixels inside the chart area. 0 = clip at the chart area.
        Parameters:
        clip - object which configures clipping per side
      • isClip

        public boolean isClip()
        Returns if clips relative to the chart area.
        Returns:
        true if clips relative to the chart area.
      • getClip

        public double getClip()
        Returns how to clip relative to the chart area.
        Positive value allows overflow, negative value clips that many pixels inside the chart area. 0 = clip at the chart area.
        If the clip was set by a Clip object or boolean, returns Undefined.DOUBLE.
        Returns:
        positive value allows overflow, negative value clips that many pixels inside the chart area. 0 = clip at the chart area.
        If the clip was set by a Clip object or boolean, returns Undefined.DOUBLE
      • getClipAsObject

        public Clip getClipAsObject()
        Returns how to clip relative to the chart area.
        Positive value allows overflow, negative value clips that many pixels inside the chart area. 0 = clip at the chart area.
        If the clip was NOT set by a Clip object, returns a Clip instance with the same values.
        Returns:
        clip positive value allows overflow, negative value clips that many pixels inside the chart area. 0 = clip at the chart area.
        If the clip was NOT set by a Clip object, returns a Clip instance with the same values.
      • setData

        public void setData​(double... values)
        Sets the data property of a data set for a chart is specified as an array of numbers.
        Each point in the data array corresponds to the label at the same index on the x axis.
        Parameters:
        values - an array of numbers
      • setData

        public void setData​(List<Double> values)
        Sets the data property of a data set for a chart is specified as a list of numbers.
        Each point in the data list corresponds to the label at the same index on the x axis.
        Parameters:
        values - list of numbers.
      • getData

        public List<Double> getData()
        Returns the data property of a data set for a chart is specified as a list of numbers.
        Each point in the data list corresponds to the label at the same index on the x axis.
        Returns:
        list of numbers or an empty list of numbers if the data type is not DataType.NUMBERS.
      • getData

        public List<Double> getData​(boolean binding)
        Returns the data property of a data set for a chart is specified as a list of numbers.
        Each point in the data list corresponds to the label at the same index on the x axis.
        Parameters:
        binding - if true binds the new array list in the container
        Returns:
        list of numbers or an empty list of numbers if the data type is not DataType.NUMBERS.
      • getDataset

        public Dataset getDataset()
        Description copied from interface: HasDataset
        Gets the dataset instance.
        Specified by:
        getDataset in interface HasDataset
        Returns:
        the dataset instance
      • getType

        public final Type getType()
        Returns the type of data set, based on type of chart.
        Returns:
        type of data set.
      • removeOptions

        public void removeOptions​(String pluginId)
        Removes the plugin options.
        Parameters:
        pluginId - plugin id.
      • setOptions

        public <T extends AbstractPluginOptions> void setOptions​(T options)
        Sets the plugin options.
        Type Parameters:
        T - type of plugin options to store
        Parameters:
        options - plugin options used to configure the plugin
      • setOptions

        public final <T extends AbstractPluginOptions> void setOptions​(String pluginId,
                                                                       T options)
        Sets the plugin data set configuration.
        If data set configuration options is null, the configuration of plugin will be removed.
        Type Parameters:
        T - type of plugin options to store
        Parameters:
        pluginId - plugin id.
        options - options used to configure the plugin.
        Pass null to remove the configuration if exist.
      • hasOptions

        public final boolean hasOptions​(String pluginId)
        Checks if there is any data set configuration for a specific plugin, by its id.
        Parameters:
        pluginId - plugin id.
        Returns:
        true if there is an options, otherwise false.
      • getOptions

        public final <T extends AbstractPluginOptions> T getOptions​(String pluginId,
                                                                    AbstractPluginOptionsFactory<T> factory)
        Returns the plugin data set configuration, if exist.
        It uses a factory instance to create a plugin options.
        Type Parameters:
        T - type of plugin options to return
        Parameters:
        pluginId - plugin id.
        factory - factory instance to create a plugin options.
        Returns:
        options instance used to configure the plugin or null if factory is null.
      • getOptions

        public <T extends AbstractPluginOptions> T getOptions​(AbstractPluginOptionsFactory<T> factory)
        Returns the plugin options, if exist.
        It uses a factory instance to create a plugin options.
        If factory argument is not consistent, null is returned.
        Type Parameters:
        T - type of plugin options to return
        Parameters:
        factory - factory instance to create a plugin options
        Returns:
        plugin options used to configure the plugin or an empty object if not exist.
        If factory argument is not consistent, null is returned.
      • invokeColorCallback

        protected final Object invokeColorCallback​(DatasetContext context,
                                                   Scriptable<?,​DatasetContext> callback,
                                                   org.pepstock.charba.client.data.Dataset.CanvasObjectKey property,
                                                   String defaultValue)
        Returns a color value of property by a callback, checking all different types of object which can be used as value of the property in color ones.
        Parameters:
        context - scriptable context
        callback - callback to invoke
        property - property of data set used to store the color
        defaultValue - default value to return in case of chart, callback or result of callback are not consistent.
        Returns:
        a value of property as color