Class Graph

Graph drawing module.

Flexible graph drawing for waves, points, bars, etc.

Info:

  • Release: v1.1.0
  • Author: Mark Eats

Methods

Graph:new (x_min, x_max, x_warp, y_min, y_max, y_warp, style, show_x_axis, show_y_axis) Create a new Graph object.
Graph:set_position_and_size (x, y, w, h) Set graph's position and size.
Graph:get_x () Get graph's x position.
Graph:set_x (x) Set graph's x position.
Graph:get_y () Get graph's y position.
Graph:set_y (y) Set graph's y position.
Graph:get_width () Get graph's width.
Graph:set_width (w) Set graph's width.
Graph:get_height () Get graph's height.
Graph:set_height (h) Set graph's height.
Graph:get_x_min () Get minimum value of x axis.
Graph:set_x_min (x_min) Set minimum value of x axis.
Graph:get_x_max () Get maximum value of x axis.
Graph:set_x_max (x_max) Set maximum value of x axis.
Graph:get_x_warp () Get x warp.
Graph:set_x_warp (warp) Set x warp.
Graph:get_y_min () Get minimum value of y axis.
Graph:set_y_min (y_min) Set minimum value of y axis.
Graph:get_y_max () Get maximum value of y axis.
Graph:set_y_max (y_max) Set maximum value of y axis.
Graph:get_y_warp () Get y warp.
Graph:set_y_warp (warp) Set y warp.
Graph:get_style () Get style.
Graph:set_style (style) Set style.
Graph:get_show_x_axis () Get show x axis.
Graph:set_show_x_axis (bool) Set show x axis.
Graph:get_show_y_axis () Get show y axis.
Graph:set_show_y_axis (bool) Set show y axis.
Graph:get_active () Get active.
Graph:set_active (bool) Set active.
Graph:get_point (index) Get point at index.
Graph:add_point (px, py[, curve[, highlight[, index]]]) Add a point to the graph.
Graph:edit_point (index[, px[, py[, curve[, highlight]]]]) Edit point at index.
Graph:remove_point (index) Remove point at index.
Graph:remove_all_points () Remove all points.
Graph:highlight_point (index) Highlight point at index.
Graph:highlight_exclusive_point (index) Highlight point at index exclusively.
Graph:clear_highlight (index) Clear highlight from point at index.
Graph:clear_all_highlights () Clear highlights from all points.
Graph:get_function (index) Get function at index.
Graph:add_function (func[, sample_quality[, index]]) Add a new y function to the graph.
Graph:edit_function (index, func[, sample_quality]) Edit function at index.
Graph:update_functions () Update all functions.
Graph:remove_function (index) Remove function at index.
Graph:remove_all_functions () Remove all functions.
Graph:redraw () Redraw the graph.


Methods

Graph:new (x_min, x_max, x_warp, y_min, y_max, y_warp, style, show_x_axis, show_y_axis)
Create a new Graph object. All arguments optional.

Parameters:

  • x_min number Minimum value for x axis, defaults to 0.
  • x_max number Maximum value for x axis, defaults to 1.
  • x_warp string defines warping for x axis, accepts "lin" or "exp", defaults to "lin".
  • y_min number Minimum value for y axis, defaults to 0.
  • y_max number Maximum value for y axis, defaults to 1.
  • y_warp string defines warping for y axis, accepts "lin" or "exp", defaults to "lin".
  • style string defines visual style, accepts "line", "point", "spline", "line_and_point", "spline_and_point" or "bar", defaults to "line".
  • show_x_axis boolean Display the x axis if set to true, defaults to false.
  • show_y_axis boolean Display the y axis if set to true, defaults to false.

Returns:

    Graph Instance of Graph.
Graph:set_position_and_size (x, y, w, h)
Set graph's position and size. All arguments optional.

Parameters:

  • x number x position in pixels.
  • y number y position in pixels.
  • w number Width in pixels.
  • h number Height in pixels.
Graph:get_x ()
Get graph's x position.

Returns:

    number y position.
Graph:set_x (x)
Set graph's x position.

Parameters:

  • x number x position in pixels.
Graph:get_y ()
Get graph's y position.

Returns:

    number y position.
Graph:set_y (y)
Set graph's y position.

Parameters:

  • y number y position in pixels.
Graph:get_width ()
Get graph's width.

Returns:

    number Width.
Graph:set_width (w)
Set graph's width.

Parameters:

  • w number Width in pixels.
Graph:get_height ()
Get graph's height.

Returns:

    number Height.
Graph:set_height (h)
Set graph's height.

Parameters:

  • h number Height in pixels.
Graph:get_x_min ()
Get minimum value of x axis.

Returns:

    number Minimum value of x axis.
Graph:set_x_min (x_min)
Set minimum value of x axis.

Parameters:

  • x_min number Minimum value of x axis.
Graph:get_x_max ()
Get maximum value of x axis.

Returns:

    number Maximum value of x axis.
Graph:set_x_max (x_max)
Set maximum value of x axis.

Parameters:

  • x_max number Maximum value of x axis.
Graph:get_x_warp ()
Get x warp.

Returns:

    string x warp string.
Graph:set_x_warp (warp)
Set x warp.

Parameters:

  • warp string Warp string, accepts "lin" or "exp".
Graph:get_y_min ()
Get minimum value of y axis.

Returns:

    number Minimum value of y axis.
Graph:set_y_min (y_min)
Set minimum value of y axis.

Parameters:

  • y_min number Minimum value of y axis.
Graph:get_y_max ()
Get maximum value of y axis.

Returns:

    number Maximum value of y axis.
Graph:set_y_max (y_max)
Set maximum value of y axis.

Parameters:

  • y_max number Maximum value of y axis.
Graph:get_y_warp ()
Get y warp.

Returns:

    string y warp string.
Graph:set_y_warp (warp)
Set y warp.

Parameters:

  • warp string Warp string, accepts "lin" or "exp".
Graph:get_style ()
Get style.

Returns:

    string Style string.
Graph:set_style (style)
Set style.

Parameters:

  • style string Style string, accepts "line", "point", "spline", "line_and_point", "spline_and_point" or "bar".
Graph:get_show_x_axis ()
Get show x axis.

Returns:

    boolean Show x axis boolean.
Graph:set_show_x_axis (bool)
Set show x axis.

Parameters:

  • bool boolean display the x axis if set to true.
Graph:get_show_y_axis ()
Get show y axis.

Returns:

    Show y axis boolean.
Graph:set_show_y_axis (bool)
Set show y axis.

Parameters:

  • bool boolean display the y axis if set to true.
Graph:get_active ()
Get active.

Returns:

    boolean Active boolean.
Graph:set_active (bool)
Set active.

Parameters:

  • bool boolean darkens the graph appearance when set to false.
Graph:get_point (index)
Get point at index.

Parameters:

  • index Index of point.

Returns:

    table Point table.
Graph:add_point (px, py[, curve[, highlight[, index]]])
Add a point to the graph.

Parameters:

  • px number Point's x position.
  • py number Point's y position.
  • curve string or number Curve of previous line segment, accepts "lin", "exp" or a number where 0 is linear and positive and negative numbers curve the envelope up and down, defaults to "lin". (optional)
  • highlight boolean Highlights the point if set to true, defaults to false. (optional)
  • index number Index to add point at, defaults to the end of the list. (optional)
Graph:edit_point (index[, px[, py[, curve[, highlight]]]])
Edit point at index.

Parameters:

  • index number Index of point to edit.
  • px number Point's x position. (optional)
  • py number Point's y position. (optional)
  • curve string or number Curve of previous line segment, accepts "lin", "exp" or a number where 0 is linear and positive and negative numbers curve the envelope up and down. (optional)
  • highlight boolean Highlights the point if set to true. (optional)
Graph:remove_point (index)
Remove point at index. Following indexes will change after removing a point.

Parameters:

  • index Index of point to remove.
Graph:remove_all_points ()
Remove all points.
Graph:highlight_point (index)
Highlight point at index.

Parameters:

  • index Index of point to highlight.
Graph:highlight_exclusive_point (index)
Highlight point at index exclusively. Other points will have highlight set to false.

Parameters:

  • index Index of point to highlight.
Graph:clear_highlight (index)
Clear highlight from point at index.

Parameters:

  • index Index of point to clear highlight from.
Graph:clear_all_highlights ()
Clear highlights from all points.
Graph:get_function (index)
Get function at index.

Parameters:

  • index Index of function.

Returns:

    function Function.
Graph:add_function (func[, sample_quality[, index]])
Add a new y function to the graph. Add a function that will be used to generate a line.

Parameters:

  • func function A function that should return the value of y for any given value of x. For example, 'function(x) return math.sin(x) end'
  • sample_quality number Quality to sample the graph function at. Values less than 1 will sample less than once per pixel, values higher than 1 can help reduce jitter of graphs with high frequency changes at the cost of performance. Recommended range 0.25 to 4, defaults to 1. (optional)
  • index Index to add function at, defaults to the end of the list. (optional)
Graph:edit_function (index, func[, sample_quality])
Edit function at index.

Parameters:

  • index Index of function to edit.
  • func function A function that should return the value of y for any given value of x.
  • sample_quality number Quality to sample the graph function at, defaults to 1. (optional)
Graph:update_functions ()
Update all functions. Call when a function's output has changed to redraw its line.
Graph:remove_function (index)
Remove function at index. Following indexes will change after removing a function.

Parameters:

  • index Index of function to remove.
Graph:remove_all_functions ()
Remove all functions.
Graph:redraw ()
Redraw the graph. Call whenever graph data or settings have been changed.
generated by LDoc 1.4.6 Last updated 2020-03-28 23:45:19