bugfix: dashboard > tempchart
Signed-off-by: meteyou <meteyou@gmail.com>
This commit is contained in:
parent
d4785c0b27
commit
fe385d1558
@ -1,4 +1,4 @@
|
|||||||
import store from '../store'
|
//import store from '../store'
|
||||||
import { Line, mixins } from 'vue-chartjs'
|
import { Line, mixins } from 'vue-chartjs'
|
||||||
const { reactiveProp } = mixins;
|
const { reactiveProp } = mixins;
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
timer: '',
|
timer: '',
|
||||||
options: {
|
options: {
|
||||||
events: ['click'],
|
events: [],
|
||||||
animation: {
|
animation: {
|
||||||
duration: 0 // general animation time
|
duration: 0 // general animation time
|
||||||
},
|
},
|
||||||
@ -37,10 +37,10 @@ export default {
|
|||||||
fontColor: 'rgb(203, 203, 203)',
|
fontColor: 'rgb(203, 203, 203)',
|
||||||
fontFamily: 'Roboto,sans-serif',
|
fontFamily: 'Roboto,sans-serif',
|
||||||
filter: function(item) {
|
filter: function(item) {
|
||||||
return !item.text.includes('_target');
|
return (item && item.text) ? !item.text.includes('_target') : false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick: function(e, legendItem) {
|
/*onClick: function(e, legendItem) {
|
||||||
let ci = this.chart;
|
let ci = this.chart;
|
||||||
let index = legendItem.datasetIndex;
|
let index = legendItem.datasetIndex;
|
||||||
let index_target = ci.data.datasets.findIndex(dataset => dataset.label === legendItem.text+'_target');
|
let index_target = ci.data.datasets.findIndex(dataset => dataset.label === legendItem.text+'_target');
|
||||||
@ -56,9 +56,9 @@ export default {
|
|||||||
store.dispatch('gui/setHeaterChartVisibility', { name: legendItem.text, hidden: meta.hidden });
|
store.dispatch('gui/setHeaterChartVisibility', { name: legendItem.text, hidden: meta.hidden });
|
||||||
|
|
||||||
ci.update();
|
ci.update();
|
||||||
}
|
}*/
|
||||||
},
|
},
|
||||||
tooltips: {
|
/*tooltips: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
mode: 'nearest',
|
mode: 'nearest',
|
||||||
caretPadding: 20,
|
caretPadding: 20,
|
||||||
@ -68,15 +68,15 @@ export default {
|
|||||||
let date = new Date(tooltipItem[0].label);
|
let date = new Date(tooltipItem[0].label);
|
||||||
return date.getHours()+":"+(date.getMinutes() < 10 ? "0" : "")+date.getMinutes()+":"+(date.getSeconds() < 10 ? "0" : "")+date.getSeconds();
|
return date.getHours()+":"+(date.getMinutes() < 10 ? "0" : "")+date.getMinutes()+":"+(date.getSeconds() < 10 ? "0" : "")+date.getSeconds();
|
||||||
},
|
},
|
||||||
label: function (tooltipItem/*, data*/) {
|
label: function (tooltipItem/!*, data*!/) {
|
||||||
/*let label_target = data['datasets'][tooltipItem.datasetIndex].label+"_target";
|
/!*let label_target = data['datasets'][tooltipItem.datasetIndex].label+"_target";
|
||||||
let target_dataset = data['datasets'].find(dataset => dataset.label === label_target);
|
let target_dataset = data['datasets'].find(dataset => dataset.label === label_target);
|
||||||
|
|
||||||
if (target_dataset !== undefined && target_dataset.data[tooltipItem.index] !== undefined) return tooltipItem.value+" / "+target_dataset.data[tooltipItem.index].y;*/
|
if (target_dataset !== undefined && target_dataset.data[tooltipItem.index] !== undefined) return tooltipItem.value+" / "+target_dataset.data[tooltipItem.index].y;*!/
|
||||||
return tooltipItem.value;
|
return tooltipItem.value;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},*/
|
||||||
maintainAspectRatio: false,
|
maintainAspectRatio: false,
|
||||||
responsive: true,
|
responsive: true,
|
||||||
responsiveAnimationDuration: 0, // animation duration after a resize
|
responsiveAnimationDuration: 0, // animation duration after a resize
|
||||||
@ -129,22 +129,24 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
/*this.timer = setInterval(function() {
|
this.timer = setInterval(() => {
|
||||||
this.update;
|
if (
|
||||||
}, 2000);*/
|
this.$data._chart.config &&
|
||||||
|
this.$data._chart.config.options &&
|
||||||
|
this.$data._chart.config.options.scales &&
|
||||||
|
this.$data._chart.config.options.scales.xAxes &&
|
||||||
|
this.$data._chart.config.options.scales.xAxes.length &&
|
||||||
|
this.$data._chart.config.options.scales.yAxes &&
|
||||||
|
this.$data._chart.config.options.scales.yAxes.length
|
||||||
|
) {
|
||||||
|
this.$data._chart.config.options.scales.yAxes[0].ticks.max = defaultMaxTemperature
|
||||||
|
this.$data._chart.config.options.scales.xAxes[0].ticks.min = new Date() - maxSampleTime
|
||||||
|
this.$data._chart.config.options.scales.xAxes[0].ticks.max = new Date()
|
||||||
|
this.$data._chart.update()
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
//this.renderChart(this.chartData, this.options)
|
this.renderChart(this.chartData, this.options)
|
||||||
},
|
},
|
||||||
methods: {
|
|
||||||
update() {
|
|
||||||
this.$data._chart.config.options.scales.yAxes[0].ticks.max = defaultMaxTemperature;
|
|
||||||
this.$data._chart.config.options.scales.xAxes[0].ticks.min = new Date() - maxSampleTime;
|
|
||||||
this.$data._chart.config.options.scales.xAxes[0].ticks.max = new Date();
|
|
||||||
this.$data._chart.update();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -107,21 +107,27 @@
|
|||||||
'heatersCount',
|
'heatersCount',
|
||||||
'temperature_fans',
|
'temperature_fans',
|
||||||
'temperature_sensors',
|
'temperature_sensors',
|
||||||
])
|
]),
|
||||||
|
datasets: {
|
||||||
|
get () {
|
||||||
|
return this.$store.state.printer.tempHistory.datasets
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fillData () {
|
|
||||||
this.loaded = true;
|
},
|
||||||
|
mounted () {
|
||||||
this.chartdata = {
|
this.chartdata = {
|
||||||
datasets: this.datasets
|
datasets: this.datasets
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
setTimeout(() => {
|
||||||
mounted () {
|
this.loaded = true
|
||||||
this.fillData();
|
}, 1000)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -28,7 +28,7 @@ export default {
|
|||||||
},
|
},
|
||||||
type: keySplit[0],
|
type: keySplit[0],
|
||||||
time: time
|
time: time
|
||||||
}, { root: true});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -82,7 +82,7 @@ export default {
|
|||||||
this.commit('printer/tempHistory/addHeater', {
|
this.commit('printer/tempHistory/addHeater', {
|
||||||
name: payload.name,
|
name: payload.name,
|
||||||
type: payload.type,
|
type: payload.type,
|
||||||
}, { root: true });
|
});
|
||||||
index = state.datasets.findIndex(element => element.label === payload.name);
|
index = state.datasets.findIndex(element => element.label === payload.name);
|
||||||
}
|
}
|
||||||
let index_target = state.datasets.findIndex(element => element.label === payload.name+'_target');
|
let index_target = state.datasets.findIndex(element => element.label === payload.name+'_target');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user