Package org.zkoss.chart
Class Palette
- java.lang.Object
-
- org.zkoss.chart.Optionable
-
- org.zkoss.chart.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()andgetDark(), has a background color, a neutral color and a highlight color, which are blended into CSS variables such asvar(--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
-
-
Field Summary
-
Fields inherited from class org.zkoss.chart.Optionable
NOT_NULL_VALUE, options
-
-
Constructor Summary
Constructors Constructor Description Palette()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Color>getColors()Returns the colors for data series and points, used in both light and dark mode.StringgetColorScheme()Returns the color scheme to use.PaletteSchemegetDark()Returns the palette options for dark mode.PaletteSchemegetLight()Returns the palette options for light mode.booleanisInjectCSS()Returns whether to inject the CSS for light and dark mode.voidsetColors(String... source)Sets the colors for data series and points, used in both light and dark mode.voidsetColors(List<Color> colors)Sets the colors for data series and points, used in both light and dark mode.voidsetColorScheme(String colorScheme)Sets the color scheme to use.voidsetDark(PaletteScheme dark)Sets the palette options for dark mode.voidsetInjectCSS(boolean injectCSS)Sets whether to inject the CSS for light and dark mode.voidsetLight(PaletteScheme light)Sets the palette options for light mode.-
Methods inherited from class org.zkoss.chart.Optionable
addExtraAttr, addOptionDataListener, clearOptonDataListener, clone, containsKey, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, getAttr, getAttr, getClientState, getExtraAttr, merge, onChange, removeExtraAttr, removeKey, removeOptionDataListener, setAttr, setAttr, setAttr, setAttr, toJSONString, toString
-
-
-
-
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 withPaletteScheme.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 withPaletteScheme.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 thehighcharts-lightorhighcharts-darkclass. "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.
-
-