Config Module
datachart.config
Attributes
datachart.config.config
The configuration instance that the users should interact with.
Classes
datachart.config.Config
The class representing the configuration options.
| ATTRIBUTE | DESCRIPTION |
|---|---|
config |
The style configuration.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
set_theme |
Set the global configuration to match the theme. |
reset_config |
Resets the global configuration. |
update_config |
Updates the global configuration. |
register_theme |
Registers a custom theme for use with |
get |
Gets the associated configuration attribute. |
set_theme
Sets the global configuration to match the theme.
Replaces the whole style configuration with a deep copy of the theme:
one of the THEME constants or a name registered with register_theme.
Use it to switch the look of every chart rendered afterwards; call
update_config on top for per-attribute tweaks.
Added in v0.5.0
Examples:
>>> from datachart.constants import THEME
>>> from datachart.config import config
>>> config.set_theme(THEME.DEFAULT)
>>> config.get("theme")
'default'
| PARAMETER | DESCRIPTION |
|---|---|
theme
|
The theme to be set.
TYPE:
|
register_theme
Registers a custom theme so it can be applied with set_theme.
Added in v0.8.1
The theme must define every attribute of the default theme; missing keys are filled from it, unknown keys are rejected.
Examples:
>>> from datachart.config import config
>>> from datachart.themes import DEFAULT_THEME
>>> config.register_theme("mine", {**DEFAULT_THEME, "font_general_size": 14})
>>> config.set_theme("mine")
>>> config.get("font_general_size")
14
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The theme name, later passed to
TYPE:
|
theme
|
The style attributes of the theme.
TYPE:
|
reset_config
Resets the global configuration.
Restores the default theme, discarding the current theme and every
update_config override. Use it to return to a known state, for example
at the start of a notebook section or between tests.
Examples:
update_config
Updates the global configuration.
Overrides individual style attributes on top of the current theme; the
change persists until the next set_theme or reset_config. Use it for
global tweaks such as font family or default colors; unknown attribute
names are skipped with a warning.
Examples:
>>> from datachart.config import config
>>> config.update_config({"font_general_color": "#FFFFFF"})
>>> config.get("font_general_color")
'#FFFFFF'
| PARAMETER | DESCRIPTION |
|---|---|
config
|
The configuration attributes to be updated.
TYPE:
|
__getitem__
get
Gets the associated configuration attribute.
Reads one style attribute, falling back to default when it is not
set. Use it to inspect the active configuration or to build style
overrides relative to the current theme.
Examples:
| PARAMETER | DESCRIPTION |
|---|---|
attr
|
The attribute to retrieve.
TYPE:
|
default
|
The value to return, if the attribute is not present in the config.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any
|
The attribute value if present. Otherwise, returns the |