new Table(data, config) → {Spyral.Table}
Create a new Table
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | Array | String | Number | An array of data or a string with CSV or TSV. |
config |
Spyral.Table~TableConfig | an Object for configuring the table initialization |
Returns:
Spyral.TableMethods
-
addColumn(config, ind) → {Spyral.Table}
-
Add a column (at the specified index)
Parameters:
Name Type Description config
Object | String ind
number | string Returns:
Spyral.Table -
addRow(data) → {Spyral.Table}
-
Add a row to the Table
Parameters:
Name Type Description data
Array | Object Returns:
Spyral.Table -
addRows(data) → {Spyral.Table}
-
Add rows to the Table
Parameters:
Name Type Description data
Array Returns:
Spyral.Table -
cell(rowInd, colInd) → {number}
-
Get the value of a cell
Parameters:
Name Type Description rowInd
number | string The row index
colInd
number | string The column index
Returns:
number -
chart(targetopt, configopt) → {Highcharts.Chart}
-
Show a chart representing the Table
Parameters:
Name Type Attributes Description target
String | HTMLElement <optional>
config
HighchartsConfig <optional>
Returns:
Highcharts.Chart -
column(ind, asObjopt) → {Object|Number|String}
-
Get the specified column
Parameters:
Name Type Attributes Description ind
number | string asObj
boolean <optional>
Returns:
Object | Number | String -
columnCounts(ind) → {number}
-
Get the count of each unique value in the specified column
Parameters:
Name Type Description ind
number | string Returns:
number -
columnMax(ind) → {number}
-
Get the maximum value in the specified column
Parameters:
Name Type Description ind
number | string Returns:
number -
columnMean(ind) → {number}
-
Get the mean of the values in the specified column
Parameters:
Name Type Description ind
number | string Returns:
number -
columnMin(ind) → {number}
-
Get the minimum value in the specified column
Parameters:
Name Type Description ind
number | string Returns:
number -
columnRollingMean(ind, neighbors, overwrite) → {Array}
-
Get the rolling mean for the specified column
Parameters:
Name Type Description ind
number | string neighbors
number overwrite
boolean Returns:
Array -
columnSort() → {Spyral.Table}
-
TODO Sort the specified columns
Returns:
Spyral.Table -
columnStandardDeviation(ind) → {number}
-
Get the standard deviation for the specified column
Parameters:
Name Type Description ind
number | string Returns:
number -
columnSum(ind) → {number}
-
Get the sum of the values in the specified column
Parameters:
Name Type Description ind
number | string Returns:
number -
columnVariance(ind) → {number}
-
Get the variance for the specified column
Parameters:
Name Type Description ind
number | string Returns:
number -
columnZScores(ind) → {Array}
-
Get the z scores for the specified column
Parameters:
Name Type Description ind
number | string Returns:
Array -
columns(indsopt, configopt) → {Number|Array}
-
This function returns different values depending on the arguments provided. When there are no arguments, it returns the number of columns in this table. When the first argument is the boolean value
true
all columns are returned. When the first argument is a number a slice of the columns is returned and if the second argument is a number it is treated as the length of the slice to return (note that it isn't theend
index like with Array.slice()).Parameters:
Name Type Attributes Description inds
Boolean | Array | Number | String <optional>
config
Object | Number | String <optional>
Returns:
Number | Array -
forEach(fn)
-
Runs the specified function on each row. The function is passed the row and the row index.
Parameters:
Name Type Description fn
function -
getColumnIndex(ind, create) → {number}
-
Get (and create) the column index
Parameters:
Name Type Description ind
number | string The index
create
boolean Returns:
number -
getRowIndex(ind, create) → {number}
-
Get (and create) the row index
Parameters:
Name Type Description ind
number | string The index
create
boolean Returns:
number -
hasColumn(ind) → {number|string}
-
Does the specified column exist
Parameters:
Name Type Description ind
number | string Returns:
number | string -
header(ind) → {number|string}
-
Get the specified header
Parameters:
Name Type Description ind
number | string Returns:
number | string -
headers(inds) → {Number|Array}
-
This function returns different values depending on the arguments provided. When there are no arguments, it returns the number of headers in this table. When the first argument is the boolean value
true
all headers are returned. When the first argument is a number a slice of the headers is returned. When the first argument is an array the slices specified in the array are returned.Parameters:
Name Type Description inds
Boolean | Array | Number | String Returns:
Number | Array -
html(target, configopt) → {Spyral.Table}
-
Set the target's contents to an HTML representation of the Table
Parameters:
Name Type Attributes Description target
function | String | Object config
Object <optional>
Returns:
Spyral.Table -
row(ind, asObjopt) → {Object|Number|String}
-
Get the specified row
Parameters:
Name Type Attributes Description ind
number | string asObj
boolean <optional>
Returns:
Object | Number | String -
rowCounts(ind) → {number}
-
Get the count of each unique value in the specified row
Parameters:
Name Type Description ind
number | string Returns:
number -
rowMax(ind) → {number}
-
Get the maximum value in the specified row
Parameters:
Name Type Description ind
number | string Returns:
number -
rowMean(ind) → {number}
-
Get the mean of the values in the specified row
Parameters:
Name Type Description ind
number | string Returns:
number -
rowMin(ind) → {number}
-
Get the minimum value in the specified row
Parameters:
Name Type Description ind
number | string Returns:
number -
rowRollingMean(ind, neighbors, overwrite) → {Array}
-
Get the rolling mean for the specified row
Parameters:
Name Type Description ind
number | string neighbors
number overwrite
boolean Returns:
Array -
rowSort() → {Spyral.Table}
-
TODO Sort the specified rows
Returns:
Spyral.Table -
rowStandardDeviation(ind) → {number}
-
Get the standard deviation for the specified row
Parameters:
Name Type Description ind
number | string Returns:
number -
rowSum(ind) → {number}
-
Get the sum of the values in the specified row
Parameters:
Name Type Description ind
number | string Returns:
number -
rowVariance(ind) → {number}
-
Get the variance for the specified row
Parameters:
Name Type Description ind
number | string Returns:
number -
rowZScores(ind) → {Array}
-
Get the z scores for the specified row
Parameters:
Name Type Description ind
number | string Returns:
Array -
rows(indsopt, configopt) → {Number|Array}
-
This function returns different values depending on the arguments provided. When there are no arguments, it returns the number of rows in this table. When the first argument is the boolean value
true
all rows are returned. When the first argument is a an array then the rows corresponding to the row indices or names are returned. When all arguments except are numbers or strings then each of those is returned.Parameters:
Name Type Attributes Description inds
Boolean | Array | Number | String <optional>
config
Object | Number | String <optional>
Returns:
Number | Array -
setCell(row, column, value) → {Spyral.Table}
-
Set the value of a cell
Parameters:
Name Type Description row
number | string The row index
column
number | string The column index
value
number The value to set
Returns:
Spyral.Table -
setColumn(ind, data, create) → {Spyral.Table}
-
Set a column
Parameters:
Name Type Description ind
number | string The column index
data
Object | Array create
boolean Returns:
Spyral.Table -
setHeaders(data) → {Spyral.Table}
-
Set the headers for the Table
Parameters:
Name Type Description data
Object | Array Returns:
Spyral.Table -
setRow(ind, data, create) → {Spyral.Table}
-
Set a row
Parameters:
Name Type Description ind
number | string The row index
data
Object | Array create
boolean Returns:
Spyral.Table -
toCsv(configopt) → {string}
-
Get a CSV representation of the Table
Parameters:
Name Type Attributes Description config
Object <optional>
Returns:
string -
toDataTable(targetopt, config) → {DataTable}
-
Displays an interactive table using DataTables
Parameters:
Name Type Attributes Description target
HTMLElement <optional>
config
Object Returns:
DataTable -
toHtml()
-
Same as toString.
-
toString(configopt) → {string}
-
Get an HTML representation of the Table
Parameters:
Name Type Attributes Description config
Object <optional>
Returns:
string -
toTsv(configopt) → {string}
-
Get a TSV representation of the Table
Parameters:
Name Type Attributes Description config
Object <optional>
Returns:
string -
updateCell(row, column, value, overwrite)
-
Add to or set a cell value
Parameters:
Name Type Description row
number | string The row index
column
number | string The column index
value
number The value to set/add
overwrite
boolean True to set, false to add to current value
-
static cmp(a, b) → {number}
-
Compare two values
Parameters:
Name Type Description a
number | string b
number | string Returns:
number -
static counts(data) → {Object}
-
Get the count of each unique value in the data
Parameters:
Name Type Description data
Array Returns:
Object -
static create(data, config) → {Spyral.Table}
-
Create a new Table
Parameters:
Name Type Description data
Object | Array | String | Number config
Spyral.Table~TableConfig Returns:
Spyral.Table -
static fetch(input, api, config) → {Promise}
-
Fetch a Table from a source
Parameters:
Name Type Description input
String | Request api
Object config
Object Returns:
Promise -
static mean(data) → {number}
-
Get the mean of the provided values
Parameters:
Name Type Description data
Array Returns:
number -
static rollingMean(data, neighbors) → {Array}
-
Get rolling mean for the provided values
Parameters:
Name Type Description data
Array neighbors
number Returns:
Array -
static standardDeviation(data) → {number}
-
Get the standard deviation for the provided values
Parameters:
Name Type Description data
Array Returns:
number -
static sum(data) → {number}
-
Get the sum of the provided values
Parameters:
Name Type Description data
Array Returns:
number -
static variance(data) → {number}
-
Get the variance for the provided values
Parameters:
Name Type Description data
Array Returns:
number -
static zScores(data) → {Array}
-
Get the z scores for the provided values
Parameters:
Name Type Description data
Array Returns:
Array -
static zip(…data) → {Array}
-
Perform a zip operation of the provided arrays. Learn more about zip on Wikipedia.
Parameters:
Name Type Attributes Description data
Array <repeatable>
Returns:
Array
Type Definitions
-
TableConfig
-
The Table config object
Properties:
Name Type Description format
string The format of the provided data, either "tsv" or "csv"
headers
Object | Array The table headers
hasHeaders
boolean True if the headers are the first item in the data
count
string Specify "vertical" or "horizontal" to create a table of unique item counts in the provided data