from __future__ import annotations
from lightningchart.ui.polar_axis import PolarAxis
[docs]
class PolarAxisRadial(PolarAxis):
"""Class representing the radial axis in a polar chart."""
def __init__(self, chart):
super().__init__(chart)
self.sections_count = None
self.instance.send(self.id, 'addPolarAxisRadial', {'chart': self.chart.id})
[docs]
def set_division(self, sections_count: int):
"""Set how many sections the radial axis is divided into by Ticks.
Args:
sections_count: Number of sections.
Returns:
The instance of the class for fluent interface.
"""
self.instance.send(self.id, 'setDivision', {'sectionsCount': sections_count})
self.sections_count = sections_count
return self
[docs]
def get_division(self) -> int | None:
"""Get how many sections the radial axis is divided into by Ticks.
Returns:
Number of sections, or None if not yet set.
"""
return self.sections_count
[docs]
def set_clockwise(self, clockwise: bool):
"""Set whether PolarAxisRadial direction is clockwise or counterclockwise.
Args:
clockwise: True for clockwise direction, False for counterclockwise.
Returns:
The instance of the class for fluent interface.
"""
self.instance.send(self.id, 'setClockwise', {'clockwise': clockwise})
return self
[docs]
def set_north(self, angle: int):
"""Set rotation of radial axis by specifying degree angle that is depicted at North position (horizontally centered, vertically highest).
Args:
angle: Angle as degrees that will be depicted at North position. Defaults to 90.
Returns:
The instance of the class for fluent interface.
"""
self.instance.send(self.id, 'setNorth', {'angle': angle})
return self
[docs]
def set_tick_labels(self, labels: list[str]):
"""Replace all default tick labels within the radial axis with a list of custom labels.
Args:
labels: A list of strings to display on the ticks. Must match the number of axis divisions.
Returns:
The instance of the class for fluent interface.
"""
self.instance.send(self.id, 'setTickFormattingFunction', {'labels': labels})
return self
[docs]
def style_tick_labels(
self,
size: int | float,
family: str = 'Segoe UI, -apple-system, Verdana, Helvetica',
style: str = 'normal',
weight: str = 'normal',
rotation: float | None = None,
tick_padding: int | float | None = None,
label_padding: int | float | None = None,
):
"""
Style the **radial axis tick labels** (font, rotation, and paddings).
Args:
size:
Font size in CSS pixels (e.g., ``12`` or ``14``).
family:
CSS font-family for labels (comma-separated fallback list).
style:
CSS font-style (e.g., ``'normal'``, ``'italic'``).
weight:
CSS font-weight (e.g., ``'normal'``, ``'600'``, ``'bold'``).
rotation:
Optional label rotation in **degrees**. If given, rotates the tick label text.
tick_padding:
Optional pixels between the **tick line** and the label.
label_padding:
Optional pixels **after** the label (right/below depending on layout).
Returns:
self: The axis instance for fluent chaining.
Examples:
>>> radial = chart.get_radial_axis()
>>> radial.style_tick_labels(size=11, weight='600', rotation=0, label_padding=2)
"""
payload = {'family': family, 'size': size, 'weight': weight, 'style': style}
if rotation is not None:
payload['rotation'] = rotation
if tick_padding is not None:
payload['tick_padding'] = tick_padding
if label_padding is not None:
payload['label_padding'] = label_padding
self.instance.send(self.id, 'styleRadialTickLabels', payload)
return self
[docs]
def set_margin_after_ticks(self, pixels: int | float):
"""Set gap (px) after tick labels toward the plot."""
self.instance.send(self.id, 'setAxisMarginAfterTicks', {'margin': pixels})
return self