diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue index 3f26eb13b..60db92628 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue @@ -8,9 +8,9 @@ - + @@ -231,17 +231,17 @@ export default { this.getRelationsList() }, methods: { - forceUpdateComponent() { - //console.log('!! forceUpdateComponent !!') - this.refreshNetwork - this.$forceUpdate() - }, initGraph() { this.container = document.getElementById('visgraph') // Instanciate vis objects in separate window variables, see vis-network.js window.network = new vis.Network(this.container, this.visgraph_data, window.options) }, + forceUpdateComponent() { + //console.log('!! forceUpdateComponent !!') + this.refreshNetwork + this.$forceUpdate() + }, // events listenOnGraph() { @@ -444,6 +444,41 @@ export default { default: throw "uncaught action" } + }, + + // export image + exportCanvasAsImage() { + const canvas = document.getElementById('visgraph') + .querySelector('canvas') + console.log(canvas) + + let link = document.getElementById('exportCanvasBtn') + link.download = "filiation.png" + + canvas.toBlob(blob => { + console.log(blob) + link.href = URL.createObjectURL(blob) + }, 'image/png') + + /* + TODO improve feature + + // 1. fonctionne, mais pas de contrĂ´le sur le nom + if (canvas && canvas.getContext('2d')) { + let img = canvas.toDataURL('image/png;base64;') + img = img.replace('image/png','image/octet-stream') + window.open(img, '', 'width=1000, height=1000') + } + + // 2. fonctionne, mais 2 click et pas compatible avec tous les browsers + let link = document.getElementById('exportCanvasBtn') + link.download = "image.png" + canvas.toBlob(blob => { + link.href = URL.createObjectURL(blob) + }, 'image/png') + */ + + } } }