Skip to content

Commit ff626c3

Browse files
authored
Merge pull request #87 from highcharts-for-python/develop
PR for v.1.3.3
2 parents 76d95e5 + 9ccc051 commit ff626c3

File tree

8 files changed

+395
-7
lines changed

8 files changed

+395
-7
lines changed

CHANGES.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11

2+
Release 1.3.3
3+
=========================================
4+
5+
* **BUGFIX:** Added in a missing class extension for ``NavigationButtonConfiguration`` (#86).
6+
7+
---------------------
8+
29
Release 1.3.2
310
=========================================
411

highcharts_core/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.3.2'
1+
__version__ = '1.3.3'

highcharts_core/options/navigation/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from highcharts_core.options.annotations import Annotation
88
from highcharts_core.options.navigation.bindings import Bindings
99
from highcharts_core.utility_classes.breadcrumbs import BreadcrumbOptions
10-
from highcharts_core.utility_classes.buttons import ButtonConfiguration
10+
from highcharts_core.utility_classes.buttons import NavigationButtonConfiguration
1111
from highcharts_core.utility_classes.events import NavigationEvents
1212

1313

@@ -78,15 +78,15 @@ def bindings_class_name(self, value):
7878
self._bindings_class_name = validators.string(value, allow_empty = True)
7979

8080
@property
81-
def button_options(self) -> Optional[ButtonConfiguration]:
81+
def button_options(self) -> Optional[NavigationButtonConfiguration]:
8282
"""Configuration options for navigation buttons.
8383
84-
:rtype: :class:`ButtonOptions`
84+
:rtype: :class:`NavigationButtonConfiguration <highcharts_core.utility_classes.buttons.NavigationButtonConfiguration>`
8585
"""
8686
return self._button_options
8787

8888
@button_options.setter
89-
@class_sensitive(ButtonConfiguration)
89+
@class_sensitive(NavigationButtonConfiguration)
9090
def button_options(self, value):
9191
self._button_options = value
9292

highcharts_core/utility_classes/buttons.py

Lines changed: 265 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ def text(self) -> Optional[str]:
119119

120120
@text.setter
121121
def text(self, value):
122-
self._text = validators.string(value, allow_empty = True)
122+
if isinstance(value, constants.EnforcedNullType):
123+
self._text = None
124+
else:
125+
self._text = validators.string(value, allow_empty = True)
123126

124127
@property
125128
def theme(self) -> Optional[ButtonTheme]:
@@ -651,4 +654,264 @@ def __getitem__(self, key):
651654
if key == 'context_button':
652655
key = 'contextButton'
653656

654-
return super().__getitem__(key)
657+
return super().__getitem__(key)
658+
659+
660+
class NavigationButtonConfiguration(ButtonConfiguration):
661+
"""Configuration options that apply to the Navigation buttons."""
662+
663+
def __init__(self, **kwargs):
664+
self._align = None
665+
self._button_spacing = None
666+
self._height = None
667+
self._symbol_fill = None
668+
self._symbol_size = None
669+
self._symbol_stroke = None
670+
self._symbol_stroke_width = None
671+
self._symbol_x = None
672+
self._symbol_y = None
673+
self._use_html = None
674+
self._vertical_align = None
675+
self._width = None
676+
677+
self.align = kwargs.get('align', None)
678+
self.button_spacing = kwargs.get('button_spacing', None)
679+
self.height = kwargs.get('height', None)
680+
self.symbol_fill = kwargs.get('symbol_fill', None)
681+
self.symbol_size = kwargs.get('symbol_size', None)
682+
self.symbol_stroke = kwargs.get('symbol_stroke', None)
683+
self.symbol_stroke_width = kwargs.get('symbol_stroke_width', None)
684+
self.symbol_x = kwargs.get('symbol_x', None)
685+
self.symbol_y = kwargs.get('symbol_y', None)
686+
self.use_html = kwargs.get('use_html', None)
687+
self.vertical_align = kwargs.get('vertical_align', None)
688+
self.width = kwargs.get('width', None)
689+
690+
super().__init__(**kwargs)
691+
692+
@property
693+
def align(self) -> Optional[str]:
694+
"""The alignment for the button. Defaults to ``'right'``.
695+
696+
Accepts:
697+
698+
* ``'left'``
699+
* ``'center'``
700+
* ``'right'``
701+
702+
:rtype: :class:`str <python:str>` or :obj:`None <python:None>`
703+
"""
704+
return self._align
705+
706+
@align.setter
707+
def align(self, value):
708+
if not value:
709+
self._align = None
710+
else:
711+
value = validators.string(value, allow_empty = False)
712+
value = value.lower()
713+
if value not in ['left', 'center', 'right']:
714+
raise errors.HighchartsValueError(f'align must be either "left", '
715+
f'"center", or "right". Was: {value}')
716+
717+
self._align = value
718+
719+
@property
720+
def button_spacing(self) -> Optional[int | float | Decimal]:
721+
"""The pixel spacing between buttons. Defaults to ``3``.
722+
723+
:rtype: numeric or :obj:`None <python:None>`
724+
"""
725+
return self._button_spacing
726+
727+
@button_spacing.setter
728+
def button_spacing(self, value):
729+
self._button_spacing = validators.numeric(value, allow_empty = True)
730+
731+
@property
732+
def height(self) -> Optional[int | float | Decimal]:
733+
"""The height of the buttons in pixels. Defaults to ``28``.
734+
735+
:rtype: numeric or :obj:`None <python:None>`
736+
"""
737+
return self._height
738+
739+
@height.setter
740+
def height(self, value):
741+
self._height = validators.numeric(value, allow_empty = True)
742+
743+
@property
744+
def symbol_fill(self) -> Optional[str]:
745+
"""The fill color of the symbol within the buttons. Defaults to ``'#666666'``.
746+
747+
:rtype: :class:`str <python:str>` or :obj:`None <python:None>`
748+
"""
749+
return self._symbol_fill
750+
751+
@symbol_fill.setter
752+
def symbol_fill(self, value):
753+
self._symbol_fill = validators.string(value, allow_empty = True)
754+
755+
@property
756+
def symbol_size(self) -> Optional[int | float | Decimal]:
757+
"""The pixel size of the symbol on the buttons. Defaults to ``14``.
758+
759+
:rtype: numeric or :obj:`None <python:None>`
760+
"""
761+
return self._symbol_size
762+
763+
@symbol_size.setter
764+
def symbol_size(self, value):
765+
self._symbol_size = validators.numeric(value, allow_empty = True)
766+
767+
@property
768+
def symbol_stroke(self) -> Optional[str]:
769+
"""The stroke color of the symbol's line within the buttons. Defaults to
770+
``'#666666'``.
771+
772+
:rtype: :class:`str <python:str>` or :obj:`None <python:None>`
773+
"""
774+
return self._symbol_stroke
775+
776+
@symbol_stroke.setter
777+
def symbol_stroke(self, value):
778+
self._symbol_stroke = validators.string(value, allow_empty = True)
779+
780+
@property
781+
def symbol_stroke_width(self) -> Optional[int | float | Decimal]:
782+
"""The stroke width of the symbol on the buttons, expressed in pixels. Defaults
783+
to ``1``.
784+
785+
:rtype: numeric or :obj:`None <python:None>`
786+
"""
787+
return self._symbol_stroke_width
788+
789+
@symbol_stroke_width.setter
790+
def symbol_stroke_width(self, value):
791+
self._symbol_stroke_width = validators.numeric(value, allow_empty = True)
792+
793+
@property
794+
def symbol_x(self) -> Optional[int | float | Decimal]:
795+
"""The x position of the center of the symbol inside the button. Defaults to
796+
``14.5``.
797+
798+
:rtype: numeric or :obj:`None <python:None>`
799+
"""
800+
return self._symbol_x
801+
802+
@symbol_x.setter
803+
def symbol_x(self, value):
804+
self._symbol_x = validators.numeric(value, allow_empty = True)
805+
806+
@property
807+
def symbol_y(self) -> Optional[int | float | Decimal]:
808+
"""The y position of the center of the symbol inside the button. Defaults to
809+
``13.5``.
810+
811+
:rtype: numeric or :obj:`None <python:None>`
812+
"""
813+
return self._symbol_y
814+
815+
@symbol_y.setter
816+
def symbol_y(self, value):
817+
self._symbol_y = validators.numeric(value, allow_empty = True)
818+
819+
@property
820+
def use_html(self) -> Optional[bool]:
821+
"""Whether to use HTML to render the buttons. Defaults to ``False``.
822+
823+
:rtype: :class:`bool <python:bool>` or :obj:`None <python:None>`
824+
"""
825+
return self._use_html
826+
827+
@use_html.setter
828+
def use_html(self, value):
829+
if value is None:
830+
self._use_html = None
831+
else:
832+
self._use_html = bool(value)
833+
834+
@property
835+
def vertical_align(self) -> Optional[str]:
836+
"""The vertical alignment of the buttons. Defaults to ``'top'``.
837+
838+
Accepts:
839+
840+
* ``'top'``
841+
* ``'middle'``
842+
* ``'bottom'``
843+
844+
:rtype: :class:`str <python:str>` or :obj:`None <python:None>`
845+
"""
846+
return self._vertical_align
847+
848+
@vertical_align.setter
849+
def vertical_align(self, value):
850+
if not value:
851+
self._vertical_align = None
852+
else:
853+
value = validators.string(value, allow_empty = False)
854+
value = value.lower()
855+
if value not in ['top', 'middle', 'bottom']:
856+
raise errors.HighchartsValueError(f'vertical_align must be either "top", '
857+
f'"middle", or "bottom". Was: {value}')
858+
859+
self._vertical_align = value
860+
861+
@property
862+
def width(self) -> Optional[int | float | Decimal]:
863+
"""The width of the button, in pixels. Defaults to ``28``.
864+
865+
:rtype: numeric or :obj:`None <python:None>`
866+
"""
867+
return self._width
868+
869+
@width.setter
870+
def width(self, value):
871+
self._width = validators.numeric(value, allow_empty = True)
872+
873+
@classmethod
874+
def _get_kwargs_from_dict(cls, as_dict):
875+
kwargs = {
876+
'enabled': as_dict.get('enabled', None),
877+
'text': as_dict.get('text', None),
878+
'theme': as_dict.get('theme', None),
879+
'y': as_dict.get('y', None),
880+
881+
'align': as_dict.get('align', None),
882+
'button_spacing': as_dict.get('buttonSpacing', None),
883+
'height': as_dict.get('height', None),
884+
'symbol_fill': as_dict.get('symbolFill', None),
885+
'symbol_size': as_dict.get('symbolSize', None),
886+
'symbol_stroke': as_dict.get('symbolStroke', None),
887+
'symbol_stroke_width': as_dict.get('symbolStrokeWidth', None),
888+
'symbol_x': as_dict.get('symbolX', None),
889+
'symbol_y': as_dict.get('symbolY', None),
890+
'use_html': as_dict.get('useHTML', None),
891+
'vertical_align': as_dict.get('verticalAlign', None),
892+
'width': as_dict.get('width', None),
893+
}
894+
895+
return kwargs
896+
897+
def _to_untrimmed_dict(self, in_cls = None) -> dict:
898+
untrimmed = {
899+
'align': self.align,
900+
'buttonSpacing': self.button_spacing,
901+
'height': self.height,
902+
'symbolFill': self.symbol_fill,
903+
'symbolSize': self.symbol_size,
904+
'symbolStroke': self.symbol_stroke,
905+
'symbolStrokeWidth': self.symbol_stroke_width,
906+
'symbolX': self.symbol_x,
907+
'symbolY': self.symbol_y,
908+
'useHTML': self.use_html,
909+
'verticalAlign': self.vertical_align,
910+
'width': self.width,
911+
}
912+
913+
parent_as_dict = super()._to_untrimmed_dict(in_cls = in_cls) or {}
914+
for key in parent_as_dict:
915+
untrimmed[key] = parent_as_dict[key]
916+
917+
return untrimmed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
align: 'left',
3+
buttonSpacing: 3,
4+
height: 28,
5+
symbolFill: '#ccc',
6+
symbolSize: 14,
7+
symbolStroke: '#333',
8+
symbolStrokeWidth: 1,
9+
symbolX: 12.5,
10+
symbolY: 10.5,
11+
useHTML: true,
12+
verticalAlign: 'top',
13+
width: 24,
14+
enabled: true,
15+
text: 'Test button',
16+
theme: {
17+
fill: '#fff',
18+
stroke: '#ccc'
19+
},
20+
y: 0
21+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
useHTML: true
3+
}

0 commit comments

Comments
 (0)