Module:TabUtils/doc
This module provides utility functions for transforming tabular data sets in chart renderings.
See mw:Extension:Chart/Transforms for more documentation on this transform feature of the Charts system.
Usage
select
: subset a data set by column reference or comparison on row values
To use as a chart transform:
"transform": {
"module": "TabUtils",
"function": "select",
"args": {
"where": "date",
"lte": "2000"
}
}
To invoke as a utility function from another module:
local TabUtils = require( "Module:TabUtils" )
local tab = mw.ext.data.get( "Sample weekly temperature dataset.tab" )
-- Note this may mutate the original tab object
tab = TabUtils.select(tab, {
["where"] = "date",
["lte"] = "2000"
})
Arguments:
cols
: comma-separated list of column names to keep, otherwise returns all colswhere
: column name to match on, otherwise returns all rowseq
,ne
,gt
,lt
,gte
,lte
: value to compare against to keep rowssort
: column name to sort onorder
: sort order "asc
" or "desc
", defaults to "asc
"decimate
: keep only every nth row
Todo
- support sort on multiple columns
- allow combining multiple gt/gte/lt/lte to allow ranges