diff --git a/src/main.js b/src/main.js
index 69bc2fe..19b1083 100644
--- a/src/main.js
+++ b/src/main.js
@@ -21,6 +21,7 @@ pinia.use(({ store }) => {
store.$router = markRaw(router);
store.$axios = markRaw(axios);
store.$toast = markRaw(ToastPlugin);
+ store.$http = app.$http;
});
// can use `this.$moment` in Vue.js
diff --git a/src/stores/files.js b/src/stores/files.js
index 14f5171..5595b2b 100644
--- a/src/stores/files.js
+++ b/src/stores/files.js
@@ -61,6 +61,7 @@ export default defineStore('filesStore', {
*/
async fetchEventLog() {
const api = '/api/logs';
+ // console.log(this);
try {
const response = await axios.get(api);
diff --git a/src/views/Discover/index.vue b/src/views/Discover/index.vue
index fe43d46..e7463bc 100644
--- a/src/views/Discover/index.vue
+++ b/src/views/Discover/index.vue
@@ -13,6 +13,12 @@
unbundled-bezier
curve style: {{ curveStyle }}
+
+
+ - LR
+ - TB
+ - rank: {{ rank }}
+
-
@@ -100,7 +106,8 @@ export default {
curveStyle:'unbundled-bezier', // 貝茲曲線 bezier | 直角 unbundled-bezier
mapType: 'processMap', // processMap | bpmn
dataLayerType: 'freq', // freq | duration
- dataLayerOption: 'total'
+ dataLayerOption: 'total',
+ rank: 'LR' // 直向 TB | 橫向 LR
}
},
methods: {
@@ -109,7 +116,7 @@ export default {
else if(e.target.type === 'select-one') this.dataLayerOption = e.target.value;
},
/**
- * 設定每個 node, edges
+ * 設定每個 node, edges 的樣式
*/
createColorGradient() {
let gradientArray = [];
@@ -306,7 +313,7 @@ export default {
},
layout: {
name: 'klay',
- rankDir: 'LR' // 直向 TB | 橫向 LR
+ rankDir: this.rank, // 直向 TB | 橫向 LR
},
style: [
// 點擊 node 後改變的樣式
@@ -323,54 +330,40 @@ export default {
style: {
'label': // 節點要顯示的文字
function(node) {
+ // node.data(this.dataLayerType+"."+this.dataLayerOption) 為原先陣列 node.data.key.value
+ let optionValue = node.data(`${this.dataLayerType}.${this.dataLayerOption}`);
let text = '';
- // 文字超過 10 字尾巴要加「...」,style 要空一行(\n 換行符號)
- text = node.data.label.length > 10 ? `${node.data.label.substr(0,10)}...\n\n` : `${node.data("label")}`;
+ // 文字超過 10 字尾巴要加「...」,style 要換兩行(\n 換行符號)
+ // 使用 data() 是因為在 cytoscape 中從陣列轉為 function
+ text = node.data('label').length > 10 ? `${node.data('label').substr(0, 10)}...\n\n` : `${node.data('label')}\n\n`;
- switch (node.data.type) {
- case 'activity':
+ // 在 element 中 activity 歸類在 default,所以要先判斷 node 是否為 activeity 才裝入文字。
+ // Relative 要轉為百分比 %
+ if(node.data('type') === 'activity') {
+ switch(this.dataLayerType) {
+ case 'freq': // Frequency
+ let textInt = this.dataLayerOption === 'rel_freq' ? text + optionValue * 100 + "%" : text + optionValue;
+ let textFloat = this.dataLayerOption === 'rel_freq'? text + (optionValue * 100).toFixed(2) + "%" : text + optionValue.toFixed(2);
- break;
+ // 判斷是否為整數,若非整數要取小數點後面兩個值。
+ text = Math.trunc(optionValue) === optionValue ? textInt : textFloat;
+ break;
- default:
- break;
- }
- if(node.data.type === 'activity'){
- if(key == "duration"){ //Duration
- if(value == "rel_duration"){ // %
- text = text + (parseFloat(node.data(key+"."+value))*100).toFixed(2) + "%"
- }
- else{ //Timelabel
- if(parseInt(node.data(key+"."+value))==node.data(key+"."+value)){ //Int
- text = text + TimeLabel(node.data(key+"."+value))
- }
- else{//Float
- text = text + TimeLabel(node.data(key+"."+value).toFixed(2))
- }
- }
- }
- else{ // Freq
- if(parseInt(node.data(key+"."+value))==node.data(key+"."+value)){ //Int
- if(value == "rel_freq"){
- text = text + node.data(key+"."+value)*100 + "%"
- }
- else{
- text = text + node.data(key+"."+value)
- }
- }
- else{ //Float
- if(value == "rel_freq"){
- text = text + (parseFloat(node.data(key+"."+value))*100).toFixed(2) + "%"
- }
- else{
- text = text + parseFloat(node.data(key+"."+value)).toFixed(2)
- }
- }
- }
+ case 'duration': // Duration 除了 Relative 為百分比 % ,其他要轉變時間單位。
+ // Relative %
+ let textDurRel = text + (optionValue * 100).toFixed(2) + "%";
+ // Timelabel
+ let timeLabelInt = text + TimeLabel(optionValue);
+ let timeLabelFloat = text + TimeLabel(optionValue).toFixed(2);
+ let textTimeLabel = Math.trunc(optionValue) === optionValue ? timeLabelInt : timeLabelFloat;
+
+ text = this.dataLayerOption === 'rel_duration' ? textDurRel : textTimeLabel;
+ break;
}
+ }
return text
- },
+ },
'text-opacity':0.7,
'background-color': 'data(backgroundColor)',
'border-color':'data(bordercolor)',