forked from p34709852/monkey
Rules update
The rules are now set at this.rules array. While some of them have two conditions, i.e. Rule #2 shoud check if Conclusive is 0 and Inconclusive > 0, all rules has its own function (formula), which returns true or false. Eventually, I could shorten variable naming, for example, d_['Conclusive'] to something more prompt, but keeping this helps understand formulas even without referencing to upper comments.
This commit is contained in:
parent
244be146bb
commit
5c4797108e
|
@ -201,6 +201,34 @@ class VennDiagram extends React.Component{
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
RULE #1: All scores have to be equal 0, except Unexecuted [U] which could be also a negative integer
|
||||||
|
sum(C, I, P, U) has to be <=0
|
||||||
|
|
||||||
|
RULE #2: Conclusive [C] has to be > 0,
|
||||||
|
sum(C) > 0
|
||||||
|
|
||||||
|
RULE #3: Inconclusive [I] has to be > 0 while Conclusive has to be 0,
|
||||||
|
sum(C, I) > 0 and C * I = 0, while C has to be 0
|
||||||
|
|
||||||
|
RULE #4: Positive [P] and Unexecuted have to be positive
|
||||||
|
sum(P, U) >= 2 and P * U = positive integer, while
|
||||||
|
if the P is bigger by 2 then negative U, first conditional
|
||||||
|
would be true.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
this.rules = [
|
||||||
|
|
||||||
|
{ id: 'Rule #1', f: function(d_){ return d_['Conclusive'] + d_['Inconclusive'] + d_['Positive'] + d_['Unexecuted'] <= 0; } },
|
||||||
|
{ id: 'Rule #2', f: function(d_){ return d_['Conclusive'] > 0; } },
|
||||||
|
{ id: 'Rule #3', f: function(d_){ return d_['Conclusive'] === 0 && d_['Inconclusive'] > 0; } },
|
||||||
|
{ id: 'Rule #4', f: function(d_){ return d_['Positive'] + d_['Unexecuted'] >= 2 && d_['Positive'] * d_['Unexecuted'] > 0; } }
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
this._onScroll = this._onScroll.bind(this);
|
this._onScroll = this._onScroll.bind(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -247,10 +275,11 @@ class VennDiagram extends React.Component{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_onScroll(e){
|
_onScroll(e){
|
||||||
|
|
||||||
this.divElement.style.cursor = 'default';
|
this.divElement.style.cursor = 'default';
|
||||||
this.setState({target: e, tooltip: { target: null, bcolor: 'none', top: 0, left: 0, display: 'none', html: '' } });
|
this.setState({target: null, tooltip: { target: null, bcolor: 'none', top: 0, left: 0, display: 'none', html: '' } });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,15 +309,13 @@ class VennDiagram extends React.Component{
|
||||||
|
|
||||||
this.props.pillarsGrades.forEach((d_, i_) => {
|
this.props.pillarsGrades.forEach((d_, i_) => {
|
||||||
|
|
||||||
let params = omit('Unexpected', omit('pillar', d_));
|
let params = omit('pillar', d_);
|
||||||
let sum = Object.keys(params).reduce((sum_, key_) => sum_ + parseFloat(params[key_]||0), 0);
|
let sum = Object.keys(params).reduce((sum_, key_) => sum_ + parseFloat(params[key_]||0), 0);
|
||||||
let key = TypographicUtilities.removeAmpersand(d_.pillar);
|
let key = TypographicUtilities.removeAmpersand(d_.pillar);
|
||||||
let html = self.buildTooltipHtmlContent(d_);
|
let html = self.buildTooltipHtmlContent(d_);
|
||||||
let rule = 3;
|
let rule = null;
|
||||||
|
|
||||||
if(sum === 0){ rule = 0 }
|
for(let j = 0; j < self.rules.length; j++){ if(self.rules[j].f(d_)) { rule = j; break; }}
|
||||||
else if(d_['Conclusive'] > 0){ rule = 1 }
|
|
||||||
else if(d_['Conclusive'] === 0 && d_['Inconclusive'] > 0) { rule = 2 }
|
|
||||||
|
|
||||||
self.setLayoutElement(rule, key, html, d_);
|
self.setLayoutElement(rule, key, html, d_);
|
||||||
data.push(this.layout[key])
|
data.push(this.layout[key])
|
||||||
|
@ -304,6 +331,8 @@ class VennDiagram extends React.Component{
|
||||||
|
|
||||||
setLayoutElement(rule_, key_, html_, d_){
|
setLayoutElement(rule_, key_, html_, d_){
|
||||||
|
|
||||||
|
if(rule_ == null) { throw Error('The node scores are invalid'); }
|
||||||
|
|
||||||
if(key_ === 'Data'){ this.layout[key_].fontStyle = this.fontStyles[0]; }
|
if(key_ === 'Data'){ this.layout[key_].fontStyle = this.fontStyles[0]; }
|
||||||
else {this.layout[key_].fontStyle = this.fontStyles[1]; }
|
else {this.layout[key_].fontStyle = this.fontStyles[1]; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue