Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time splitting #4

Merged
merged 21 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from 14 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
7 changes: 7 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Alert from '@/components/Alert.vue';
import Controls from '@/components/Controls.vue';
import MultiLink from '@/components/MultiLink.vue';
import ProvVis from '@/components/ProvVis.vue';
import TimeLine from '@/components/TimeLine.vue';

export default {
name: 'App',
Expand All @@ -18,12 +19,14 @@ export default {
Controls,
MultiLink,
ProvVis,
TimeLine,
},

setup() {
const network = computed(() => store.state.network);
const selectedNodes = computed(() => store.state.selectedNodes);
const loadError = computed(() => store.state.loadError);
const slicedNetwork = computed(() => store.state.slicedNetwork.length > 1);

const multilinkContainer: Ref<Element | null> = ref(null);
const multilinkContainerDimensions = computed(() => {
Expand Down Expand Up @@ -56,6 +59,7 @@ export default {
multilinkContainer,
multilinkContainerDimensions,
showProvenanceVis,
slicedNetwork,
};
},
};
Expand All @@ -65,6 +69,9 @@ export default {
<v-app>
<v-main>
<controls />
<time-line
v-if="network !== null && slicedNetwork === true"
JackWilb marked this conversation as resolved.
Show resolved Hide resolved
/>

<multi-link
v-if="network !== null && selectedNodes !== null"
Expand Down
7 changes: 6 additions & 1 deletion src/components/Controls.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<script lang="ts">
import Legend from '@/components/Legend.vue';
import TimeSlicing from '@/components/TimeSlicing.vue';
import EdgeBuilder from '@/components/EdgeBuilder.vue';
import AboutDialog from '@/components/AboutDialog.vue';
import LoginMenu from '@/components/LoginMenu.vue';

Expand All @@ -12,8 +14,10 @@ import {
export default defineComponent({
components: {
Legend,
TimeSlicing,
AboutDialog,
LoginMenu,
EdgeBuilder,
},

setup() {
Expand Down Expand Up @@ -482,7 +486,8 @@ export default defineComponent({
/>
</v-list-item>
</div>

<TimeSlicing />
<EdgeBuilder />
<v-subheader class="grey darken-3 py-0 white--text">
Legend

Expand Down
13 changes: 13 additions & 0 deletions src/components/DragTarget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,25 @@ export default defineComponent({
const updatedEdgeVars = {
width: droppedVarName,
color: edgeVariables.value.color,
time: edgeVariables.value.time,
};
store.commit.setEdgeVariables(updatedEdgeVars);
} else if (props.type === 'edge' && props.title === 'color') {
const updatedEdgeVars = {
width: edgeVariables.value.width,
color: droppedVarName,
time: edgeVariables.value.time,

JackWilb marked this conversation as resolved.
Show resolved Hide resolved
};
store.commit.setEdgeVariables(updatedEdgeVars);
} else if (props.type === 'edge' && props.title === 'time') {
// TODO: https://github.com/multinet-app/multidynamic/issues/6
// Make more elegant edge filter
const updatedEdgeVars = {
width: droppedVarName,
color: edgeVariables.value.color,
time: droppedVarName,

};
store.commit.setEdgeVariables(updatedEdgeVars);
}
Expand Down
142 changes: 142 additions & 0 deletions src/components/EdgeBuilder.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<script lang="ts">
import store from '@/store';
import { internalFieldNames, Edge } from '@/types';
import DragTarget from '@/components/DragTarget.vue';
import { computed, defineComponent, ref } from '@vue/composition-api';
import EdgeBuilderChart from '@/components/EdgeBuilderChart.vue';
import LegendChart from '@/components/LegendChart.vue';

export default defineComponent({
components: {
DragTarget,
EdgeBuilderChart,
LegendChart,
},

setup() {
const showOptions = ref(false);
const network = computed(() => store.state.network);
const nestedVariables = computed(() => store.state.nestedVariables);
const edgeVariables = computed(() => store.state.edgeVariables);

const columnTypes = computed(() => store.state.columnTypes);

function cleanVariableList(list: Set<string>): Set<string> {
const cleanedVariables = new Set<string>();

list.forEach((variable) => {
if (columnTypes.value !== null && columnTypes.value[variable] !== 'label') {
cleanedVariables.add(variable);
}
});

return cleanedVariables;
}

const cleanedEdgeVariables = computed(() => {
if (network.value !== null) {
// Loop through all edges, flatten the 2d array, and turn it into a set
const allVars: Set<string> = new Set();
network.value.edges.map((edge: Edge) => Object.keys(edge).forEach((key) => allVars.add(key)));

internalFieldNames.forEach((field) => allVars.delete(field));
allVars.delete('source');
allVars.delete('target');
allVars.delete('index');

return cleanVariableList(allVars);
}
return new Set();
});

const displayCharts = computed(() => store.state.displayCharts);

return {
showOptions,
edgeVariables,
cleanedEdgeVariables,
displayCharts,
nestedVariables,
};
},
});
</script>

<template>
<div id="edgebuilder">
<v-list class="pa-0">
<v-subheader class="grey darken-3 py-0 pr-0 white--text">
Build Edges

<v-spacer />

<v-btn
:min-width="40"
:height="48"
depressed
tile
:class="showOptions? `grey darken-2 pa-0` : `grey darken-3 pa-0`"
@click="showOptions = !showOptions"
>
<v-icon color="white">
mdi-cog
</v-icon>
</v-btn>
</v-subheader>

<v-card
v-if="showOptions"
flat
color="white"
class="pb-4 pt-2"
>
<div class="sticky">
<drag-target
v-if="edgeVariables.time === ''"
:title="'time'"
:type="'edge'"
/>

<edge-builder-chart
v-else
:var-name="edgeVariables.time"
:type="'edge'"
:selected="true"
:mapped-to="'time'"
/>

<v-divider />
</div>

<div v-if="cleanedEdgeVariables.size === 0">
No edge attributes to visualize
</div>

<div
v-for="edgeAttr of cleanedEdgeVariables"
v-else
:key="`edge${edgeAttr}`"
>
<legend-chart
:var-name="edgeAttr"
:type="'edge'"
:selected="false"
/>
</div>
</v-card>
</v-list>
</div>
</template>

<style scoped>
.sticky {
position: sticky;
top: 0;
z-index: 2;
background-color: white;
}

.draggable {
cursor: pointer;
}
</style>
JackWilb marked this conversation as resolved.
Show resolved Hide resolved
Loading