GraphOptions

Struct GraphOptions 

Source
pub struct GraphOptions {
    pub canvas_size: CanvasPoint<u16>,
    pub center: GraphPoint<f64>,
    pub scale: GraphPoint<f64>,
    pub square_scale: bool,
    pub label_canvas_boundaries: bool,
    pub major_grid_spacing: GraphPoint<f64>,
    pub major_grid_divisions: (u8, u8),
    pub major_grid_opacity: f64,
    pub minor_grid_opacity: f64,
}
Expand description

Options to use when drawing a graph.

Fields§

§canvas_size: CanvasPoint<u16>

The width and height of the canvas, in pixels.

The default value is (1000, 1000).

§center: GraphPoint<f64>

The (x, y) point at which to center the graph.

For example, to place the origin at the center of the output image, set this to (0.0, 0.0).

This field will automatically be computed when calling Graph::center_on_points.

The default value is (0.0, 0.0).

§scale: GraphPoint<f64>

The (x, y) scale of the graph.

The scale indicates the distance, in graph units, from the center of the canvas to the edge of the canvas. For example, when the graph is centered at (0.0, 0.0) with a scale of (10.0, 10.0), the visible graph will be from (x, y): (-10.0, -10.0) to (x, y): (10.0, 10.0).

This field will automatically be computed when calling Graph::center_on_points.

The default value is (10.0, 10.0).

§square_scale: bool

When calling Graph::center_on_points, determines whether to scale the x- and y-axes together (resulting in a square graph) or independently (resulting in a rectangular graph).

The default value is false.

§label_canvas_boundaries: bool

Whether to label the canvas boundaries with their corresponding graph values.

The default value is false.

§major_grid_spacing: GraphPoint<f64>

The number of graph units between each major grid line, given as a pair of (x, y) units.

For example, to have a major grid line every 3.0 units on the x-axis and every 2.0 units on the y-axis, set this to (3.0, 2.0).

This field will automatically be computed when calling Graph::center_on_points.

The default value is (2.0, 2.0).

§major_grid_divisions: (u8, u8)

The number of spaces to divide each major grid line into, given as a pair of (x, y) units. The number of minor grid lines between each major grid line will then be x - 1 on the x-axis, and y - 1 on the y-axis.

For example, to divide each major grid line into 5 spaces on the x-axis (4 minor grid lines) and 4 spaces on the y-axis (3 minor grid lines), set this to (5, 4).

This field will automatically be computed when calling Graph::center_on_points.

The default value is (4, 4).

§major_grid_opacity: f64

The opacity of the major grid lines, given as a value in the range 0.0 to 1.0, where 0.0 is fully transparent and 1.0 is fully opaque. This also affects the opacity of the major grid line numbers.

The default value is 0.8.

§minor_grid_opacity: f64

The opacity of the minor grid lines, given as a value in the range 0.0 to 1.0, where 0.0 is fully transparent and 1.0 is fully opaque.

The default value is 0.5.

Implementations§

Source§

impl GraphOptions

Source

pub fn canvas_size(self, width: u16, height: u16) -> Self

Set the canvas size. Returns an updated GraphOptions for chaining.

Source

pub fn center(self, x: f64, y: f64) -> Self

Set the center of the graph. Returns an updated GraphOptions for chaining.

Source

pub fn scale(self, x: f64, y: f64) -> Self

Set the scale of the graph. Returns an updated GraphOptions for chaining.

Source

pub fn square_scale(self, square_scale: bool) -> Self

Set whether to scale the x- and y-axes together. Returns an updated GraphOptions for chaining.

Source

pub fn label_canvas_boundaries(self, label_canvas_boundaries: bool) -> Self

Set whether to label the canvas boundaries with their corresponding graph values. Returns an updated GraphOptions for chaining.

Source

pub fn major_grid_spacing(self, x: f64, y: f64) -> Self

Set the number of graph units between each major grid line. Returns an updated GraphOptions for chaining.

Source

pub fn major_grid_divisions(self, x: u8, y: u8) -> Self

Set the number of spaces to divide each major grid line into. Returns an updated GraphOptions for chaining.

Source

pub fn major_grid_opacity(self, major_grid_opacity: f64) -> Self

Set the opacity of the major grid lines. Returns an updated GraphOptions for chaining.

Source

pub fn minor_grid_opacity(self, minor_grid_opacity: f64) -> Self

Set the opacity of the minor grid lines. Returns an updated GraphOptions for chaining.

Source§

impl GraphOptions

Source

pub fn to_canvas(&self, point: GraphPoint<f64>) -> CanvasPoint<f64>

Converts a point in graph space to canvas space.

Source

pub fn to_graph(&self, point: CanvasPoint<f64>) -> GraphPoint<f64>

Converts a point in canvas space to graph space.

Trait Implementations§

Source§

impl Clone for GraphOptions

Source§

fn clone(&self) -> GraphOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for GraphOptions

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for GraphOptions

The default options for a graph. Returns a GraphOptions with the following values:

Source§

fn default() -> GraphOptions

Returns the “default value” for a type. Read more
Source§

impl Copy for GraphOptions

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

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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> 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> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
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> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.