Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public class ChartTheme

  1. Object
  2. ChartTheme
Colours a chart is painted with. The default palette is the Okabe-Ito set, chosen so neighbouring series stay distinguishable for the common forms of colour blindness, and a dark variant is picked automatically when the device is in dark mode.

Constructors

public ChartTheme(boolean dark)Creates the light or dark default theme.

Methods

public static ChartTheme createDefault()The theme for the device’s current appearance.
public static ChartTheme fromStyle(Style style)A theme matching a component style: light text means a dark background, whatever the device setting says, so an application with its own dark theme gets light labels.
public ChartTheme applyUIIDs(UIManager ui)Applies colours a theme sets on the chart’s part UIIDs: the foreground of ChartAxis colours axis labels and lines, ChartGrid the grid lines, ChartLegend the legend text, and the background and foreground of ChartTooltip the tooltip.
public int getLegendTextColor()The legend text colour; the secondary text colour unless ChartLegend or setLegendTextColor sets one.
public ChartTheme setLegendTextColor(int c)Sets the legend text colour.
public boolean isDark()True for a theme meant for a dark background.
public int tint(int rgb, float amount)A tint of rgb for nested levels: lighter on a light theme, darker on a dark one.
public int getSeriesColor(int index)The colour assigned to the series at index, cycling through the palette.
public ChartTheme setPalette(int... colors)Replaces the series palette.
public int getTextColor()Labels and titles.
public ChartTheme setTextColor(int c)Sets the label colour.
public int getSecondaryTextColor()Axis tick labels and the legend.
public ChartTheme setSecondaryTextColor(int c)Sets the tick label colour.
public int getGridColor()Grid lines.
public ChartTheme setGridColor(int c)Sets the grid colour.
public int getAxisColor()Axis lines and tick marks.
public ChartTheme setAxisColor(int c)Sets the axis line colour.
public int getTooltipBackground()Tooltip fill.
public ChartTheme setTooltipBackground(int c)Sets the tooltip fill.
public int getTooltipText()Tooltip text.
public ChartTheme setTooltipText(int c)Sets the tooltip text colour.
public int getPositiveColor()Rising candles, positive waterfall steps.
public ChartTheme setPositiveColor(int c)Sets the rising colour.
public int getNegativeColor()Falling candles, negative waterfall steps.
public ChartTheme setNegativeColor(int c)Sets the falling colour.

Inherited methods

Constructor details

ChartTheme

public ChartTheme(boolean dark)
Creates the light or dark default theme.

Parameters

dark boolean
true for colours suited to a dark background

Method details

createDefault

public static ChartTheme createDefault()
The theme for the device’s current appearance.

fromStyle

public static ChartTheme fromStyle(Style style)
A theme matching a component style: light text means a dark background, whatever the device setting says, so an application with its own dark theme gets light labels.

Parameters

style Style
the chart’s style; its foreground colour becomes the label colour

Returns

the derived theme

applyUIIDs

public ChartTheme applyUIIDs(UIManager ui)
Applies colours a theme sets on the chart’s part UIIDs: the foreground of ChartAxis colours axis labels and lines, ChartGrid the grid lines, ChartLegend the legend text, and the background and foreground of ChartTooltip the tooltip. A UIID the theme leaves out keeps the palette’s colour.

Parameters

ui UIManager
the UI manager to read the styles from

Returns

this theme

getLegendTextColor

public int getLegendTextColor()
The legend text colour; the secondary text colour unless ChartLegend or setLegendTextColor sets one.

setLegendTextColor

public ChartTheme setLegendTextColor(int c)
Sets the legend text colour.

Parameters

c int
an RGB colour

Returns

this theme

isDark

public boolean isDark()
True for a theme meant for a dark background.

tint

public int tint(int rgb, float amount)
A tint of rgb for nested levels: lighter on a light theme, darker on a dark one.

Parameters

rgb int
the base colour
amount float
0 for the colour itself, towards 1 for the background

Returns

the tint

getSeriesColor

public int getSeriesColor(int index)
The colour assigned to the series at index, cycling through the palette.

setPalette

public ChartTheme setPalette(int... colors)
Replaces the series palette.

getTextColor

public int getTextColor()
Labels and titles.

setTextColor

public ChartTheme setTextColor(int c)
Sets the label colour.

getSecondaryTextColor

public int getSecondaryTextColor()
Axis tick labels and the legend.

setSecondaryTextColor

public ChartTheme setSecondaryTextColor(int c)
Sets the tick label colour.

getGridColor

public int getGridColor()
Grid lines.

setGridColor

public ChartTheme setGridColor(int c)
Sets the grid colour.

getAxisColor

public int getAxisColor()
Axis lines and tick marks.

setAxisColor

public ChartTheme setAxisColor(int c)
Sets the axis line colour.

getTooltipBackground

public int getTooltipBackground()
Tooltip fill.

setTooltipBackground

public ChartTheme setTooltipBackground(int c)
Sets the tooltip fill.

getTooltipText

public int getTooltipText()
Tooltip text.

setTooltipText

public ChartTheme setTooltipText(int c)
Sets the tooltip text colour.

getPositiveColor

public int getPositiveColor()
Rising candles, positive waterfall steps.

setPositiveColor

public ChartTheme setPositiveColor(int c)
Sets the rising colour.

getNegativeColor

public int getNegativeColor()
Falling candles, negative waterfall steps.

setNegativeColor

public ChartTheme setNegativeColor(int c)
Sets the falling colour.