feat: Performance timeLabel done.

This commit is contained in:
chiayin
2024-02-01 12:33:11 +08:00
parent bddc1d3a7a
commit d89c5ff4d8
9 changed files with 481 additions and 58 deletions

View File

@@ -3,7 +3,7 @@ import dagre from 'cytoscape-dagre';
import tippy from 'tippy.js';
import 'tippy.js/dist/tippy.css';
import Gradient from 'javascript-color-gradient'; // 多個色階產生器
import TimeLabel from '@/module/timeLabel.js'; // 時間格式轉換器
import { getTimeLabel } from '@/module/timeLabel.js'; // 時間格式轉換器
cytoscape.use( dagre );
@@ -122,8 +122,8 @@ export default function cytoscapeMap(mapData, dataLayerType, dataLayerOption, cu
// Relative %
let textDurRel = text + (optionValue * 100).toFixed(2) + "%";
// Timelabel
let timeLabelInt = text + TimeLabel(optionValue);
let timeLabelFloat = text + TimeLabel(optionValue.toFixed(2));
let timeLabelInt = text + getTimeLabel(optionValue);
let timeLabelFloat = text + getTimeLabel(optionValue.toFixed(2));
// 判斷是否為整數,若非整數要取小數點後面兩個值。
let textTimeLabel = Math.trunc(optionValue) === optionValue ? timeLabelInt : timeLabelFloat;
@@ -180,8 +180,8 @@ export default function cytoscapeMap(mapData, dataLayerType, dataLayerOption, cu
// Relative %
let edgeDurRel = (optionValue * 100).toFixed(2) + "%";
// Timelabel
let timeLabelInt = TimeLabel(optionValue);
let timeLabelFloat = TimeLabel(optionValue.toFixed(2));
let timeLabelInt = getTimeLabel(optionValue);
let timeLabelFloat = getTimeLabel(optionValue.toFixed(2));
let edgeTimeLabel = Math.trunc(optionValue) === optionValue ? timeLabelInt : timeLabelFloat;
result = dataLayerOption === 'rel_duration' ? edgeDurRel : edgeTimeLabel;