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(insights): Fix custom labels on bar chart #19393

Merged
merged 1 commit into from
Dec 18, 2023
Merged
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
32 changes: 18 additions & 14 deletions frontend/src/scenes/insights/views/LineGraph/LineGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -702,20 +702,24 @@ export function LineGraph_({
precision,
autoSkip: true,
callback: function _renderYLabel(_, i) {
const labelDescriptors = (
datasets?.[0]?.labels?.[i]
? [
// prefer to use the label over the action name if it exists
datasets?.[0]?.labels?.[i],
datasets?.[0]?.compareLabels?.[i],
]
: [
datasets?.[0]?.actions?.[i]?.custom_name ?? datasets?.[0]?.actions?.[i]?.name, // action name
datasets?.[0]?.breakdownValues?.[i], // breakdown value
datasets?.[0]?.compareLabels?.[i], // compare value
]
).filter((l) => !!l)
return labelDescriptors.join(' - ')
const d = datasets?.[0]
if (!d) {
return ''
}
// prefer custom name, then label, then action name
let labelDescriptors: (string | number | undefined | null)[]
if (d.actions?.[i]?.custom_name) {
labelDescriptors = [
d.actions?.[i]?.custom_name,
d.breakdownValues?.[i],
d.compareLabels?.[i],
]
} else if (d.labels?.[i]) {
labelDescriptors = [d.labels[i], d.compareLabels?.[i]]
} else {
labelDescriptors = [d.actions?.[i]?.name, d.breakdownValues?.[i], d.compareLabels?.[i]]
}
return labelDescriptors.filter((l) => !!l).join(' - ')
},
},
grid: {
Expand Down
Loading