RobustChart

Namespace: SnowBank.Numerics · class

Generates ASCII Art that look like plots

Methods

DrawData

static void DrawData(FrameBuffer frame, Data xs, Func<double, double> xAxis, Func<double, double> yAxis, int x0 = 0, int y0 = 0, char c = '*', char nc = 'x')

Draws a series of data onto a frame

  • frame — Frame where to draw
  • xs — Series of data
  • xAxis — Scaler for the X axis
  • yAxis — Scaler for the Y axis
  • x0 — X coordinate of the origin
  • y0 — Y coordinate of the origin
  • c — "Color" for the points
  • nc — "Color" for the missing values

static void DrawData(FrameBuffer frame, Data xs, Data ys, Func<double, double> xAxis, Func<double, double> yAxis, int x0 = 0, int y0 = 0, char c = '*', char nc = 'x')

Draws an X/Y plot onto a frame

  • frame — Frame where to draw
  • xs — Series of data for the X coordinates
  • ys — Series of data for the Y coordinates
  • xAxis — Scaler for the X axis
  • yAxis — Scaler for the Y axis
  • x0 — X coordinate of the origin
  • y0 — Y coordinate of the origin
  • c — "Color" for the points
  • nc — "Color" for the missing values

Render

static string Render(Data ys, int width, int height, double? min = null, double? max = null, int digits = 0, char c = '#')

Renders a Plot

  • ys — Values for the Y coordinates of the points
  • width — Width (in characters) of the plot. Final width will be larger to accomodate for the axis and labels
  • height — Height (in characters) of the plot. Final eight will be larger to accomodate for the axis and labels
  • min — Minimum value on the Y axis (automatically computed if null)
  • max — Maximum value on the Y axis (automatically computed if null)
  • digits — Number of digits used for rounding. If positive, number of decimal digits (ex: 2 for 1.2345=>'1.23'). If positive, number of significant digits (ex: -3 for 123456=>'123000').
  • c — Character used for drawing the points of the series

Returns: Multi-line string that contains the rendered plot

static string Render(Data[] series, int width, int height, double? min = null, double? max = null, int digits = 0, string chars = null)

Renders a Plot

  • series — List of series to plot
  • width — Width (in characters) of the plot. Final width will be larger to accomodate for the axis and labels
  • height — Height (in characters) of the plot. Final eight will be larger to accomodate for the axis and labels
  • min — Minimum value on the Y axis (automatically computed if null)
  • max — Maximum value on the Y axis (automatically computed if null)
  • digits — Number of digits used for rounding. If positive, number of decimal digits (ex: 2 for 1.2345=>'1.23'). If positive, number of significant digits (ex: -3 for 123456=>'123000').
  • chars — String with all the characters used for drawing the points of each series. chars[0] is used to draw series[0], and so on. Modulo is used if there is more series than "colors"

Returns: Multi-line string that contains the rendered plot

RenderFrame

static FrameBuffer RenderFrame(Data ys, int width, int height, double? min = null, double? max = null, int digits = 0, char c = '#')

Renders a Plot

  • ys — Values for the Y coordinates of the points
  • width — Width (in characters) of the plot. Final width will be larger to accomodate for the axis and labels
  • height — Height (in characters) of the plot. Final eight will be larger to accomodate for the axis and labels
  • min — Minimum value on the Y axis (automatically computed if null)
  • max — Maximum value on the Y axis (automatically computed if null)
  • digits — Number of digits used for rounding. If positive, number of decimal digits (ex: 2 for 1.2345=>'1.23'). If positive, number of significant digits (ex: -3 for 123456=>'123000').
  • c — Character used for drawing the points of the series

Returns: Multi-line string that contains the rendered plot

static FrameBuffer RenderFrame(Data[] series, int width, int height, double? min = null, double? max = null, int digits = 0, string chars = null)

Renders a Plot

  • series — List of series to plot
  • width — Width (in characters) of the plot. Final width will be larger to accomodate for the axis and labels
  • height — Height (in characters) of the plot. Final eight will be larger to accomodate for the axis and labels
  • min — Minimum value on the Y axis (automatically computed if null)
  • max — Maximum value on the Y axis (automatically computed if null)
  • digits — Number of digits used for rounding. If positive, number of decimal digits (ex: 2 for 1.2345=>'1.23'). If positive, number of significant digits (ex: -3 for 123456=>'123000').
  • chars — String with all the characters used for drawing the points of each series. chars[0] is used to draw series[0], and so on. Modulo is used if there is more series than "colors"

Returns: Multi-line string that contains the rendered plot

static FrameBuffer RenderFrame(Data xs, Data ys, int width, int height, double? xMin = null, double? xMax = null, double? yMin = null, double? yMax = null, int digits = 0, char c = '#')

Renders a XY Plot

  • xs — Series for the X coordinates
  • ys — Series for the Y coordinates
  • width — Width (in characters) of the plot. Final width will be larger to accomodate for the axis and labels
  • height — Height (in characters) of the plot. Final eight will be larger to accomodate for the axis and labels
  • xMin — Minimum value of the X axis (automatically computed if null)
  • xMax — Maximum value of the X axis (automatically computed if null)
  • yMin — Minimum value of the Y axis (automatically computed if null)
  • yMax — Maximum value of the Y axis (automatically computed if null)
  • digits — Number of digits used for rounding. If positive, number of decimal digits (ex: 2 for 1.2345=>'1.23'). If positive, number of significant digits (ex: -3 for 123456=>'123000').
  • c — Character used for drawing the points of the series

Returns: Rendered frame

SigCeiling

static double SigCeiling(double x, int digits)

Rounds a value up to the specified number of digits

  • x — Value to round down
  • digits — If positive, number of decimal digits. If negative, number of significant digits

Returns: Rounded value

  • SigCeiling(PI, 2) => 3.15 - SigCeiling(123456789, -3) => 123,457,000

SigFloor

static double SigFloor(double x, int digits)

Rounds a value down to the specified number of digits

  • x — Value to round down
  • digits — If positive, number of decimal digits. If negative, number of significant digits

Returns: Rounded value

  • SigFloor(PI, 2) => 3.14 - SigFloor(123456789, 3) => 123,456,000

SigFormat

static string SigFormat(double x, int digits)

Formats a value

  • x — Value to format

  • digits — If positive, number of decimal digits. If negative, number of significant digits

  • SigFormat(PI, 2) => "3.15" - SigFormat(123456789, -3) => "123,456,000"