You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the upcoming Lens formula features some minor things have to be adjusted about how the math and mapColumn expression functions work.
math
The math function is pretty strict because it always tries to return a number and fails the expression execution otherwise. In the case of Lens, it's very easy to run into this case and a better behavior is to just return null as result (which will handled correctly by the chart)
Move into expressions plugin
Remove explicit return type of number (replaced by ['boolean', 'number', 'null'])
Add optional onError argument. Valid values are "null", "zero", "false" and "throw", defaulting to "throw". In case the tinymath evaluation fails or returns NaN, the return value is specified by onError. If it's set to throw, it will throw an exception, terminating expression execution (in the same way it happens now)
// b is null in the current context
math "a + b" onError="null" | // it's null here
math "a + b" onError="zero" | // it's 0 here
math "a + b" onError="false" | // it's false here
math "a + b" onError="throw" | // expression aborts
math "a + b" | // expression aborts
mapColumn
The mapColumn function creates a new column for the current datatable context. However, it only allows to specify the id without a different name and meta information from other columns can't be copied over.
Move into expressions plugin
Add optional string id attribute - if set, it's used for the id of the resulting column. If not specified defaults to the value of name/column
Add optional string copyMetaFrom attribute - if set, the meta object from the specified column id is copied over to the specified target column. Throws an exception of the column doesn't exist
// creates new column `newCol` (visible name `User facing name`) which contains the duplicate of `oldCol`, with all meta info like field formatters copied over
mapColumn copyMetaFrom="oldCol" name="User facing name" id="newCol" fn={math "oldCol * 2" onError="zero"}
The text was updated successfully, but these errors were encountered:
For the upcoming Lens formula features some minor things have to be adjusted about how the
math
andmapColumn
expression functions work.math
The
math
function is pretty strict because it always tries to return a number and fails the expression execution otherwise. In the case of Lens, it's very easy to run into this case and a better behavior is to just return null as result (which will handled correctly by the chart)expressions
pluginnumber
(replaced by['boolean', 'number', 'null']
)onError
argument. Valid values are"null"
,"zero"
,"false"
and"throw"
, defaulting to"throw"
. In case the tinymath evaluation fails or returnsNaN
, the return value is specified byonError
. If it's set to throw, it will throw an exception, terminating expression execution (in the same way it happens now)mapColumn
The
mapColumn
function creates a new column for the current datatable context. However, it only allows to specify theid
without a differentname
and meta information from other columns can't be copied over.expressions
pluginid
attribute - if set, it's used for theid
of the resulting column. If not specified defaults to the value ofname
/column
copyMetaFrom
attribute - if set, the meta object from the specified column id is copied over to the specified target column. Throws an exception of the column doesn't existThe text was updated successfully, but these errors were encountered: