|
1 | 1 | from typing import Optional
|
2 | 2 | from decimal import Decimal
|
3 | 3 |
|
4 |
| -from validator_collection import validators |
| 4 | +from validator_collection import validators, checkers |
5 | 5 |
|
6 | 6 | from highcharts_core import errors, constants
|
7 | 7 | from highcharts_core.metaclasses import HighchartsMeta
|
@@ -372,3 +372,76 @@ def _to_untrimmed_dict(self, in_cls = None) -> dict:
|
372 | 372 | }
|
373 | 373 |
|
374 | 374 | return untrimmed
|
| 375 | + |
| 376 | + |
| 377 | +class YAxisTitle(AxisTitle): |
| 378 | + """The axis title, shown next to the axis line.""" |
| 379 | + |
| 380 | + def __init__(self, **kwargs): |
| 381 | + super().__init__(**kwargs) |
| 382 | + |
| 383 | + @property |
| 384 | + def _dot_path(self) -> Optional[str]: |
| 385 | + """The dot-notation path to the options key for the current class. |
| 386 | +
|
| 387 | + :rtype: :class:`str <python:str>` or :obj:`None <python:None>` |
| 388 | + """ |
| 389 | + return "yAxis.title" |
| 390 | + |
| 391 | + @property |
| 392 | + def text(self) -> Optional[str | constants.EnforcedNullType]: |
| 393 | + """The actual text of the title. |
| 394 | +
|
| 395 | + .. note:: |
| 396 | +
|
| 397 | + A subset of HTML is supported, e.g. ``<b>``, ``<i>``, ``<span>`` (with in-line |
| 398 | + styles), etc. |
| 399 | +
|
| 400 | + .. warning:: |
| 401 | +
|
| 402 | + A :meth:`.text <highcharts_core.options.axes.title.YAxisTitle.text>` of |
| 403 | + :obj:`None <python:None>` will default to ``'Values'``. To clear the Y-Axis title |
| 404 | + on your chart, set its value to an empty string (``''``). |
| 405 | +
|
| 406 | + :rtype: :class:`str <python:str>` or :obj:`None <python:None>` |
| 407 | + """ |
| 408 | + return self._text |
| 409 | + |
| 410 | + @text.setter |
| 411 | + def text(self, value): |
| 412 | + if isinstance(value, constants.EnforcedNullType): |
| 413 | + self._text = constants.EnforcedNull |
| 414 | + elif value == '': |
| 415 | + self._text = "" |
| 416 | + else: |
| 417 | + self._text = validators.string(value, allow_empty=True) |
| 418 | + |
| 419 | + @classmethod |
| 420 | + def _get_kwargs_from_dict(cls, as_dict): |
| 421 | + kwargs = { |
| 422 | + "align": as_dict.get("align", None), |
| 423 | + "margin": as_dict.get("margin", None), |
| 424 | + "offset": as_dict.get("offset", None), |
| 425 | + "position_3d": as_dict.get("position3d", None), |
| 426 | + "reserve_space": as_dict.get("reserveSpace", None), |
| 427 | + "rotation": as_dict.get("rotation", None), |
| 428 | + "skew_3d": as_dict.get("skew3d", None), |
| 429 | + "style": as_dict.get("style", None), |
| 430 | + "text": as_dict.get("text", None), |
| 431 | + "text_align": as_dict.get("textAlign", None), |
| 432 | + "use_html": as_dict.get("useHTML", None), |
| 433 | + "x": as_dict.get("x", None), |
| 434 | + "y": as_dict.get("y", None), |
| 435 | + } |
| 436 | + |
| 437 | + return kwargs |
| 438 | + |
| 439 | + def _to_untrimmed_dict(self, in_cls=None) -> dict: |
| 440 | + untrimmed = { |
| 441 | + } |
| 442 | + |
| 443 | + parent_as_dict = super()._to_untrimmed_dict(in_cls=in_cls) |
| 444 | + for key in parent_as_dict: |
| 445 | + untrimmed[key] = parent_as_dict[key] |
| 446 | + |
| 447 | + return untrimmed |
0 commit comments