mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
vue_visgraph: add vis manipulation actions and vis styles
This commit is contained in:
parent
8735602dd6
commit
6ff80be88d
@ -1,59 +1,87 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="visgraph"></div>
|
<div id="visgraph"></div>
|
||||||
|
<!--
|
||||||
|
<button class="btn btn-outline-primary" @click="updateNetwork">UPDATE data</button>
|
||||||
|
-->
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import vis from 'vis-network/dist/vis-network.min'
|
import vis from 'vis-network/dist/vis-network'
|
||||||
import { mapState, mapGetters } from "vuex"
|
import { mapState, mapGetters } from "vuex"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "App",
|
name: "App",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
network: {},
|
container: '',
|
||||||
options: {}
|
network: null,
|
||||||
|
options: {
|
||||||
|
manipulation: {
|
||||||
|
enabled: true,
|
||||||
|
initiallyActive: true,
|
||||||
|
addNode: function(nodeData, callback) {
|
||||||
|
console.log('addNode', nodeData)
|
||||||
|
nodeData.label = 'hello world';
|
||||||
|
callback(nodeData);
|
||||||
|
},
|
||||||
|
editNode: function(nodeData, callback) {
|
||||||
|
console.log('editNode', nodeData)
|
||||||
|
callback(nodeData);
|
||||||
|
},
|
||||||
|
addEdge: function(edgeData, callback) {
|
||||||
|
console.log('addEdge', edgeData)
|
||||||
|
callback(edgeData);
|
||||||
|
},
|
||||||
|
editEdge: function(edgeData, callback) {
|
||||||
|
console.log('editNode', edgeData)
|
||||||
|
callback(edgeData);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
nodes: {
|
||||||
|
physics: true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['persons', 'households', 'courses', 'relationships', 'householdLoadingIds']),
|
...mapState(['persons', 'households', 'courses', 'relationships', 'householdLoadingIds']),
|
||||||
...mapGetters(['nodes', 'edges']),
|
...mapGetters(['nodes', 'edges']),
|
||||||
getNetwork() {
|
visgraph_data() {
|
||||||
console.log('refresh network', this.network, 'with', this.nodes.length, 'nodes')
|
console.log('::: visgraph_data :::', this.nodes.length, 'nodes,', this.edges.length, 'edges')
|
||||||
this.network.setData({
|
return {
|
||||||
nodes: this.nodes,
|
nodes: this.nodes,
|
||||||
edges: this.edges
|
edges: this.edges
|
||||||
})
|
}
|
||||||
}, /*
|
|
||||||
getNodes() {
|
|
||||||
console.log('refresh nodes', this.nodes.length)
|
|
||||||
/// BOUM
|
|
||||||
this.network.setData({nodes: this.nodes})
|
|
||||||
return this.nodes
|
|
||||||
},
|
},
|
||||||
getEdges() {
|
/*
|
||||||
/// BOUM
|
updateNetwork() {
|
||||||
//this.network.setData({edges: this.edges})
|
console.log('refresh network', this.network, 'with', this.nodes.length, 'nodes')
|
||||||
return this.edges
|
this.network.setData(this.visgraph_data)
|
||||||
} */
|
}
|
||||||
|
*/
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
console.log('mounted: init graph')
|
||||||
|
this.initGraph()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initGraph() {
|
initGraph() {
|
||||||
const container = document.getElementById('visgraph')
|
this.container = document.getElementById('visgraph')
|
||||||
this.network = new vis.Network(
|
this.network = new vis.Network(
|
||||||
container, {
|
this.container,
|
||||||
nodes: new vis.DataSet(this.nodes),
|
this.visgraph_data,
|
||||||
edges: new vis.DataSet(this.relationships)
|
this.options
|
||||||
}, this.options
|
|
||||||
)
|
)
|
||||||
|
/*{
|
||||||
|
nodes: new vis.DataSet(this.nodes),
|
||||||
|
edges: new vis.DataSet(this.relationships)
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
console.log('mounted')
|
|
||||||
this.initGraph()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style src="vis-network/dist/dist/vis-network.min.css"></style>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
div#visgraph {
|
div#visgraph {
|
||||||
margin: 2em auto;
|
margin: 2em auto;
|
||||||
|
@ -34,10 +34,12 @@ const store = createStore({
|
|||||||
mutations: {
|
mutations: {
|
||||||
addPerson(state, person) {
|
addPerson(state, person) {
|
||||||
person.label = person.text // vis need label
|
person.label = person.text // vis need label
|
||||||
|
person.id = `person_${person.id}`
|
||||||
state.persons.push(person)
|
state.persons.push(person)
|
||||||
},
|
},
|
||||||
addHousehold(state, household) {
|
addHousehold(state, household) {
|
||||||
household.label = `Ménage n° ${household.id}` // vis need label
|
household.label = `Ménage n° ${household.id}` // vis need label
|
||||||
|
household.id = `household_${household.id}`
|
||||||
state.households.push(household)
|
state.households.push(household)
|
||||||
},
|
},
|
||||||
markHouseholdLoading(state, id) {
|
markHouseholdLoading(state, id) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user