Module lib.Graph

Graph drawing module.

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

Info:

  • Release: v1.1.0
  • Author: Mark Eats

Functions

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


Functions

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.
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.
get_x ()
Get graph's x position.

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

    string Style string.
set_style (style)
Set style.

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

    boolean Active boolean.
set_active (bool)
Set active.

Parameters:

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

Parameters:

  • index Index of point.

Returns:

    table Point table.
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)
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)
remove_point (index)
Remove point at index. Following indexes will change after removing a point.

Parameters:

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

Parameters:

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

Parameters:

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

Parameters:

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

Parameters:

  • index Index of function.

Returns:

    function Function.
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)
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)
update_functions ()
Update all functions. Call when a function's output has changed to redraw its line.
remove_function (index)
Remove function at index. Following indexes will change after removing a function.

Parameters:

  • index Index of function to remove.
remove_all_functions ()
Remove all functions.
redraw ()
Redraw the graph. Call whenever graph data or settings have been changed.
generated by LDoc 1.4.6 Last updated 2021-01-11 12:10:11