ZingChart Themes
The ZingChart library has several built-in themes as well as the ability to extend and create new themes.
Implementation
Graphset
You can enable themes in several ways. The first way to enable a theme is a the graphset
level.
let chartConfig = {
theme: 'dark',
graphset: [{
type: 'line',
noData: {},
series: []
}]
};
Top Level
If you are not using graphset
, you can just define theme
in the top level of your chart configuration.
let chartConfig = {
theme: 'dark',
type: 'line',
noData: {},
series: []
};
Globally
You can define a theme globally at the window level by defining the theme on the zingchart
window object.
// MUST define before zingchart.render() call
zingchart.THEME = 'dark';
let chartConfig = {
type: 'line',
noData: {},
series: []
};
Defaults (Custom)
You can define a theme globally in a JavaScript variable and assign the theme defaults at render.
// MUST define at a scope available at zingchart.render()
let myTheme = {};
let chartConfig = {
type: 'line',
noData: {},
series: []
};
zingchart.render({
id: 'myChart',
data: chartConfig,
defaults: myTheme
});
![https://app.zingsoft.com/demos/embed/A4WEINO4](https://storage.googleapis.com/studio_v_0_0_2/A4WEINO4/_desktop_preview_1567033493878.png)
Defaultsurl (Custom)
You can define a theme globally in a .txt
file and assign the theme defaults at render.
// MUST define at a scope available at zingchart.render()
let themeConfig = {};
let chartConfig = {
type: 'line',
noData: {},
series: []
};
zingchart.render({
id: 'myChart',
data: chartConfig,
defaultsurl: './path/to/myTheme.txt'
});
Default (Light)
The light theme is enabled by default implicitly.
![https://app.zingsoft.com/demos/embed/SK76JC7S](https://storage.googleapis.com/studio_v_0_0_2/SK76JC7S/_desktop_preview_1567033792217.png)
Dark
The dark theme will make the chart dark and the text light.
![https://app.zingsoft.com/demos/embed/C9AYGXJN](https://storage.googleapis.com/studio_v_0_0_2/C9AYGXJN/_desktop_preview_1567033816360.png)
Classic
The classic theme was the original theme from our Flash days. For backwards compatibility and to pay homage our roots, we still keep it around.
![https://app.zingsoft.com/demos/embed/CMW8L6W1](https://storage.googleapis.com/studio_v_0_0_2/CMW8L6W1/_desktop_preview_1567033800278.png)
Spark
The spark theme will remove all text and axis lines from the chart. The spark theme is a shortcut of default attributes which turn off a lot of features.
![https://app.zingsoft.com/demos/embed/LRGSA2DC](https://storage.googleapis.com/studio_v_0_0_2/LRGSA2DC/_desktop_preview_1567033831173.png)
Custom
A custom theme can be defined globally and applied to your charts.
![https://app.zingsoft.com/demos/embed/LZHII36K](https://storage.googleapis.com/studio_v_0_0_2/LZHII36K/_desktop_preview_1568396004716.png)
Summary
Themes allow you to quickly apply preset styling to each of your charts. You can use our built in themes or create your own!