optimize tempchart workflow
Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
parent
0edb9dd1d2
commit
761f08b87d
@ -15,8 +15,7 @@ export default {
|
||||
return {
|
||||
chart : null,
|
||||
timerChart: '',
|
||||
timerDataset: '',
|
||||
isVisable: true,
|
||||
isVisible: true,
|
||||
chartOptions: {
|
||||
darkMode: true,
|
||||
animation: false,
|
||||
@ -186,7 +185,6 @@ export default {
|
||||
computed: {
|
||||
...mapState({
|
||||
intervalChartUpdate: state => state.gui.tempchart.intervalChartUpdate,
|
||||
intervalDatasetUpdate: state => state.gui.tempchart.intervalDatasetUpdate,
|
||||
boolTempchart: state => state.gui.dashboard.boolTempchart,
|
||||
}),
|
||||
maxHistory: {
|
||||
@ -230,21 +228,16 @@ export default {
|
||||
if (document.getElementById("tempchart") && this.chart === null) {
|
||||
this.chart = echarts.init(document.getElementById("tempchart"), null, {renderer: 'canvas'})
|
||||
this.chart.setOption(this.chartOptions)
|
||||
this.updateChart()
|
||||
} else setTimeout(() => {
|
||||
this.createChart()
|
||||
}, 500)
|
||||
}, 1000)
|
||||
},
|
||||
visibilityChanged (isVisible) {
|
||||
this.isVisible = isVisible
|
||||
if(isVisible && this.chart !== null) this.chart.resize()
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.timerChart = setInterval(() => {
|
||||
updateChart() {
|
||||
if (
|
||||
this.chart &&
|
||||
this.boolTempchart &&
|
||||
this.isVisable
|
||||
this.isVisible
|
||||
) {
|
||||
this.chart.setOption({
|
||||
series: this.series,
|
||||
@ -300,13 +293,19 @@ export default {
|
||||
}
|
||||
}],
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
this.updateChart()
|
||||
}, this.intervalChartUpdate)
|
||||
}
|
||||
}, this.intervalChartUpdate)
|
||||
|
||||
this.timerDataset = setInterval(() => {
|
||||
this.$store.dispatch("printer/tempHistory/updateDatasets")
|
||||
}, this.intervalDatasetUpdate)
|
||||
|
||||
},
|
||||
visibilityChanged (isVisible) {
|
||||
this.isVisible = isVisible
|
||||
if(isVisible && this.chart !== null) this.chart.resize()
|
||||
if(this.chart !== null) this.updateChart()
|
||||
},
|
||||
},
|
||||
created() {
|
||||
window.addEventListener('resize', () => {
|
||||
if (this.chart) this.chart.resize()
|
||||
})
|
||||
|
@ -5,7 +5,7 @@ export default {
|
||||
commit('reset')
|
||||
},
|
||||
|
||||
getHistory({ commit, state, rootGetters }, payload) {
|
||||
getHistory({ commit, state, rootGetters, rootState, dispatch }, payload) {
|
||||
const now = new Date()
|
||||
const maxHistory = rootGetters['server/getConfig']('server', 'temperature_store_size') || 1200
|
||||
|
||||
@ -147,10 +147,14 @@ export default {
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
dispatch("updateDatasets")
|
||||
}, rootState.gui.tempchart.intervalDatasetUpdate)
|
||||
}
|
||||
},
|
||||
|
||||
updateDatasets({ commit, rootState, rootGetters }) {
|
||||
updateDatasets({ commit, dispatch, rootState, rootGetters }) {
|
||||
if (
|
||||
'heaters' in rootState.printer &&
|
||||
'available_sensors' in rootState.printer.heaters &&
|
||||
@ -179,5 +183,9 @@ export default {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
dispatch("updateDatasets")
|
||||
}, rootState.gui.tempchart.intervalDatasetUpdate)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user