Skip to content

Commit

Permalink
fix: temperature chart legend (#973)
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
  • Loading branch information
pedrolamas committed Dec 8, 2022
1 parent e8b9f78 commit f490098
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
4 changes: 0 additions & 4 deletions src/components/widgets/thermals/TemperatureTargets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,6 @@ export default class TemperatureTargets extends Mixins(StateMixin) {
return this.$store.getters['printer/getSensors']
}
get chartableSensors () {
return this.$store.getters['printer/getChartableSensors']
}
get chartSelectedLegends () {
return this.$store.getters['charts/getSelectedLegends']
}
Expand Down
3 changes: 1 addition & 2 deletions src/components/widgets/thermals/ThermalChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ export default class ThermalChart extends Vue {
formatter: (params: any) => {
let text = ''
params
.reverse()
.forEach((param: any) => {
if (
!param.seriesName.toLowerCase().endsWith('target') &&
Expand All @@ -177,7 +176,7 @@ export default class ThermalChart extends Vue {
<div>
${param.marker}
<span style="font-size:${fontSize}px;color:${fontColor};font-weight:400;margin-left:2px">
${param.seriesName}:
${this.$filters.startCase(param.seriesName)}:
</span>
<span style="float:right;margin-left:20px;font-size:${fontSize}px;color:${fontColor};font-weight:900">
${param.value[param.seriesName].toFixed(2)}<small>°C</small>`
Expand Down
38 changes: 23 additions & 15 deletions src/store/printer/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,24 +616,32 @@ export const getters: GetterTree<PrinterState, RootState> = {
* to chart.
*/
getChartableSensors: (state) => {
let sensors: string[] = []
const keys = [
'temperature_fan',
'temperature_probe',
'z_thermal_adjust',
'temperature_sensor'
const keyGroups = [
[
'temperature_fan'
],
[
'temperature_probe',
'z_thermal_adjust',
'temperature_sensor'
]
]

for (const key of Object.keys(state.printer)) {
if (keys.some(e => key.startsWith(e))) {
sensors.push(key)
}
}
const printerKeys = Object.keys(state.printer)

if (state.printer.heaters.available_heaters.length > 0) {
sensors = [...sensors, ...state.printer.heaters.available_heaters]
}
return sensors
const sensors = keyGroups.flatMap(keyGroup => {
return printerKeys
.filter(key => keyGroup.some(x => key.startsWith(x)))
.sort((a, b) => a.localeCompare(b))
})

const heaters = (state.printer.heaters.available_heaters as string[])
.sort((a, b) => a.localeCompare(b))

return [
...heaters,
...sensors
]
},

getBedScrews: (_, getters) => {
Expand Down

0 comments on commit f490098

Please sign in to comment.