sonar 9 left; Resolved as much as possible
This commit is contained in:
@@ -7,6 +7,14 @@ import { getTimeLabel } from '@/module/timeLabel.js'; // 時間格式轉換器
|
||||
import CytoscapeStore from '@/stores/cytoscapeStore';
|
||||
import { SAVE_KEY_NAME } from '@/constants/constants.js';
|
||||
|
||||
const composeFreqTypeText = (baseText, dataLayerOption, optionValue) => { //sonar-qube
|
||||
let text = baseText;
|
||||
const textInt = dataLayerOption === 'rel_freq' ? baseText + optionValue * 100 + "%" : baseText + optionValue;
|
||||
const textFloat = dataLayerOption === 'rel_freq'? baseText + (optionValue * 100).toFixed(2) + "%" : baseText + optionValue.toFixed(2);
|
||||
// 判斷是否為整數,若非整數要取小數點後面兩個值。
|
||||
text = Math.trunc(optionValue) === optionValue ? textInt : textFloat;
|
||||
return text;
|
||||
};
|
||||
|
||||
cytoscape.use( dagre );
|
||||
|
||||
@@ -113,22 +121,15 @@ export default function cytoscapeMap(mapData, dataLayerType, dataLayerOption, cu
|
||||
// 可使用 parseInt(整數) parseFloat(浮點數) 將字串轉為數字
|
||||
// Relative 要轉為百分比 %
|
||||
if(node.data('type') === 'activity') {
|
||||
let textInt;
|
||||
let textFloat;
|
||||
let textDurRel;
|
||||
let timeLabelInt;
|
||||
let timeLabelFloat;
|
||||
let textTimeLabel;
|
||||
|
||||
switch(dataLayerType) {
|
||||
case 'freq': // Frequency
|
||||
textInt = dataLayerOption === 'rel_freq' ? text + optionValue * 100 + "%" : text + optionValue;
|
||||
textFloat = dataLayerOption === 'rel_freq'? text + (optionValue * 100).toFixed(2) + "%" : text + optionValue.toFixed(2);
|
||||
|
||||
// 判斷是否為整數,若非整數要取小數點後面兩個值。
|
||||
text = Math.trunc(optionValue) === optionValue ? textInt : textFloat;
|
||||
case 'freq': // Frequency
|
||||
text = composeFreqTypeText(text, dataLayerOption, optionValue);
|
||||
break;
|
||||
|
||||
case 'duration': // Duration 除了 Relative 為百分比 % ,其他要轉變時間單位。
|
||||
// Relative %
|
||||
textDurRel = text + (optionValue * 100).toFixed(2) + "%";
|
||||
@@ -144,7 +145,7 @@ export default function cytoscapeMap(mapData, dataLayerType, dataLayerOption, cu
|
||||
}
|
||||
}
|
||||
|
||||
return text
|
||||
return text;
|
||||
},
|
||||
'text-opacity':0.7,
|
||||
'background-color': 'data(backgroundColor)',
|
||||
|
||||
Reference in New Issue
Block a user