Skip to main content

Chart

Struct Chart 

Source
pub struct Chart { /* private fields */ }
Expand description

Main chart instance that manages rendering and data

Implementations§

Source§

impl Chart

Source

pub async fn new(config: ChartConfig) -> Result<Self>

Create a new chart with the given configuration

Source

pub async fn new_financial(config: ChartConfig) -> Result<Self>

Create a basic financial chart with default layers

Source

pub fn set_data(&mut self, data: ChartData) -> Result<()>

Set chart data

Source

pub fn data(&self) -> Option<&ChartData>

Get current chart data

Source

pub fn add_layer(&mut self, layer: Box<dyn Layer>)

Add a layer to the chart

Source

pub fn remove_layer(&mut self, name: &str) -> Option<Box<dyn Layer>>

Remove a layer by name

Source

pub fn get_layer_mut(&mut self, name: &str) -> Option<&mut (dyn Layer + '_)>

Get a mutable reference to a layer

Source

pub fn set_layer_enabled(&mut self, name: &str, enabled: bool) -> bool

Enable or disable a layer

Source

pub fn viewport(&self) -> &Viewport

Get current viewport

Source

pub fn set_viewport_bounds(&mut self, bounds: ChartBounds)

Set viewport bounds

Source

pub fn pan(&mut self, delta_x: f32, delta_y: f32)

Pan the viewport by screen pixels

Source

pub fn zoom(&mut self, center_x: f32, center_y: f32, zoom_factor: f32)

Zoom the viewport around a center point

Source

pub fn fit_to_data(&mut self) -> Result<()>

Reset viewport to fit all data

Source

pub fn set_config(&mut self, config: ChartConfig)

Update chart configuration

Source

pub fn config(&self) -> &ChartConfig

Get current configuration

Source

pub fn set_theme(&mut self, theme: ChartTheme)

Set chart theme

Source

pub fn needs_render(&self) -> bool

Check if chart needs to be re-rendered

Source

pub async fn render(&mut self) -> Result<Vec<u8>>

Render the chart and return RGBA image data

Source

pub fn dimensions(&self) -> (u32, u32)

Get chart dimensions

Source

pub async fn resize(&mut self, width: u32, height: u32) -> Result<()>

Resize the chart

Source

pub fn screen_to_chart(&self, screen_x: f32, screen_y: f32) -> Vec2

Convert screen coordinates to chart coordinates

Source

pub fn chart_to_screen(&self, chart_x: f32, chart_y: f32) -> Vec2

Convert chart coordinates to screen coordinates

Source

pub fn hit_test( &self, screen_x: f32, screen_y: f32, ) -> Option<(usize, DateTime<Utc>, f64, f64, f64, f64, f64)>

Find data point at screen coordinates Returns: (index, timestamp, start, max, min, end, auxiliary)

Source

pub fn visible_time_range(&self) -> (i64, i64)

Get visible time range as timestamps

Source

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

Get visible price range

Auto Trait Implementations§

§

impl !Freeze for Chart

§

impl !RefUnwindSafe for Chart

§

impl Send for Chart

§

impl !Sync for Chart

§

impl Unpin for Chart

§

impl UnsafeUnpin for Chart

§

impl !UnwindSafe for Chart

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> Downcast<T> for T

Source§

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> Upcast<T> for T

Source§

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

Source§

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