Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/firefly/js/charts/ui/ColumnOrExpression.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {ToolbarButton} from '../../ui/ToolbarButton.jsx';

const EXPRESSION_TTIPS = `
Supported operators: *, /, +, -.
Supported functions: abs(x), acos(x), asin(x), atan(x), atan2(x,y), ceil(x), cos(x), exp(x), floor(x), lg(x), ln(x), log10(x), log(x), power(x,y), round(x), sin(x), sqrt(x), tan(x).
Supported functions: abs(x), acos(x), asin(x), atan(x), atan2(x,y), ceil(x), cos(x), degrees(x), exp(x), floor(x), lg(x), ln(x), log10(x), log(x), power(x,y), radians(x), round(x), sin(x), sqrt(x), tan(x).
Example: sqrt(power(b,4) - 4*a*c) / (2*a), where a, b, c are column names.
Non-alphanumeric column names should be quoted in expressions.`;

Expand Down
2 changes: 2 additions & 0 deletions src/firefly/js/util/__tests__/Expression-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ describe('A test suite for expr/Expression.js', function () {
{e: 'atan(x)', r: Math.atan(x)},
{e: 'ceil(x)', r: Math.ceil(x)},
{e: 'cos(x)', r: Math.cos(x)},
{e: 'degrees(x)', r: x * (180/Math.PI)},
{e: 'exp(x)', r: Math.exp(x)},
{e: 'floor(x)', r: Math.floor(x)},
{e: 'lg(x)', r: Math.log10(x)},
{e: 'log10(x)', r: Math.log10(x)},
{e: 'log(x)', r: Math.log(x)},
{e: 'ln(x)', r: Math.log(x)},
{e: 'radians(x)', r: x * (Math.PI/180) },
{e: 'round(x)', r: Math.round(x)},
{e: 'sin(x)', r: Math.sin(x)},
{e: 'sqrt(x)', r: Math.sqrt(x)},
Expand Down
4 changes: 4 additions & 0 deletions src/firefly/js/util/expr/Expr.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
/** Unary operator: natural log */ export const LN = 114;
/** Unary operator: log 10 */ export const LOG10 = 115;
/** Unary operator: log 10 */ export const LG = 116;
/** Unary operator: degrees */ export const DEGREES = 117;
/** Unary operator: radians */ export const RADIANS = 118;

// NVL2 - If <value expr 1> is not null, returns <value expr 2>, otherwise returns <value expr 3>. (HyperSQL)
/** Ternary operator: if null */ export const NVL2 = 200;
Expand Down Expand Up @@ -175,6 +177,8 @@ class UnaryExpr {
case SIN: return Math.sin(arg);
case SQRT: return Math.sqrt(arg);
case TAN: return Math.tan(arg);
case DEGREES: return arg * (180/Math.PI);
case RADIANS : return arg * (Math.PI/180) ;
default: throw 'BUG: bad rator: '+this.rator;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/firefly/js/util/expr/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ const rators0 = [

const procs1 = [
'abs', 'acos', 'asin', 'atan',
'ceil', 'cos', 'exp', 'floor',
'log', 'ln', 'lg', 'log10', 'round', 'sin', 'sqrt',
'ceil', 'cos', 'degrees', 'exp', 'floor',
'log', 'ln', 'lg', 'log10', 'radians', 'round', 'sin', 'sqrt',
'tan'
];

const rators1 = [
Expr.ABS, Expr.ACOS, Expr.ASIN, Expr.ATAN,
Expr.CEIL, Expr.COS, Expr.EXP, Expr.FLOOR,
Expr.LOG, Expr.LN, Expr.LG, Expr.LOG10, Expr.ROUND, Expr.SIN, Expr.SQRT,
Expr.CEIL, Expr.COS, Expr.DEGREES ,Expr.EXP, Expr.FLOOR,
Expr.LOG, Expr.LN, Expr.LG, Expr.LOG10, Expr.RADIANS, Expr.ROUND, Expr.SIN, Expr.SQRT,
Expr.TAN
];

Expand Down