Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: combine small entries in history pie chart #1056

Merged
merged 3 commits into from
Sep 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@
"in_progress": "In Arbeit",
"klippy_disconnect": "Klippy getrennt",
"klippy_shutdown": "Klippy heruntergefahren",
"Others": "Sonstige",
"server_exit": "Server-Exit"
},
"TitleExportHistory": "Historie exportieren",
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@
"in_progress": "In progress",
"klippy_disconnect": "Klippy disconnect",
"klippy_shutdown": "Klippy shutdown",
"Others": "Others",
"server_exit": "Server exit"
},
"TitleExportHistory": "Export History",
Expand Down
32 changes: 32 additions & 0 deletions src/store/server/history/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const getters: GetterTree<ServerHistoryState, any> = {

getAllPrintStatusArray(state, getters, rootState) {
const output: ServerHistoryStateAllPrintStatusEntry[] = []
const totalCount = state.jobs.length

state.jobs.forEach((current) => {
const index = output.findIndex((element) => element.name === current.status)
Expand Down Expand Up @@ -118,6 +119,37 @@ export const getters: GetterTree<ServerHistoryState, any> = {
}
})

const otherLimit = totalCount * 0.05
const others = output.filter((entry) => entry.value < otherLimit)
if (others.length > 1) {
let otherValue = 0

others.forEach((otherGroup) => {
const index = output.findIndex((entry) => entry.name === otherGroup.name)
if (index !== -1) {
otherValue += output[index].value
output.splice(index, 1)
}
})

output.push({
name: 'others',
displayName: i18n.t(`History.StatusValues.Others`).toString(),
value: otherValue,
itemStyle: {
opacity: 0.9,
color: '#616161',
borderColor: '#1E1E1E',
borderWidth: 2,
borderRadius: 3,
},
showInTable: true,
label: {
color: '#fff',
},
})
}

return output
},

Expand Down