Skip to content

Commit 716fb98

Browse files
Plotly: fix external graphs
1 parent 9100a29 commit 716fb98

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

src/components/Plotly.vue

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,21 @@ export default {
240240
'/#/plot', '_blank',
241241
'toolbar=no,scrollbars=yes,resizable=yes,top=500,left=500,width=800,height=400,allow-scripts'
242242
)
243-
setTimeout(() => {
244-
console.log(newWindow)
245-
console.log(newWindow.setPlotData)
246-
newWindow.setPlotData(gd.data)
247-
newWindow.setPlotOptions(gd.layout)
248-
newWindow.setCssColors(this.state.cssColors)
249-
newWindow.setFlightModeChanges(this.state.flightModeChanges)
250-
console.log(this.$eventHub)
251-
newWindow.setEventHub(this.$eventHub)
252-
newWindow.plot()
243+
const externalPlotInterval = setInterval(() => {
244+
try {
245+
console.log(newWindow)
246+
console.log(newWindow.setPlotData)
247+
newWindow.setPlotData(gd.data)
248+
newWindow.setPlotOptions(gd.layout)
249+
newWindow.setCssColors(this.state.cssColors)
250+
newWindow.setFlightModeChanges(this.state.flightModeChanges)
251+
console.log(this.$eventHub)
252+
newWindow.setEventHub(this.$eventHub)
253+
newWindow.plot()
254+
clearInterval(externalPlotInterval)
255+
} catch (e) {
256+
console.log(e)
257+
}
253258
}, 1000)
254259
this.state.childPlots.push(newWindow)
255260
console.log(newWindow)

src/components/PlotlyPopup.vue

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,18 @@ export default {
5656
mounted () {
5757
console.log('mounted')
5858
console.log(this.$route.path)
59-
if (this.$route.path === '/plot') {
60-
window.plot = () => { this.plot() }
61-
window.setPlotData = (data) => { this.plotData = data }
62-
window.setPlotOptions = (options) => { this.plotOptions = options }
63-
window.setFlightModeChanges = (modes) => { this.flightModeChanges = modes }
64-
window.setCssColors = (colors) => { this.cssColors = colors }
65-
window.setTimeRange = (timeRange) => { this.setTimeRange(timeRange) }
66-
window.setEventHub = (eventHub) => {
67-
this.$eventHub = eventHub
68-
this.$eventHub.$on('cesium-time-changed', this.setCursorTime)
69-
this.$eventHub.$on('hoveredTime', this.setCursorTime)
70-
this.$eventHub.$on('child-zoomed', this.setTimeRange)
71-
this.$eventHub.$on('force-resize-plotly', this.resize)
72-
}
59+
window.plot = () => { this.plot() }
60+
window.setPlotData = (data) => { this.plotData = data }
61+
window.setPlotOptions = (options) => { this.plotOptions = options }
62+
window.setFlightModeChanges = (modes) => { this.flightModeChanges = modes }
63+
window.setCssColors = (colors) => { this.cssColors = colors }
64+
window.setTimeRange = (timeRange) => { this.setTimeRange(timeRange) }
65+
window.setEventHub = (eventHub) => {
66+
this.$eventHub = eventHub
67+
this.$eventHub.$on('cesium-time-changed', this.setCursorTime)
68+
this.$eventHub.$on('hoveredTime', this.setCursorTime)
69+
this.$eventHub.$on('child-zoomed', this.setTimeRange)
70+
this.$eventHub.$on('force-resize-plotly', this.resize)
7371
}
7472
const WIDTH_IN_PERCENT_OF_PARENT = 90
7573
d3.select('#line')

0 commit comments

Comments
 (0)