Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions frontend/src/graph/Graph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
:fitScreen="fitScreen"
:download="download"
:scale="config.scale"
:curNode="curNode"
@curNodeUpdated="curNode = $event"
></ui-chart>
</div>
<div class="visual-dl-page-right">
<div class="visual-dl-page-config-container">
<ui-config
:config="config"
:curNode="curNode"
@fitScreen="handleFitScreen"
@download="handleDownload"
></ui-config>
Expand All @@ -37,19 +40,20 @@ export default {
scale: 0.5
},
fitScreen: {fitScreen: false},
download: {download: false}
download: {download: false},
curNode: {}
}
},
mounted() {
autoAdjustHeight();
},
methods: {
handleFitScreen() {
this.fitScreen = {fitScreen: true}
this.fitScreen = {fitScreen: true};
this.config.scale = 0.5;
},
handleDownload() {
this.download = {fitScreen: true}
this.download = {fitScreen: true};
}
}
};
Expand Down
37 changes: 30 additions & 7 deletions frontend/src/graph/ui/Chart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import * as dagreD3 from 'dagre-d3';

export default {
props: ['fitScreen', 'download', 'scale'],
props: ['fitScreen', 'download', 'scale', 'curNode'],
computed: {
computedWidth() {
let scale = this.scale;
Expand Down Expand Up @@ -54,7 +54,7 @@
},
mounted() {
this.getOriginChartsData();

let chartScope = this;
getPluginGraphsGraph().then(({errno, data}) => {
var raw_data = data.data;
var data = raw_data;
Expand Down Expand Up @@ -131,6 +131,26 @@

// adjust viewBox so that the whole graph can be shown, with scroll bar
svg.attr('viewBox', '0 0 ' + g.graph().width + ' ' + g.graph().height);

svg.selectAll(".node").on("click", function(d, i){
this.curNode = g.node(d);
var nodeType = this.curNode.class;
var nodeInfo = null;
if (nodeType === "operator") {
var opIndex = d.slice(7); // remove prefix "opNode_"
nodeInfo = data.node[opIndex];
} else if (nodeType === "input") {
nodeInfo = data.input[d-1];
} else {
nodeInfo = "output";
}

chartScope.$emit('curNodeUpdated',
{
'nodeType': nodeType,
'nodeInfo': nodeInfo
});
});
});
},

Expand Down Expand Up @@ -175,7 +195,7 @@
},

addDragEventForImg() {
let that = this;
let chartScope = this;
// target elements with the "draggable" class
interact('.draggable').draggable({
// enable inertial throwing
Expand All @@ -186,8 +206,8 @@
dragMovelHandler(event, (target, x, y) => {
tansformElement(target, x, y);
// compute the proportional value
let triggerEl = that.getBigImgEl();
let relativeEl = that.getSmallImgDragHandler();
let triggerEl = chartScope.getBigImgEl();
let relativeEl = chartScope.getSmallImgDragHandler();

relativeMove({triggerEl, x, y}, relativeEl);
});
Expand All @@ -213,8 +233,8 @@
dragMovelHandler(event, (target, x, y) => {
tansformElement(target, x, y);
// compute the proportional value
let triggerEl = that.getSmallImgEl();
let relativeEl = that.getBigImgEl();
let triggerEl = chartScope.getSmallImgEl();
let relativeEl = chartScope.getBigImgEl();

relativeMove({triggerEl, x, y}, relativeEl);
});
Expand Down Expand Up @@ -245,6 +265,9 @@
rx: 10;
ry: 10;

.node
cursor: pointer

.output
fill: #c38d9e

Expand Down
76 changes: 52 additions & 24 deletions frontend/src/graph/ui/Config.vue
Original file line number Diff line number Diff line change
@@ -1,36 +1,60 @@
<template>
<div class="visual-dl-graph-config-com">
<v-btn
class="visual-dl-graph-config-button"
color="primary"
@click="handleFitScreen"
dark>
<v-icon style="margin-right: 6px" size="20">fullscreen</v-icon>
Fit &nbsp; to &nbsp; screen
</v-btn>
<div class="graph-config-upper">
<v-btn
class="visual-dl-graph-config-button"
color="primary"
@click="handleFitScreen"
dark>
<v-icon style="margin-right: 6px" size="20">fullscreen</v-icon>
Fit &nbsp; to &nbsp; screen
</v-btn>

<v-btn
class="visual-dl-graph-config-button"
color="primary"
@click="handleDownload"
dark>
<v-icon style="margin-right: 6px">file_download</v-icon>
Download image
</v-btn>
<v-btn
class="visual-dl-graph-config-button"
color="primary"
@click="handleDownload"
dark>
<v-icon style="margin-right: 6px">file_download</v-icon>
Download image
</v-btn>

<v-slider
label="Scale"
max="1"
min="0.1"
step="0.1"
v-model="config.scale"
dark></v-slider>
<v-slider
label="Scale"
max="1"
min="0.1"
step="0.1"
v-model="config.scale"
dark></v-slider>
</div>
<div class="node-info">
<h3>Node Info: </h3>

<div v-if="curNode.nodeType === 'input'">
<div>Node Type: {{ curNode.nodeType }}</div>
<div>Name: {{curNode.nodeInfo.name}}</div>
<div>Shape: {{curNode.nodeInfo.shape}}</div>
<div>Data Type: {{curNode.nodeInfo.data_type}}</div>
</div>
<div v-else-if="curNode.nodeType === 'output'">
<div>Node Type: {{ curNode.nodeType }}</div>
</div>
<div v-else-if="curNode.nodeType === 'operator'">
<div>Node Type: {{ curNode.nodeType }}</div>
<div>Input: {{curNode.nodeInfo.input}}</div>
<div>Operator Type: {{curNode.nodeInfo.opType}}</div>
<div>Output: {{curNode.nodeInfo.output}}</div>
</div>
<div v-else>

</div>
</div>
</div>
</template>
<script>

export default {
props:['config'],
props:['config', 'curNode'],
methods: {
handleFitScreen() {
this.$emit('fitScreen')
Expand All @@ -55,4 +79,8 @@ export default {
.sm-icon
width 36px
height 26px

.graph-config-upper
height 400px

</style>