Skip to content

Commit

Permalink
Plotly: fix external graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
Williangalvani committed Jun 19, 2023
1 parent 9100a29 commit 716fb98
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
25 changes: 15 additions & 10 deletions src/components/Plotly.vue
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,21 @@ export default {
'/#/plot', '_blank',
'toolbar=no,scrollbars=yes,resizable=yes,top=500,left=500,width=800,height=400,allow-scripts'
)
setTimeout(() => {
console.log(newWindow)
console.log(newWindow.setPlotData)
newWindow.setPlotData(gd.data)
newWindow.setPlotOptions(gd.layout)
newWindow.setCssColors(this.state.cssColors)
newWindow.setFlightModeChanges(this.state.flightModeChanges)
console.log(this.$eventHub)
newWindow.setEventHub(this.$eventHub)
newWindow.plot()
const externalPlotInterval = setInterval(() => {
try {
console.log(newWindow)
console.log(newWindow.setPlotData)
newWindow.setPlotData(gd.data)
newWindow.setPlotOptions(gd.layout)
newWindow.setCssColors(this.state.cssColors)
newWindow.setFlightModeChanges(this.state.flightModeChanges)
console.log(this.$eventHub)
newWindow.setEventHub(this.$eventHub)
newWindow.plot()
clearInterval(externalPlotInterval)
} catch (e) {
console.log(e)
}
}, 1000)
this.state.childPlots.push(newWindow)
console.log(newWindow)
Expand Down
26 changes: 12 additions & 14 deletions src/components/PlotlyPopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,18 @@ export default {
mounted () {
console.log('mounted')
console.log(this.$route.path)
if (this.$route.path === '/plot') {
window.plot = () => { this.plot() }
window.setPlotData = (data) => { this.plotData = data }
window.setPlotOptions = (options) => { this.plotOptions = options }
window.setFlightModeChanges = (modes) => { this.flightModeChanges = modes }
window.setCssColors = (colors) => { this.cssColors = colors }
window.setTimeRange = (timeRange) => { this.setTimeRange(timeRange) }
window.setEventHub = (eventHub) => {
this.$eventHub = eventHub
this.$eventHub.$on('cesium-time-changed', this.setCursorTime)
this.$eventHub.$on('hoveredTime', this.setCursorTime)
this.$eventHub.$on('child-zoomed', this.setTimeRange)
this.$eventHub.$on('force-resize-plotly', this.resize)
}
window.plot = () => { this.plot() }
window.setPlotData = (data) => { this.plotData = data }
window.setPlotOptions = (options) => { this.plotOptions = options }
window.setFlightModeChanges = (modes) => { this.flightModeChanges = modes }
window.setCssColors = (colors) => { this.cssColors = colors }
window.setTimeRange = (timeRange) => { this.setTimeRange(timeRange) }
window.setEventHub = (eventHub) => {
this.$eventHub = eventHub
this.$eventHub.$on('cesium-time-changed', this.setCursorTime)
this.$eventHub.$on('hoveredTime', this.setCursorTime)
this.$eventHub.$on('child-zoomed', this.setTimeRange)
this.$eventHub.$on('force-resize-plotly', this.resize)
}
const WIDTH_IN_PERCENT_OF_PARENT = 90
d3.select('#line')
Expand Down

0 comments on commit 716fb98

Please sign in to comment.