feat: add stddev func option (#211)

This commit is contained in:
jsers 2020-07-23 10:10:57 +08:00
parent d70e60d4a5
commit e0584066a9
2 changed files with 15 additions and 6 deletions

View File

@ -119,6 +119,7 @@ class Expression extends Component {
</span>
);
let nPostfix = str.substring(index1 + 2);
if (index2 > -1) {
const mPrefix = str.substring(index1 + 2, index2);
previewNode = (
@ -128,9 +129,10 @@ class Expression extends Component {
{m}
</span>
);
nPostfix = str.substring(index2 + 2);
}
if (func !== 'nodata') {
if (func !== 'nodata' && func !== 'stddev') {
// eslint-disable-next-line no-underscore-dangle
const _index = index2 > -1 ? index2 : index1;
const vPrefix = str.substring(_index + 2, index3);
@ -143,7 +145,7 @@ class Expression extends Component {
</span>
);
} else {
const nPostfix = str.substring(index1 + 2);
// const nPostfix = str.substring(index1 + 2);
previewNode = (
<span>
{previewNode}
@ -187,7 +189,7 @@ class Expression extends Component {
</Select>
);
}
if (func === 'happen' || func === 'ndiff') {
if (func === 'happen' || func === 'ndiff' || func === 'stddev') {
// 发生次数
return (
<InputNumber
@ -195,7 +197,7 @@ class Expression extends Component {
value={val}
min={minnum}
max={_.toNumber(params[0])}
style={{ display: 'inline-block' }}
style={{ display: 'inline-block', marginRight: 8 }}
onChange={(newVal) => { this.handleParamsChange(i, newVal); }}
/>
);
@ -218,7 +220,7 @@ class Expression extends Component {
_.map(_.get(funcMap[value.func], 'params', []), (o, i) => {
return (
<div key={o} style={{ display: 'inline-block', verticalAlign: 'top' }}>
<span style={{ color: i === 0 ? '#2DB7F5' : '#FFB727' }}>{o}</span>
<span style={{ color: i === 0 ? '#FFB727' : '#FFB727' }}>{o}</span>
<span style={{ marginRight: 8, marginLeft: 2 }}>:</span>
{ this.renderFuncParams(i) }
</div>
@ -227,7 +229,7 @@ class Expression extends Component {
}
{
// render value
value.func !== 'nodata' && // nodata 不需要填值
value.func !== 'nodata' && value.func !== 'stddev' && // nodata 不需要填值
<div style={{ display: 'inline-block' }}>
<div style={{ display: 'inline-block', verticalAlign: 'top' }}>
<span style={{ color: '#FF6F27' }}>v</span>

View File

@ -64,6 +64,13 @@ export const funcMap = {
params: [],
defaultValue: [],
},
stddev: {
label: '3-sigma离群点检测',
meaning: '持续 $n 秒内波动值过大超过了 $m 个标准差范围',
meaningEn: 'within $n seconds, the fluctuation value exceeds the $m standard deviation range',
params: ['m'],
defaultValue: [3],
}
};
export const defaultExpressionValue = {