Graph

Trait Graph 

Source
pub trait Graph {
    // Required method
    fn graph_data(&self) -> GraphData;

    // Provided method
    fn graph_config(&self) -> GraphConfig { ... }
}
Expand description

A trait that defines the functionality for creating, configuring, and rendering graphical representations of data, along with support for various output formats.

The Graph trait abstracts away details involved in preparing graph data, applying configurations, and rendering graphs in different formats such as PNG, SVG, PDF, or directly displaying them in an interactive terminal.

§Required Methods

  • graph_data: Returns the raw data structure (GraphData) required for plotting.

§Optional Methods

  • graph_config: Provides configuration overrides for the graph, including dimensions, labels, legends, and other visual properties. Defaults to GraphConfig::default().

§Core Render Methods

  • to_gnuplot: Converts the instance into a sequence of gnuplot commands based on its data and configuration.

§Export and Viewing Methods

  • write_png: Exports the graph as a PNG image to a specified file.
  • write_html: (For compatibility) Creates a self-contained HTML file with the image embedded.
  • write_svg: Exports the graph as an SVG file.
  • write_pdf: Exports the graph as a PDF file.
  • show: Displays the graph interactively.
  • render: A unified interface for rendering graphs in various formats.

§Advanced Features

  • to_interactive_html: (For compatibility) Creates an interactive HTML file with hover information and annotations.

Required Methods§

Source

fn graph_data(&self) -> GraphData

Return the raw data ready for plotting.

Provided Methods§

Source

fn graph_config(&self) -> GraphConfig

Optional per‑object configuration overrides.

Implementations on Foreign Types§

Source§

impl Graph for Vec<Curve>

Implementors§

Source§

impl Graph for Curve

Source§

impl Graph for Options

Source§

impl Graph for Position

Implementation of the Graph trait for the Position struct, enabling graphical representation of financial options positions.

This implementation provides methods to visualize the profit/loss (PnL) profile of an options position across different price levels of the underlying asset. It handles the generation of appropriate title, data values for plotting, and special chart elements like break-even points.

The visualization capabilities allow traders to analyze the potential outcomes of their options positions at expiration across various price scenarios.

Source§

impl Graph for BearCallSpread

Source§

impl Graph for BearPutSpread

Source§

impl Graph for BullCallSpread

Source§

impl Graph for BullPutSpread

Source§

impl Graph for CallButterfly

Source§

impl Graph for CustomStrategy

Source§

impl Graph for IronButterfly

Source§

impl Graph for IronCondor

Source§

impl Graph for LongButterflySpread

Source§

impl Graph for LongCall

Source§

impl Graph for LongPut

Source§

impl Graph for LongStraddle

Source§

impl Graph for LongStrangle

Source§

impl Graph for PoorMansCoveredCall

Source§

impl Graph for ShortButterflySpread

Source§

impl Graph for ShortCall

Source§

impl Graph for ShortPut

Source§

impl Graph for ShortStraddle

Source§

impl Graph for ShortStrangle

Source§

impl Graph for Surface

Source§

impl<T: Plottable + Graph> Graph for PlotBuilder<T>

Source§

impl<X, Y> Graph for RandomWalk<X, Y>

Source§

impl<X, Y> Graph for Simulator<X, Y>