ChartData

Struct ChartData 

Source
pub struct ChartData {
    pub vertices: Vec<Vertex>,
    pub viewport_width: f32,
    pub viewport_height: f32,
}
Expand description

Chart data container

Fields§

§vertices: Vec<Vertex>§viewport_width: f32§viewport_height: f32

Implementations§

Source§

impl ChartData

Source

pub fn new(width: f32, height: f32) -> Self

Source

pub fn add_point(&mut self, point: Point2D, color: Color, size: f32)

Add a point to the chart

§Parameters
  • point - The 2D coordinates (x, y) of the point to add
  • color - The RGBA color for this point (values 0.0-1.0)
  • size - The size/radius of the point in pixels
Source

pub fn from_scatter( x: &[f32], y: &[f32], color: Option<Color>, size: Option<f32>, width: f32, height: f32, ) -> Self

Create scatter plot data from raw arrays

Converts raw x and y coordinate arrays into normalized vertex data ready for GPU rendering. By default, normalizes coordinates to the [-1, 1] range required by GPU clip space.

§Parameters
  • x - Array of x-coordinates for each point
  • y - Array of y-coordinates for each point (must be same length as x)
  • color - Optional color for all points. If None, uses default blue color
  • size - Optional size for all points in pixels. If None, defaults to 2.0
  • width - Viewport width in pixels
  • height - Viewport height in pixels
§Returns

A new ChartData instance with normalized vertices ready for rendering

Source

pub fn from_scatter_with_range( x: &[f32], y: &[f32], color: Option<Color>, size: Option<f32>, width: f32, height: f32, x_range: Option<(f32, f32)>, y_range: Option<(f32, f32)>, ) -> Self

Create scatter plot data with custom normalization ranges

Converts raw x and y coordinate arrays into normalized vertex data with user-specified output ranges. This allows control over the coordinate mapping for custom viewports.

§Parameters
  • x - Array of x-coordinates for each point
  • y - Array of y-coordinates for each point (must be same length as x)
  • color - Optional color for all points. If None, uses default blue color
  • size - Optional size for all points in pixels. If None, defaults to 2.0
  • width - Viewport width in pixels
  • height - Viewport height in pixels
  • x_range - Optional custom output range for x (min, max). If None, uses [-1.0, 1.0]
  • y_range - Optional custom output range for y (min, max). If None, uses [-1.0, 1.0]
§Returns

A new ChartData instance with normalized vertices

§Example
use helion_core::data::ChartData;
 
let x_data = vec![1.0, 2.0, 3.0];
let y_data = vec![4.0, 5.0, 6.0];
 
// Map to [0, 1] range instead of [-1, 1]
let data = ChartData::from_scatter_with_range(
    &x_data, &y_data, None, None, 800.0, 600.0,
    Some((0.0, 1.0)),  // x maps to [0, 1]
    Some((0.0, 1.0)),  // y maps to [0, 1]
);

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

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, 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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,