Source code for highcharts_stock.options.navigator

from typing import Optional, List
from decimal import Decimal

from validator_collection import validators

from highcharts_stock import errors
from highcharts_stock.decorators import class_sensitive, validate_types
from highcharts_stock.metaclasses import HighchartsMeta
from highcharts_stock.utility_classes.gradients import Gradient
from highcharts_stock.utility_classes.patterns import Pattern
from highcharts_stock.options.axes.x_axis import XAxis
from highcharts_stock.options.axes.y_axis import YAxis
from highcharts_stock.utility_functions import validate_color


[docs]class HandleOptions(HighchartsMeta): """Options for the handles that allow dragging the zoomed-in area.""" def __init__(self, **kwargs): self._background_color = None self._border_color = None self._enabled = None self._height = None self._line_width = None self._symbols = None self._width = None self.background_color = kwargs.get('background_color', None) self.border_color = kwargs.get('border_color', None) self.enabled = kwargs.get('enabled', None) self.height = kwargs.get('height', None) self.line_width = kwargs.get('line_width', None) self.symbols = kwargs.get('symbols', None) self.width = kwargs.get('width', None) @property def background_color(self) -> Optional[str | Gradient | Pattern]: """The background color or gradient for the pane. Defaults to ``'#f2f2f2'``. :returns: The backgorund color for the handle. :rtype: :class:`str <python:str>`, :class:`Gradient`, :class:`Pattern``, or :obj:`None <python:None>` """ return self._background_color @background_color.setter def background_color(self, value): from highcharts_core import utility_functions self._background_color = utility_functions.validate_color(value) @property def border_color(self) -> Optional[str | Gradient | Pattern]: """The color of the pane border. Defaults to ``'#999999'``. :returns: The color of the handle border and the stripes inside. :rtype: :class:`str <python:str>`, :class:`Gradient`, :class:`Pattern``, or :obj:`None <python:None>` """ return self._border_color @border_color.setter def border_color(self, value): from highcharts_core import utility_functions self._border_color = utility_functions.validate_color(value) @property def enabled(self) -> Optional[bool]: """If ``True``, enables the handles. if ``False``, disables them. Defaults to :obj:`None <python:None>`, which behaves as ``True``. :rtype: :class:`bool <python:bool>` or :obj:`None <python:None>` """ return self._enabled @enabled.setter def enabled(self, value): if value is None: self._enabled = None else: self._enabled = bool(value) @property def height(self) -> Optional[int | float | Decimal]: """The height given to the handles, expressed in pixels. Defaults to ``15``. :rtype: numeric or :obj:`None <python:None>` """ return self._height @height.setter def height(self, value): self._height = validators.numeric(value, allow_empty = True) @property def line_width(self) -> Optional[int | float | Decimal]: """The width of the handle border and the stripes inside, expressed in pixels. Defaults to ``1``. :rtype: numeric or :obj:`None <python:None>` """ return self._line_width @line_width.setter def line_width(self, value): self._line_width = validators.numeric(value, allow_empty = True) @property def symbols(self) -> Optional[List[str]]: """Configuration of the shapes given to the handles. Defaults to :obj:`None <python:None>`, which applies ``['navigator-handle', 'navigator-handle']``. .. note:: The ``symbols`` setting takes a 2-member collection of :class:`str <python:str>` values. These values can either indicate CSS styles (as in the default behavior), a ``url(...)`` to a graphic image, or the name of a (JavaScript) ``SVGRenderer.prototype.symbols`` callback method. :rtype: :class:`list <python:list>` of :class:`str <python:str>` or :obj:`None <python:None>` """ return self._symbols @symbols.setter def symbols(self, value): if not value: self._symbols = None else: self._symbols = [validators.string(x) for x in validators.iterable(value, minimum_length = 2, maximum_length = 2)] @property def width(self) -> Optional[int | float | Decimal]: """The width given to the handles, expressed in pixels. Defaults to ``7``. :rtype: numeric or :obj:`None <python:None>` """ return self._width @width.setter def width(self, value): self._width = validators.numeric(value, allow_empty = True) @classmethod def _get_kwargs_from_dict(cls, as_dict): kwargs = { 'background_color': as_dict.get('backgroundColor', None), 'border_color': as_dict.get('borderColor', None), 'enabled': as_dict.get('enabled', None), 'height': as_dict.get('height', None), 'line_width': as_dict.get('lineWidth', None), 'symbols': as_dict.get('symbols', None), 'width': as_dict.get('width', None), } return kwargs def _to_untrimmed_dict(self, in_cls = None) -> dict: untrimmed = { 'backgroundColor': self.background_color, 'borderColor': self.border_color, 'enabled': self.enabled, 'height': self.height, 'lineWidth': self.line_width, 'symbols': self.symbols, 'width': self.width, } return untrimmed
class NavigatorAccessibilityOptions(HighchartsMeta): """Accessibility options for the Navigator.""" def __init__(self, **kwargs): self._enabled = None self.enabled = kwargs.get('enabled') @property def _dot_path(self) -> Optional[str]: """The dot-notation path to the options key for the current class. :rtype: :class:`str <python:str>` or :obj:`None <python:None>` """ return 'accessibility' @property def enabled(self) -> Optional[bool]: """If ``True``, enables accessibility support for the navigator. Defaults to ``True``. :rtype: :class:`bool <python:bool>` """ return self._enabled @enabled.setter def enabled(self, value): if value is None: self._enabled = None else: self._enabled = bool(value) @classmethod def _get_kwargs_from_dict(cls, as_dict): kwargs = { 'enabled': as_dict.get('enabled', None), } return kwargs def _to_untrimmed_dict(self, in_cls = None) -> dict: untrimmed = { 'enabled': self.enabled, } return untrimmed