.options.chart
class: ChartOptions
- class ChartOptions(**kwargs)[source]
Configuration settings that apply to a chart.
Class Inheritance
- copy(other=None, overwrite=True, **kwargs)
Copy the configuration settings from this instance to the
other
instance.- Parameters:
other (
HighchartsMeta
) – The target instance to which the properties of this instance should be copied. IfNone
, will create a new instance and populate it with properties copied fromself
. Defaults toNone
.overwrite (
bool
) – ifTrue
, properties inother
that are already set will be overwritten by their counterparts inself
. Defaults toTrue
.kwargs – Additional keyword arguments. Some special descendents of
HighchartsMeta
may have special implementations of this method which rely on additional keyword arguments.
- Returns:
A mutated version of
other
with new property values
- classmethod from_dict(as_dict: dict, allow_snake_case: bool = True)
Construct an instance of the class from a
dict
object.
- classmethod from_js_literal(as_str_or_file, allow_snake_case: bool = True, _break_loop_on_failure: bool = False)
Return a Python object representation of a Highcharts JavaScript object literal.
- Parameters:
as_str_or_file (
str
) – The JavaScript object literal, represented either as astr
or as a filename which contains the JS object literal.allow_snake_case (
bool
) – IfTrue
, interpretssnake_case
keys as equivalent tocamelCase
keys. Defaults toTrue
._break_loop_on_failure (
bool
) – IfTrue
, will break any looping operations in the event of a failure. Otherwise, will attempt to repair the failure. Defaults toFalse
.
- Returns:
A Python object representation of the Highcharts JavaScript object literal.
- Return type:
HighchartsMeta
- classmethod from_json(as_json_or_file, allow_snake_case: bool = True)
Construct an instance of the class from a JSON string.
- Parameters:
as_json_or_file – The JSON string for the object or the filename of a file that contains the JSON string.
allow_snake_case (
bool
) – IfTrue
, interpretssnake_case
keys as equivalent tocamelCase
keys. Defaults toTrue
.
- Returns:
A Python objcet representation of
as_json
.- Return type:
HighchartsMeta
- get_required_modules(include_extension=False) List[str]
Return the list of URLs from which the Highcharts JavaScript modules needed to render the chart can be retrieved.
- to_dict() dict
Generate a
dict
representation of the object compatible with the Highcharts JavaScript library.Note
The
dict
representation has a property structure and naming convention that is intentionally consistent with the Highcharts JavaScript library. This is not Pythonic, but it makes managing the interplay between the two languages much, much simpler.
- to_js_literal(filename=None, encoding='utf-8', careful_validation=False) str | None
Return the object represented as a
str
containing the JavaScript object literal.- Parameters:
along the way using the esprima-python library. Defaults to
False
.Warning
Setting this value to
True
will significantly degrade serialization performance, though it may prove useful for debugging purposes.
- to_json(filename=None, encoding='utf-8', for_export: bool = False)
Generate a JSON string/byte string representation of the object compatible with the Highcharts JavaScript library.
Note
This method will either return a standard
str
or abytes
object depending on the JSON serialization library you are using. For example, if your environment has orjson, the result will be abytes
representation of the string.- Parameters:
filename (Path-like) – The name of a file to which the JSON string should be persisted. Defaults to
None
encoding (
str
) – The character encoding to apply to the resulting object. Defaults to'utf-8'
.for_export (
bool
) – IfTrue
, indicates that the method is being run to produce a JSON for consumption by the export server. Defaults toFalse
.
- Returns:
A JSON representation of the object compatible with the Highcharts library.
- Return type:
- static trim_dict(untrimmed: dict, to_json: bool = False, context: str = None, for_export: bool = False) dict
Remove keys from
untrimmed
whose values areNone
and convert values that have.to_dict()
methods.- Parameters:
untrimmed (
dict
) – Thedict
whose values may still beNone
or Python objects.to_json (
bool
) – IfTrue
, will remove all keys fromuntrimmed
that are not serializable to JSON. Defaults toFalse
.context (
str
orNone
) – If provided, will inform the method of the context in which it is being run which may inform special handling cases (e.g. where empty strings may be important / allowable). Defaults toNone
.for_export (
bool
) – IfTrue
, indicates that the method is being run to produce a JSON for consumption by the export server. Defaults toFalse
.
- Returns:
Trimmed
dict
- Return type:
- static trim_iterable(untrimmed, to_json=False, context: str = None, for_export: bool = False)
Convert any
EnforcedNullType
values inuntrimmed
to'null'
.- Parameters:
untrimmed (iterable) – The iterable whose members may still be
None
or Python objects.to_json (
bool
) – IfTrue
, will remove all members fromuntrimmed
that are not serializable to JSON. Defaults toFalse
.context (
str
orNone
) – If provided, will inform the method of the context in which it is being run which may inform special handling cases (e.g. where empty strings may be important / allowable). Defaults toNone
.for_export (
bool
) – IfTrue
, indicates that the method is being run to produce a JSON for consumption by the export server. Defaults toFalse
.
- Return type:
iterable
- property align_thresholds: bool | None
When using multiple axes, align the thresholds. When
True
, other ticks will also be aligned. Defaults toFalse
.Note
For line series and some other series types, the threshold option is set to
null
by default. This will in turn cause their y-axis to not have a threshold. In order to avoid that, set the series threshold to0
or another number.Note
If
AxisOptions.start_on_tick()
orAxisOptions.end_on_tick()
are set toFalse
, or if the axis is logarithmic, the threshold will not be aligned.
- property align_ticks: bool | None
If
True
and using multiple axes, the ticks of two or more opposite axes will automatically be aligned by adding ticks to the axis or axes with the least ticks, as iftick_amount
were specified. This can be prevented by settingalign_ticks
toFalse
.Defaults to
True
.Hint
If the grid lines look messy, it’s a good idea to hide them for the secondary axis by setting
grid_line_width
to0
.Warning
If
start_on_tick
orend_on_tick
in the axis options are set toFalse
, then tick alignment will be disabled for the axis.Warning
Aways disabled for logarithmic axes.
- property allow_mutating_data: bool | None
If
True
, the original data source will be allowed to be mutated. However, ifFalse
then Highcharts will create a copy of the original data to prevent inadvertent mutation. Defaults toTrue
.Note
By default, (for memory and performance reasons) the chart does not copy the data but keeps it as a reference.
In some cases, this might result in mutating the original data source. In order to prevent that, set this property to
False
. Please note that changing this may decrease performance, especially with bigger sets of data.
- property animation: bool | AnimationOptions | None
Configures the overall animation for all chart updating.
The animation can be configured as either a boolean or a
AnimationOptions
object. IfTrue
, it will apply the'swing'
jQuery easing and a duration of 500 ms by default. If used as aAnimationOptions
instance, you have more fine-grianed configuration control.Animation can be disabled throughout the chart by setting it to
False
here. It can be overridden for each individual API method as a function parameter. The only animation not affected by this option is the initial series animation, seePlotOptions.series.animation()
.When zooming on a series with less than 100 points, the chart redraw will be done with animation, but in case of more data points, it is necessary to set this option to ensure animation on zoom.
- Returns:
Settings for the animation of image patterns.
- Return type:
AnimationOptions
orNone
- property axis_layout_runs: int | None
The number of axis layout runs to execute when rendering the chart. Defaults to
2
.Note
When a chart with an x and a y-axis is rendered, we first pre-render the labels of both in order to measure them. Then, if either of the axis labels take up so much space that it significantly affects the length of the other axis, we repeat the process.
By default we stop at two axis layout runs, but it may be that the second run also alters the space required by either axis, for example if it causes the labels to rotate. In this situation, a subsequent redraw of the chart may cause the tick and label placement to change for apparently no reason.
Use the
.axis_layout_runs
property to set the maximum allowed number of repetitions.Warning
Keep in mind that the default value of
2
is set because every run costs performance time. Changing this value option to higher than the default might decrease performance significantly, especially with bigger sets of data.- Returns:
The maximum allowed number of axis layout runs.
- Return type:
- property background_color: str | Gradient | Pattern | None
The background color or gradient for the outer chart area. Defaults to
'#ffffff'
.
- property border_color: str | Gradient | Pattern | None
The color of the outer chart border. Defaults to
'#335cad'
.
- property border_radius: int | float | Decimal | None
The border radius (in pixels) applied to the outer chart border. Defaults to
0
.- Returns:
The border radius to apply to the outer chart border.
- Return type:
numeric or
None
- property border_width: int | float | Decimal | None
The border width (in pixels) applied to the outer chart border. Defaults to
0
.- Returns:
The border width to apply to the outer chart border.
- Return type:
numeric or
None
- property color_count: int | None
In styled mode, sets how many colors the class names should rotate between. Defaults to
10
With ten colors, series (or points) are given class names like
highcharts-color-0
,highcharts-color-0
[…]highcharts-color-9
. The equivalent in non-styled mode is to set colors using the colors setting.
- property display_errors: bool | None
If
True
, will display errors on the chart itself. IfFalse
, will only report errors to the console. Defaults toTrue
.
- property events: ChartEvents | None
Definition of JavaScript event listeners to apply to the chart.
- Return type:
ChartEvents
orNone
- property height: EnforcedNullType | int | float | Decimal | str | None
An explicit height for the chart. Defaults to
None
.If a number, the height is given in pixels. If given a percentage string (for example
'56%'
), the height is given as the percentage of the actual chart width. This allows for preserving the aspect ratio across responsive sizes.By default (when
None python:None>
) the height is calculated from the offset height of the containing element, or 400 pixels if the containing element’s height is 0.
If
True
, the axes will scale to the remaining visible series once one series is hidden. IfFalse
, hiding and showing a series will not affect the axes or the other series.Defaults to
True
.Note
For stacks, once one series within the stack is hidden, the rest of the stack will close in around it even if the axis is not affected.
- property inverted: bool | None
If
True
, inverts the axes so that the x-axis is vertical and y-axis is horizontal. Defaults toFalse
.Hint
When
True
, the x-axis is reversed by default.Warning
If a bar series is present in the chart, it will be inverted automatically.
Hint
Inverting the chart doesn’t have an effect if there are no cartesian series in the chart, or if the chart is a polar chart type.
- property margin: List[int | float | Decimal] | None
The margin between the outer edge of the chart and the plot area. The numbers in the array designate top, right, bottom and left respectively.
By default there is no margin. The actual space is dynamically calculated from the offset of axis labels, axis title, title, subtitle and legend in addition to the
spacing_top
,spacing_right
,spacing_bottom
andspacing_left
options.Note
This property is a convenience property to consolidate simple margin configuration across the
margin_top
,margin_right
,margin_bottom
, andmargin_left
options. Values will be propagated between all options.
- property margin_bottom: int | float | Decimal | None
The margin between the bottom outer edge of the chart and the plot area. Use this to set a fixed pixel value for the margin as opposed to the default dynamic margin.
By default, not set.
See also
Chart.spacing_bottom()
- Return type:
numeric or
None
- property margin_left: int | float | Decimal | None
The margin between the left outer edge of the chart and the plot area. Use this to set a fixed pixel value for the margin as opposed to the default dynamic margin.
By default, not set.
See also
Chart.spacing_left()
- Return type:
numeric or
None
- property margin_right: int | float | Decimal | None
The margin between the right outer edge of the chart and the plot area. Use this to set a fixed pixel value for the margin as opposed to the default dynamic margin.
By default, not set.
See also
Chart.spacing_right()
- Return type:
numeric or
None
- property margin_top: int | float | Decimal | None
The margin between the top outer edge of the chart and the plot area. Use this to set a fixed pixel value for the margin as opposed to the default dynamic margin.
By default, not set.
See also
Chart.spacing_top()
- Return type:
numeric or
None
- property number_formatter: CallbackFunction | None
JavaScript Callback function to override the default function that formats all the numbers in the chart. Returns a string with the formatted number.
- Return type:
CallbackFunction
orNone
- property options_3d: Options3D | None
Options to render charts in three dimensions.
Note
This feature requires the JavaScript
highcharts-3d.js
module, found in the download package or online at code.highcharts.com/highcharts-3d.js.- Return type:
Options3D
orNone
- property pan_key: str | None
Allows setting a key to switch between zooming and panning.
Accepts the following values:
'alt'
'ctrl'
'meta'
(the command key on Mac and Windows key on Windows)'shift'
.
The keys are mapped directly to the key properties of the click event argument (
event.altKey
,event.ctrlKey
,event.metaKey
, andevent.shiftKey
).
- property panning: PanningOptions | None
Configures panning behavior in a chart.
Hint
Best used with
Chart.pan_key()
to combine zooming and panning.Note
On touch devices, when the
Tooltip.follow_touch_move()
property isTrue
(default), panning requires two fingers. To allow panning with one finger, setfollow_touch_move
toFalse
.- Returns:
Configuration settings for panning behavior.
- Return type:
- property parallel_axes: ParallelAxesOptions | None
Common options for all Y-Axes rendered in a parallel coordinates plot.
Note
This feature requires in JavaScript
modules/parallel-coordinates.js
.- Return type:
ParallelAxesOptions
orNone
- property parallel_coordinates: bool | None
If
True
, renders charts as a parallel coordinates plot. Defaults toFalse
.In a parallel coordinates plot (||-coords) by default all required Y-axes are generated and the legend is disabled.
Note
This feature requires the JavaScript module
modules/parallel-coordinates.js
.See also
- property plot_background_color: str | Gradient | Pattern | None
The background color or gradient for the plot area. Defaults to
None
.
- property plot_background_image: str | None
The URL for an image to use as the background of the plot area.
Hint
To set an image as the background for the entire chart, set a CSS background image to the container element.
Note
Note that for the image to be applied to exported charts, its URL needs to be accessible by the export server.
- Return type:
- Raises:
HighchartsValueError – if a value is supplied that is not a URL or not path-like
- property plot_border_color: str | Gradient | Pattern | None
The color of the outer chart border. Defaults to
'#cccccc'
.
- property plot_border_width: int | float | Decimal | None
The border width (in pixels) applied to the outer chart border. Defaults to
0
.- Returns:
The border width to apply to the outer chart border.
- Return type:
numeric or
None
- property plot_shadow: bool | ShadowOptions | None
Configuration of a drop shadow applied to the plot area. Accepts either a boolean value of
False
which disables any shadow, or aShadowOptions
instance with the applicable configuration.Defaults to
False
.Warning
Requires that
Chart.plot_background_color()
be set.
- property polar: bool | None
If
True
, cartesian charts like line, spline, area, and column are transformed into the polar coordinate system. This produces polar charts (also known as radar charts). Defaults toFalse
.
- property reflow: bool | None
If
True
, reflows the chart to fit the width of the containerdiv
when the window is resized. Defaults toTrue
.
- property render_to: str | None
The ID of the HTML element where the chart will be rendered.
Note
In JavaScript, the HTML element can also be passed by direct reference, or as the first argument of the chart constructor, in which case the option is not needed.
- property scrollable_plot_area: ScrollablePlotArea | None
Configuration settings to make the plot area scrollable.
This feature provides a minimum size for the plot area of the chart. If the size gets smaller than this, typically on mobile devices, a native browser scrollbar is presented. This scrollbar provides smooth scrolling for the contents of the plot area, whereas the title, legend and unaffected axes are fixed.
Hint
Since v7.1.2, a scrollable plot area can be defined for either horizontal or vertical scrolling, depending on whether the minimum_width or minimum_height options are set.
- Return type:
ScrollablePlotArea
orNone
- property selection_marker_fill: str | Gradient | Pattern | None
The background color or the marker square when selecting (zooming in on) an area of the chart. Defaults to
'rgba(51,92,173,0.25)'
.
- property shadow: bool | ShadowOptions | None
Configuration of a drop shadow applied to the outer chart area. Accepts either a boolean value of
False
which disables any shadow, or aShadowOptions
instance with the applicable configuration.Defaults to
False
.Warning
Requires that
Chart.background_color()
be set.
- property show_axes: bool | None
If
True
, shows axes initially (before series have been added to the chart).Warning
This property only applies to empty charts where series are added dynamically.
- property spacing: List[int | float | Decimal] | None
The distance between the outer edge of the chart and the content, like title or legend, or axis title and labels if present. The numbers in the array designate top, right, bottom and left respectively.
By default,
[10,10,15,10]
.Note
This property is a convenience property to consolidate simple spacing configuration across the
spacing_top
,spacing_right
,spacing_bottom
, andspacing_left
options. Values will be propagated between all options.
- property spacing_bottom: int | float | Decimal | None
The spacing between the bottom edge of the chart and the content (plot area, axis title and labels, title, subtitle or legend in top position).
By default,
15
.- Return type:
numeric or
None
- property spacing_left: int | float | Decimal | None
The spacing between the left edge of the chart and the content (plot area, axis title and labels, title, subtitle or legend in top position).
Defaults to
10
.- Return type:
numeric or
None
- property spacing_right: int | float | Decimal | None
The spacing between the right edge of the chart and the content (plot area, axis title and labels, title, subtitle or legend in top position).
Defaults to
10
.- Return type:
numeric or
None
- property spacing_top: int | float | Decimal | None
The spacing between the top edge of the chart and the content (plot area, axis title and labels, title, subtitle or legend in top position).
Defaults to
10
.- Return type:
numeric or
None
- property style: str | dict | None
Additional CSS styles to apply inline to the container div.
Defaults to
'{"fontFamily": ""Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif","fontSize":"12px"}'
.Note
Since the default font styles are applied in the renderer, it is ignorant of the individual chart options and must be set globally.
- property styled_mode: bool | None
If
True
, sets the chart to operate in styled mode, where no presentational attributes or CSS are applied to the chart SVG. Instead, CSS rules are required to style the chart. Defaults toFalse
.See also
The Default Style Sheet: https://code.highcharts.com/css/highcharts.css.
- property type: str | None
The default series type for the chart. Defaults to
'line'
.Can be any of the chart types listed under
PlotOptions
andSeries
, or can be a series provided by an additional module.
- property width: EnforcedNullType | int | float | Decimal | str | None
An explicit width for the chart.
Defaults to
EnforcedNull <EnforcedNullType>`
which indicates a JavaScript value ofnull
(as opposed toNone
which results inundefined
when converted JavaScript.)If a number, the width is given in pixels. If given a percentage string (for example
'56%'
), the width is given as the percentage of the actual chart width. This allows for preserving the aspect ratio across responsive sizes.By default (when null) the width is calculated from the offset width of the containing element.
- property zooming: ZoomingOptions | None
Chart zooming configuration.
- Return type:
ZoomingOptions
orNone
class: PanningOptions
- class PanningOptions(**kwargs)[source]
Configures panning behavior in a chart.
Hint
Best used with
Chart.pan_key()
to combine zooming and panning.Note
On touch devices, when the
Tooltip.follow_touch_move()
property isTrue
(default), panning requires two fingers. To allow panning with one finger, setfollow_touch_move
toFalse
.Class Inheritance
- copy(other=None, overwrite=True, **kwargs)
Copy the configuration settings from this instance to the
other
instance.- Parameters:
other (
HighchartsMeta
) – The target instance to which the properties of this instance should be copied. IfNone
, will create a new instance and populate it with properties copied fromself
. Defaults toNone
.overwrite (
bool
) – ifTrue
, properties inother
that are already set will be overwritten by their counterparts inself
. Defaults toTrue
.kwargs – Additional keyword arguments. Some special descendents of
HighchartsMeta
may have special implementations of this method which rely on additional keyword arguments.
- Returns:
A mutated version of
other
with new property values
- classmethod from_dict(as_dict: dict, allow_snake_case: bool = True)
Construct an instance of the class from a
dict
object.
- classmethod from_js_literal(as_str_or_file, allow_snake_case: bool = True, _break_loop_on_failure: bool = False)
Return a Python object representation of a Highcharts JavaScript object literal.
- Parameters:
as_str_or_file (
str
) – The JavaScript object literal, represented either as astr
or as a filename which contains the JS object literal.allow_snake_case (
bool
) – IfTrue
, interpretssnake_case
keys as equivalent tocamelCase
keys. Defaults toTrue
._break_loop_on_failure (
bool
) – IfTrue
, will break any looping operations in the event of a failure. Otherwise, will attempt to repair the failure. Defaults toFalse
.
- Returns:
A Python object representation of the Highcharts JavaScript object literal.
- Return type:
HighchartsMeta
- classmethod from_json(as_json_or_file, allow_snake_case: bool = True)
Construct an instance of the class from a JSON string.
- Parameters:
as_json_or_file – The JSON string for the object or the filename of a file that contains the JSON string.
allow_snake_case (
bool
) – IfTrue
, interpretssnake_case
keys as equivalent tocamelCase
keys. Defaults toTrue
.
- Returns:
A Python objcet representation of
as_json
.- Return type:
HighchartsMeta
- get_required_modules(include_extension=False) List[str]
Return the list of URLs from which the Highcharts JavaScript modules needed to render the chart can be retrieved.
- to_dict() dict
Generate a
dict
representation of the object compatible with the Highcharts JavaScript library.Note
The
dict
representation has a property structure and naming convention that is intentionally consistent with the Highcharts JavaScript library. This is not Pythonic, but it makes managing the interplay between the two languages much, much simpler.
- to_js_literal(filename=None, encoding='utf-8', careful_validation=False) str | None
Return the object represented as a
str
containing the JavaScript object literal.- Parameters:
along the way using the esprima-python library. Defaults to
False
.Warning
Setting this value to
True
will significantly degrade serialization performance, though it may prove useful for debugging purposes.
- to_json(filename=None, encoding='utf-8', for_export: bool = False)
Generate a JSON string/byte string representation of the object compatible with the Highcharts JavaScript library.
Note
This method will either return a standard
str
or abytes
object depending on the JSON serialization library you are using. For example, if your environment has orjson, the result will be abytes
representation of the string.- Parameters:
filename (Path-like) – The name of a file to which the JSON string should be persisted. Defaults to
None
encoding (
str
) – The character encoding to apply to the resulting object. Defaults to'utf-8'
.for_export (
bool
) – IfTrue
, indicates that the method is being run to produce a JSON for consumption by the export server. Defaults toFalse
.
- Returns:
A JSON representation of the object compatible with the Highcharts library.
- Return type:
- static trim_dict(untrimmed: dict, to_json: bool = False, context: str = None, for_export: bool = False) dict
Remove keys from
untrimmed
whose values areNone
and convert values that have.to_dict()
methods.- Parameters:
untrimmed (
dict
) – Thedict
whose values may still beNone
or Python objects.to_json (
bool
) – IfTrue
, will remove all keys fromuntrimmed
that are not serializable to JSON. Defaults toFalse
.context (
str
orNone
) – If provided, will inform the method of the context in which it is being run which may inform special handling cases (e.g. where empty strings may be important / allowable). Defaults toNone
.for_export (
bool
) – IfTrue
, indicates that the method is being run to produce a JSON for consumption by the export server. Defaults toFalse
.
- Returns:
Trimmed
dict
- Return type:
- static trim_iterable(untrimmed, to_json=False, context: str = None, for_export: bool = False)
Convert any
EnforcedNullType
values inuntrimmed
to'null'
.- Parameters:
untrimmed (iterable) – The iterable whose members may still be
None
or Python objects.to_json (
bool
) – IfTrue
, will remove all members fromuntrimmed
that are not serializable to JSON. Defaults toFalse
.context (
str
orNone
) – If provided, will inform the method of the context in which it is being run which may inform special handling cases (e.g. where empty strings may be important / allowable). Defaults toNone
.for_export (
bool
) – IfTrue
, indicates that the method is being run to produce a JSON for consumption by the export server. Defaults toFalse
.
- Return type:
iterable
Sub-components
Module |
Classes / Functions |
---|---|