Module chart

Provides a chart display.

This module returns a constructor function that should be called to create a new chart.

Info:

  • License: GPL v3
  • Author: Wesley Werner

Functions

clear () Clears all data points from the chart.
data (points, name) Add data points to the chart.
mousemoved (x, y, dx, dy, istouch) Process mouse movement to allow focus on data points.
update (dt) Process chart animations.
draw () Draw the chart.
drawGrid (chart, width, height) Callback to draw the grid.
drawLabels (chart, labels) Callback to draw the axiz label.s You must overwrite this function to draw your own.
drawBorder (chart, width, height) Callback to draw the border.
drawLine (chart, dataset, node1, node2) Callback to draw the lines.
drawNode (chart, dataset, node) Callback to draw the joins between lines.
drawFill (chart, dataset, triangles) Callback to fill the area under the lines.

Tables

pointdefinition A table of data points that represent the chart.
labeldefinition Defines label data for you to draw.
chartnode Defines a point in a line.


Functions

clear ()
Clears all data points from the chart.
data (points, name)
Add data points to the chart. Calling this multiple times adds new datasets to the chart.

Parameters:

mousemoved (x, y, dx, dy, istouch)
Process mouse movement to allow focus on data points.

Parameters:

  • x
  • y
  • dx
  • dy
  • istouch the focus radius around a node
update (dt)
Process chart animations.

Parameters:

  • dt number delta time as given by Love
draw ()
Draw the chart. This calls the chart drawing functions that you should overwrite.

See also:

drawGrid (chart, width, height)
Callback to draw the grid. You must overwrite this function to draw your own.

Parameters:

  • chart table The chart instance.
  • width number The width of the chart.
  • height number The height of the chart.
drawLabels (chart, labels)
Callback to draw the axiz label.s You must overwrite this function to draw your own.

Parameters:

drawBorder (chart, width, height)
Callback to draw the border. You must overwrite this function to draw your own.

Parameters:

  • chart table The chart instance.
  • width number The width of the chart.
  • height number The height of the chart.
drawLine (chart, dataset, node1, node2)
Callback to draw the lines. You must overwrite this function to draw your own.

Parameters:

  • chart table The chart instance.
  • dataset string The name of the dataset currently drawn.
  • node1 chartnode The first node in the line segment to draw.
  • node2 chartnode The second node in the line segment to draw.
drawNode (chart, dataset, node)
Callback to draw the joins between lines. You must overwrite this function to draw your own.

Parameters:

  • chart table The chart instance.
  • dataset string The name of the dataset currently drawn.
  • node chartnode The node on a join between line segments.
drawFill (chart, dataset, triangles)
Callback to fill the area under the lines. You must overwrite this function to draw your own.

Parameters:

  • chart table The chart instance.
  • dataset string The name of the dataset currently drawn.
  • triangles table The collection of points to fill. To avoid concave polygons, the chart points are triangulated into this set of points that must be iterated over.

Tables

pointdefinition
A table of data points that represent the chart.

Fields:

  • a number The value on the horizontal axiz.
  • b number The value on the vertical axiz.
labeldefinition
Defines label data for you to draw.

Fields:

  • text string The label text.
  • x number The x position of the label.
  • y number The y position of the label.
chartnode
Defines a point in a line.

Fields:

  • x number The x screen position of the point.
  • y number The y screen position of the point.
  • a number The horizontal axiz value of the point.
  • b number The vertical axiz value of the point.
  • focus bool If the point is under the mouse cursor.
generated by LDoc 1.4.6 Last updated 2018-01-03 16:24:23