Skip to main content

ChartLayout

Struct ChartLayout 

Source
pub struct ChartLayout {
    pub width: f64,
    pub height: f64,
    pub x_offset: f64,
    pub y_start: f64,
    pub y_interval: f64,
    pub min_y: f64,
    pub max_y: f64,
}
Expand description

Shared layout state for charts with numeric Y-axis and categorical X-axis.

Encapsulates the common chart setup pattern used by LineGraph.java and QualityBoxPlot.java: computing xOffset from Y-axis label widths, y_start from the Y interval, and the get_y() mapping function.

Fields§

§width: f64§height: f64§x_offset: f64§y_start: f64§y_interval: f64§min_y: f64§max_y: f64

Implementations§

Source§

impl ChartLayout

Source

pub fn new(min_y: f64, max_y: f64, y_interval: f64) -> Self

Create a chart layout by computing x_offset from Y-axis label widths.

Source

pub fn get_y(&self, value: f64) -> f64

getY() maps a data value to a pixel Y coordinate. Matches Java: (getHeight()-40) - (int)(((getHeight()-80)/(maxY-minY))*(y-minY)) The inner multiplication result is truncated to int before subtraction. // JAVA COMPAT

Source

pub fn base_width(&self, num_points: usize) -> f64

Calculate the width of each data column in the plot area. Uses floor() to match Java’s integer division truncation: int baseWidth = (getWidth()-(xOffset+10))/xLabels.length

Source

pub fn half_base_width(&self, num_points: usize) -> f64

Half of base_width, truncated to match Java’s baseWidth/2 int division. // JAVA COMPAT

Source

pub fn render_background(&self, svg: &mut String)

Render gray + white background rectangles matching Java’s JPanel default paint.

Source

pub fn render_y_labels(&self, svg: &mut String)

Render Y-axis labels at each tick interval.

Source

pub fn render_axes(&self, svg: &mut String)

Render the X and Y axis lines.

Source

pub fn render_x_axis_label(&self, svg: &mut String, label: &str)

Render the X-axis label centered below the axis.

Source

pub fn render_x_category_label_at( &self, svg: &mut String, label: &str, i: usize, base_width: f64, last_x_label_end: f64, ) -> f64

Render a single X-axis category label at position i, if it doesn’t overlap the previous label. Returns the updated last_x_label_end value.

Source

pub fn render_gridlines(&self, svg: &mut String)

Render horizontal gridlines at each Y-axis tick.

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V