Class Palette

  • All Implemented Interfaces:
    Serializable, OptionDataListener, org.zkoss.json.JSONAware

    public class Palette
    extends Optionable
    The palette options specify the colors of the chart and how to apply them in light and dark mode. Each color scheme, getLight() and getDark(), has a background color, a neutral color and a highlight color, which are blended into CSS variables such as var(--highcharts-neutral-color-80).

    By default, ZK Charts uses the light color scheme, so charts don't follow the dark mode of the operating system. Call setColorScheme("light dark") to follow it.

    All the options in this class support DynamicalAttribute.

    Since:
    13.1.1.0
    Author:
    peggypeng
    See Also:
    Serialized Form
    • Constructor Detail

      • Palette

        public Palette()
    • Method Detail

      • getColors

        public List<Color> getColors()
        Returns the colors for data series and points, used in both light and dark mode.

        Default: null

      • setColors

        public void setColors​(List<Color> colors)
        Sets the colors for data series and points, used in both light and dark mode. Each mode can override them with PaletteScheme.setColors(List). The palette only accepts plain colors, not gradients or patterns.
      • setColors

        public void setColors​(String... source)
        Sets the colors for data series and points, used in both light and dark mode. Each mode can override them with PaletteScheme.setColors(String...). The palette only accepts plain colors, not gradients or patterns.
      • getColorScheme

        public String getColorScheme()
        Returns the color scheme to use.

        Default: "light"

      • setColorScheme

        public void setColorScheme​(String colorScheme)
        Sets the color scheme to use. "light dark" switches between light and dark mode following the operating system, or a parent element with the highcharts-light or highcharts-dark class. "light" and "dark" use one mode only. "inherit" uses the color scheme of the closest parent element that defines one, or light mode if none does.

        Defaults to "light", so charts don't follow the dark mode of the operating system unless set to "light dark".

        Parameters:
        colorScheme - "light dark", "light", "dark" or "inherit"
      • isInjectCSS

        public boolean isInjectCSS()
        Returns whether to inject the CSS for light and dark mode.

        Default: true

      • setInjectCSS

        public void setInjectCSS​(boolean injectCSS)
        Sets whether to inject the CSS for light and dark mode. If not injected, the page must include the CSS variables itself, for example from the bundled ~./js/chart/ext/css/highcharts-palette.css.
      • getLight

        public PaletteScheme getLight()
        Returns the palette options for light mode.
      • setLight

        public void setLight​(PaletteScheme light)
        Sets the palette options for light mode.
      • getDark

        public PaletteScheme getDark()
        Returns the palette options for dark mode.
      • setDark

        public void setDark​(PaletteScheme dark)
        Sets the palette options for dark mode.