Skip to main content

PolarArtist

Struct PolarArtist 

Source
pub struct PolarArtist {
    pub theta: Vec<f64>,
    pub r: Vec<f64>,
    pub color: Color,
    pub label: Option<String>,
    pub alpha: f64,
    pub linewidth: f64,
    pub filled: bool,
    pub marker: Option<Marker>,
}
Expand description

A polar line or filled radar chart in polar coordinates.

Each data point is defined by an angle theta (in radians) and a radial distance r. In line mode, a polyline connects the data points. In filled mode, the path is closed and the interior is filled, producing a radar or area chart.

The rendering pipeline converts polar coordinates to Cartesian pixel coordinates using x = cx + r*cos(theta), y = cy - r*sin(theta), draws concentric circles for the r-grid, and radial lines for the theta-grid.

Fields§

§theta: Vec<f64>

Angles in radians, measured counter-clockwise from the positive x-axis.

§r: Vec<f64>

Radial distances from the origin. Must have the same length as theta.

§color: Color

Stroke/fill color.

§label: Option<String>

Optional legend label.

§alpha: f64

Opacity from 0.0 (fully transparent) to 1.0 (fully opaque).

§linewidth: f64

Stroke width in pixels for the polar line.

§filled: bool

When true, the polar path is closed and filled (radar/area chart).

§marker: Option<Marker>

Optional marker shape drawn at each data point.

Implementations§

Source§

impl PolarArtist

Source

pub fn color(&mut self, color: Color) -> &mut Self

Sets the line/fill color.

Accepts any Color value.

Source

pub fn label(&mut self, label: &str) -> &mut Self

Sets the legend label for this polar series.

When a label is set, this series will appear in the legend if one is displayed on the axes.

Source

pub fn alpha(&mut self, alpha: f64) -> &mut Self

Sets the opacity (0.0 = fully transparent, 1.0 = fully opaque).

The value is clamped to the [0.0, 1.0] range.

Source

pub fn linewidth(&mut self, width: f64) -> &mut Self

Sets the stroke width in pixels for the polar line.

A width of 1.5 is the default. Values below 1.0 may produce sub-pixel rendering depending on the backend.

Source

pub fn filled(&mut self, filled: bool) -> &mut Self

Controls whether the polar path is closed and filled.

When true, the path is closed (connecting the last point back to the first) and the interior is filled with the configured color and alpha. When false (default for polar_plot), only the line is drawn.

Source

pub fn marker(&mut self, marker: Marker) -> &mut Self

Sets the marker shape drawn at each data point.

By default, no markers are drawn (None). Set to Some(Marker::Circle) or another variant to show markers at each vertex.

Source

pub fn data_bounds(&self) -> (f64, f64, f64, f64)

Computes the data-space bounding box (xmin, xmax, ymin, ymax) in Cartesian coordinates derived from the polar data.

The polar data is converted to Cartesian coordinates (x = rcos(theta), y = rsin(theta)) and the bounding box of those points is returned. Falls back to (-1.0, 1.0, -1.0, 1.0) when no finite data exists.

Source

pub fn max_finite_r(&self) -> f64

Returns the maximum finite, positive radial value.

Returns 0.0 if no finite positive values exist.

Source

pub fn polar_to_cartesian(r: f64, theta: f64) -> (f64, f64)

Converts polar coordinates (r, theta) to Cartesian coordinates (x, y).

The angle theta is in radians, measured counter-clockwise from the positive x-axis (3 o’clock position).

Source

pub fn cartesian_points(&self) -> Vec<(f64, f64)>

Returns an iterator of (x, y) Cartesian points derived from the polar data.

Non-finite r or theta values are filtered out.

Trait Implementations§

Source§

impl Clone for PolarArtist

Source§

fn clone(&self) -> PolarArtist

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PolarArtist

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.