Module plugin.dataviz

DataViz plugin Shapes and color manipulation with a view to dataviz and charting

Info:

  • Copyright: Kodaps 2018
  • Release: 1.0
  • Author: hockley, david

Color functions

addNamedColors (colorDict) set material palette
setPalette (name) set material palette
getPalettes () get material palette
color (...) color function

Shape functions

newCircleSegment (options) create a circle segment
newDot (options) create a dot
newArc (options) create an arc anchored in the center of the circle
newPie (options) create an pie slice anchored in the center of the circle
newRegularPolygon (options) create an n-sided regular polygon
newStar (options) create an n-pointed star


Color functions

Useful utilities for manipulating and getting colors
addNamedColors (colorDict)
set material palette

Parameters:

  • colorDict

Returns:

    boolean load success or failure

Usage:

    dataviz.addNamedColors({
     red = "#F00",
     green = "#0F0"
    })
    shape:setStrokeColor(dataviz.color("green"))
setPalette (name)
set material palette

Parameters:

  • name

Returns:

    boolean load success or failure

Usage:

    local result = dataviz.setPalette("blue")
getPalettes ()
get material palette

Returns:

    table a list of material palette names
color (...)
color function

Parameters:

  • ...

Returns:

    an unpacked set of floats

Usage:

    -- accepts a 3 (or 4) letter RGB(A) hex string starting with #
    shape:setFillColor(dataviz.color('#ABC'))
    -- accepts a 6 (or 8) letter RGB(A) hex string starting with #
    shape:setFillColor(dataviz.color('#aa99fc99'))
    -- accepts a material palette color id (as a string) once the palette is set
    dataviz.setPalette('green')
    shape:setFillColor(dataviz.color('a700'))

Shape functions

Useful utilities for creating shapes
newCircleSegment (options)
create a circle segment

Parameters:

  • options table a table with : radius, start_angle (in degrees), end_angle (in degrees), and inner_radius

Returns:

    a polygon DisplayObject anchored arc in the center of the circle

Usage:

    local segment = dataviz.newCircleSegment({
      start_angle = 0,
      end_angle = 60,
      radius = 100,
      stroke = 5,
      inner_radius = 50,
      color = "#222F",
      strokeColor = "#0FF",
      strokeWidth = 1
    )
newDot (options)
create a dot

Parameters:

Returns:

    a small circle DisplayObject

Usage:

    local segment = dataviz.newDot({
      x = 100,
      y = 30
    )
newArc (options)
create an arc anchored in the center of the circle

Parameters:

Returns:

    a DisplayObject group containing a Line and a Dot

Usage:

    local arc = dataviz.newArc({
    start_angle = 20,
    end_angle = 90,
    radius = 200,
    strokeWidth = 5,
    strokeColor = "#A00"
    )
newPie (options)
create an pie slice anchored in the center of the circle

Parameters:

Returns:

    a DisplayObject polygon

Usage:

    local pie = dataviz.newPie({
       start_angle = 20,
    	  end_angle = 60,
    	  radius = radius*1.3,
    	  stroke = 5,
    	  color = "#f492a5"
    })
newRegularPolygon (options)
create an n-sided regular polygon

Parameters:

  • options table a table with nb : number of sides, radius : radius of the circle that would contain the polygon

Returns:

    a DisplayObject polygon

Usage:

    local pie = dataviz.newRegularPolygon({
       nb = 5, -- let's make a pentagon
      radius = radius,
      color = "#6e82b7"
    })
newStar (options)
create an n-pointed star

Parameters:

  • options table a table with nb : number of sides, radius : length of the star arms inner_radius : the distance of the "valleys" of the star from the center

Returns:

    a DisplayObject polygon

Usage:

    local str = dataviz.newStar({
     nb = 6, -- it's a star of David. sort of.
     radius =  100,
     inner_radius = 50,
     color = '#f7e8d8',
    })
generated by LDoc 1.4.6 Last updated 2018-09-15 12:10:02