Row Expression

1 Usages of Row Expression

JavaScript expression can be data values when manufacture/trim/calculate data or generate chart.

2 Edit Row Expression

  1. If the script is blank, then return empty string.

  2. It can include any valid elments which Nashorn can parse(ECMAScript 5.1).

  3. It should be a value finally.

  4. It can include following placeholders:

  5. #{TableRowNumber}

    #{DataRowNumber}

    #{<column_name>}

    #{<column_name>- <statistic-name>}

  6. All valid placeholders are listed in left.

  7. To save the script, click “Edit” button.

  8. Hover or click button “Examples” to paste example codes.

  9. Hover or click button “Histories” to paste codes in histories.

3 Calculate Row Expression

When MyBox evaluates the expression:

  1. Placeholders are replaced with actual values of each data row.

  2. Statistic values are calculated by all data.

  3. ‘#{xxx}’ is handled as string while #{xxx} is handled as number.

  4. When handles all pages, script fails when it includes “#{TableRowNumber}” .

4 Examples

row expression meaning
#{DataRowNumber} % 2 == 0 data row number is even
#{TableRowNumber} % 2 == 1 odd rows in current page
Math.abs(#{v1}) + Math.PI * Math.sqrt(#{v2}) calculation
‘#{v1}’.replace(/hello/ig, ‘Hello’) replace all “hello”(case-insensitive) as “Hello” in column “v1”
‘#{v1}’.toLowerCase() lower case of value of column “v1”
‘#{v1}’.split(‘,’) split value of column “v1” by comma
#{v1} - #{v1-Mean} difference between value of column “v1” and mean of column “v1”
new Date(‘#{time}’.replace(/-/g,‘/’)).getFullYear() year of value of column “time”

Row Filter

1 Usages of Row Filter

“Row Filter” is special “Row Expression”, and can be condition to filter data rows.

2 Edit Row Filter

  1. It should be boolean value(“true” or “false”) finally.

  2. Can set maximum rows to take.

  3. Can be saved in tree.

3 Exmaples

row filter meaning
#{DataRowNumber} % 2 == 0 data row number is even
#{TableRowNumber} % 2 == 1 odd rows in current page
Math.abs(#{v1}) >= 0 value of column “v1” is number
#{v1}) > 0 value of column “v1” is larger than zero
#{v1} - #{v2} < 100 difference between values of “v1” and “v2” is less than 100
‘#{v1}’ == '' value of column “v1” is null or empty
‘#{v1}’.length > 0 value of column “v1” is not empty
‘#{v1}’.search(/Hello/ig) >= 0 value of column “v1” includes “Hello”(case-insensitive)
‘#{v1}’.startsWith(‘Hello’) value of column “v1” starts with “Hello”
var array = [ ‘A’, ‘B’, ‘C’];array.includes(‘#{v1}’) value of column “v1” is one of “A”, “B”, “C”
#{v1} < #{v1-Mean} value of column “v1” is less than mean of column “v1”
new Date(‘#{time}’.replace(/-/g,‘/’)).getTime() > new Date(‘2016/05/19 09:23:12’).getTime() value of column “time” is later than ‘2016/05/19 09:23:12’