@@ -108,6 +108,7 @@ def __init__(self, **kwargs):
108108 self ._align_ticks = None
109109 self ._allow_mutating_data = None
110110 self ._animation = None
111+ self ._axis_layout_runs = None
111112 self ._background_color = None
112113 self ._border_color = None
113114 self ._border_radius = None
@@ -155,6 +156,7 @@ def __init__(self, **kwargs):
155156 self .align_ticks = kwargs .get ('align_ticks' , None )
156157 self .allow_mutating_data = kwargs .get ('allow_mutating_data' , None )
157158 self .animation = kwargs .get ('animation' , None )
159+ self .axis_layout_runs = kwargs .get ('axis_layout_runs' , None )
158160 self .background_color = kwargs .get ('background_color' , None )
159161 self .border_color = kwargs .get ('border_color' , None )
160162 self .border_radius = kwargs .get ('border_radius' , None )
@@ -337,6 +339,38 @@ def animation(self, value):
337339 self ._animation = validate_types (value ,
338340 types = AnimationOptions )
339341
342+ @property
343+ def axis_layout_runs (self ) -> Optional [int ]:
344+ """The number of axis layout runs to execute when rendering the chart. Defaults to ``2``.
345+
346+ .. note::
347+
348+ When a chart with an x and a y-axis is rendered, we first pre-render the labels of both
349+ in order to measure them. Then, if either of the axis labels take up so much space that
350+ it significantly affects the length of the other axis, we repeat the process.
351+
352+ By default we stop at two axis layout runs, but it may be that the second run also alters
353+ the space required by either axis, for example if it causes the labels to rotate. In this
354+ situation, a subsequent redraw of the chart may cause the tick and label placement to
355+ change for apparently no reason.
356+
357+ Use the ``.axis_layout_runs`` property to set the maximum allowed number of repetitions.
358+
359+ .. warning::
360+
361+ Keep in mind that the default value of ``2`` is set because every run costs performance time.
362+ Changing this value option to higher than the default might decrease performance significantly,
363+ especially with bigger sets of data.
364+
365+ :returns: The maximum allowed number of axis layout runs.
366+ :rtype: :class:`int <python:int>`
367+ """
368+ return self ._axis_layout_runs
369+
370+ @axis_layout_runs .setter
371+ def axis_layout_runs (self , value ):
372+ self ._axis_layout_runs = validators .integer (value , allow_empty = True )
373+
340374 @property
341375 def background_color (self ) -> Optional [str | Gradient | Pattern ]:
342376 """The background color or gradient for the outer chart area. Defaults to
@@ -1349,6 +1383,7 @@ def _get_kwargs_from_dict(cls, as_dict):
13491383 'align_ticks' : as_dict .get ('alignTicks' , None ),
13501384 'allow_mutating_data' : as_dict .get ('allowMutatingData' , None ),
13511385 'animation' : as_dict .get ('animation' , None ),
1386+ 'axis_layout_runs' : as_dict .get ('axisLayoutRuns' , None ),
13521387 'background_color' : as_dict .get ('backgroundColor' , None ),
13531388 'border_color' : as_dict .get ('borderColor' , None ),
13541389 'border_radius' : as_dict .get ('borderRadius' , None ),
@@ -1403,6 +1438,7 @@ def _to_untrimmed_dict(self, in_cls = None) -> dict:
14031438 'alignTicks' : self .align_ticks ,
14041439 'allowMutatingData' : self .allow_mutating_data ,
14051440 'animation' : self .animation ,
1441+ 'axisLayoutRuns' : self .axis_layout_runs ,
14061442 'backgroundColor' : self .background_color ,
14071443 'borderColor' : self .border_color ,
14081444 'borderRadius' : self .border_radius ,
0 commit comments