SetData/StandardDatasetFormat

Data Object

The data object is an array of row objects.

local data = {
    row1,
    row2,
    row3,
    etc...,
}

Row

Each row object has the following structure:

local row = {
    ["cols"] = column object, -- see below
    ["color"] = {
        ["r"] = 1.0,
        ["g"] = 0.0,
        ["b"] = 0.0,
        ["a"] = 1.0,
    },
    ["colorargs"] = nil,
    ["DoCellUpdate"] = nil,
}

cols

The cols object structure is described below.

color

(Optional) A color object. Defaults to '''white'''.

colorargs

(Opional) An array of args that will be passed to the '''function''' specified for '''color'''. See color object. Defaults to (data, cols, realrow, column, table)

DoCellUpdate

A custom display function.

Cols

The column object is also an array of cell objects, one for each column.
It is important that the size of the cols array is the same as the number of columns you have defined in '''CreateST'''.

local cols= { 
    cell1,
    cell2,
    cell3,
    etc...,
}

Each cell object has the following format:

local column = {
    ["value"] = "Sachmo",
    ["args"] = nil,
    ["color"] = {
        ["r"] = 1.0,
        ["g"] = 1.0,
        ["b"] = 1.0,
        ["a"] = 1.0,
    },
    ["colorargs"] = nil,
    ["DoCellUpdate"] = nil,
}

value

Just like color objects, '''value''' can be a function or a value to display. If the type of '''value''' is a function, it is evaluated for display using the args table of arguments.

args

(Optional) An array of args that will be passed to the '''function''' specified for '''value'''. Defaults to (data, cols, realrow, column, table)

color

(Optional) A color object. Defaults to '''white'''.

colorargs

(Opional) An array of args that will be passed to the '''function''' specified for '''color'''. See color object. Defaults to (data, cols, realrow, column, table)

DoCellUpdate

A custom display function.

Example

{
    {
        ["cols"] = {
            {
                ["value"] = function(min, max)
                    return math.random(min, max);
                },
                ["args"] = {
                    1,
                    100,
                },
            }, -- [1] Column 1
            {
                ["value"] = "Row 1, Col 2",
                ["color"] = {
                    ["r"] = 1.0,
                    ["g"] = 1.0,
                    ["b"] = 1.0,
                    ["a"] = 1.0,
                },  -- Cell color
            }, -- [2] Column 2
        },
    }, -- [1] Row 1
    {
        ["cols"] = {
            {
                ["value"] = "Row 2, Col 1",
            }, -- [1] Column 1
            {
                ["value"] = "Row 2, Col 2",
            }, -- [2] Column 2
        }, 
        ["color"] = {
            ["r"] = 0.0,
            ["g"] = 1.0,
            ["b"] = 1.0,
            ["a"] = 1.0,
        },  -- Row color
    }, -- [2] Row 2
}

Comments

Posts Quoted:
Reply
Clear All Quotes