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: boolWhen 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: boolWhether 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: f64The 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: f64The 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
impl GraphOptions
Sourcepub fn canvas_size(self, width: u16, height: u16) -> Self
pub fn canvas_size(self, width: u16, height: u16) -> Self
Set the canvas size. Returns an updated GraphOptions for chaining.
Sourcepub fn center(self, x: f64, y: f64) -> Self
pub fn center(self, x: f64, y: f64) -> Self
Set the center of the graph. Returns an updated GraphOptions for chaining.
Sourcepub fn scale(self, x: f64, y: f64) -> Self
pub fn scale(self, x: f64, y: f64) -> Self
Set the scale of the graph. Returns an updated GraphOptions for chaining.
Sourcepub fn square_scale(self, square_scale: bool) -> Self
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.
Sourcepub fn label_canvas_boundaries(self, label_canvas_boundaries: bool) -> Self
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.
Sourcepub fn major_grid_spacing(self, x: f64, y: f64) -> Self
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.
Sourcepub fn major_grid_divisions(self, x: u8, y: u8) -> Self
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.
Sourcepub fn major_grid_opacity(self, major_grid_opacity: f64) -> Self
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.
Sourcepub fn minor_grid_opacity(self, minor_grid_opacity: f64) -> Self
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
impl GraphOptions
Sourcepub fn to_canvas(&self, point: GraphPoint<f64>) -> CanvasPoint<f64>
pub fn to_canvas(&self, point: GraphPoint<f64>) -> CanvasPoint<f64>
Converts a point in graph space to canvas space.
Sourcepub fn to_graph(&self, point: CanvasPoint<f64>) -> GraphPoint<f64>
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
impl Clone for GraphOptions
Source§fn clone(&self) -> GraphOptions
fn clone(&self) -> GraphOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GraphOptions
impl Debug for GraphOptions
Source§impl Default for GraphOptions
The default options for a graph. Returns a GraphOptions with the following values:
impl Default for GraphOptions
The default options for a graph. Returns a GraphOptions with the following values:
canvas_size:(1000, 1000)center:(0.0, 0.0)scale:(10.0, 10.0)square_scale:falselabel_canvas_boundaries:falsemajor_grid_spacing:(2.0, 2.0)major_grid_divisions:(4, 4)
Source§fn default() -> GraphOptions
fn default() -> GraphOptions
impl Copy for GraphOptions
Auto Trait Implementations§
impl Freeze for GraphOptions
impl RefUnwindSafe for GraphOptions
impl Send for GraphOptions
impl Sync for GraphOptions
impl Unpin for GraphOptions
impl UnwindSafe for GraphOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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