feat: add stddev func option (#211)

master
jsers 5 years ago
parent d70e60d4a5
commit e0584066a9

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

@ -64,6 +64,13 @@ export const funcMap = {
params: [], params: [],
defaultValue: [], 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 = { export const defaultExpressionValue = {

Loading…
Cancel
Save