Source code for lightningchart.series.polar_point_line_series

from __future__ import annotations
from typing import Optional

from lightningchart.charts import Chart
from lightningchart import Themes
from lightningchart.series import (
    GetPolarData,
    Series,
    SeriesWith2DLines,
    SeriesWith2DPoints,
    SeriesWithAddEventListener,
    SeriesWithCursor,
    SolveNearestMixin,
)
from lightningchart.utils import convert_to_dict, convert_color_to_hex
from lightningchart.utils.utils import ColorInput, LegendOptions, build_series_legend_options


[docs] class PolarPointLineSeries(SeriesWith2DLines, SeriesWith2DPoints, SeriesWithAddEventListener, GetPolarData, SolveNearestMixin, SeriesWithCursor): def __init__( self, chart: Chart, theme: Themes = Themes.Light, name: str = None, automatic_color_index: int = None, legend: Optional[LegendOptions] = None, ): Series.__init__(self, chart) legend_options = build_series_legend_options(legend) payload = { 'chart': self.chart.id, 'theme': theme.value, 'name': name, 'automaticColorIndex': automatic_color_index, 'legend': legend_options if legend_options else None, } self.instance.send( self.id, 'addPointLineSeries', payload, )
[docs] def set_data(self, data: list[dict]): """Set the data for the series. Args: data (list[dict]): A list of dictionaries, each containing: - 'angle' (float): The angle in degrees. - 'amplitude' (float): The amplitude at that angle. - optional 'color' (Color): color property Example: >>> series.set_data([ ... {'angle': 0, 'amplitude': 5}, ... {'angle': 90, 'amplitude': 10}, ... {'angle': 180, 'amplitude': 7.5}, ... {'angle': 270, 'amplitude': 3}, ... ]) Returns: The instance of the class for fluent interface. """ data = convert_to_dict(data) data = [dict(d, color=convert_color_to_hex(d['color'])) if 'color' in d else d for d in data] self.instance.send(self.id, 'setDataPolarPoint', {'data': data}) return self
[docs] def enable_individual_point_colors(self): """Enable individual point coloring. Required for using 'color' properties in data points with set_data. Returns: The instance of the class for fluent interface. """ self.instance.send(self.id, 'setIndividualPointFillStyle', {}) return self
[docs] def set_stroke(self, thickness: int | float, color: ColorInput | None = None): """Set Stroke style of the series. Args: thickness (int | float): Thickness of the stroke. color (Color): Color of the stroke. Use 'transparent' or None to hide. Returns: The instance of the class for fluent interface. """ color = convert_color_to_hex(color) if color is not None else None self.instance.send( self.id, 'setStrokeStyle', {'thickness': thickness, 'color': color}, ) return self