Skip to content

Commit

Permalink
fix: insights tooltip percentage (#17386)
Browse files Browse the repository at this point in the history
* fix: insights tooltip percentage

* Update UI snapshots for `chromium` (1)

* Empty commit to run checks

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
Gilbert09 and github-actions[bot] authored Sep 13, 2023
1 parent aace87d commit 2ce6105
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions frontend/src/scenes/insights/views/LineGraph/LineGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { lineGraphLogic } from 'scenes/insights/views/LineGraph/lineGraphLogic'
import { TooltipConfig } from 'scenes/insights/InsightTooltip/insightTooltipUtils'
import { groupsModel } from '~/models/groupsModel'
import { ErrorBoundary } from '~/layout/ErrorBoundary'
import { formatPercentStackAxisValue } from 'scenes/insights/aggregationAxisFormat'
import { formatAggregationAxisValue, formatPercentStackAxisValue } from 'scenes/insights/aggregationAxisFormat'
import { insightLogic } from 'scenes/insights/insightLogic'
import { useResizeObserver } from 'lib/hooks/useResizeObserver'
import { PieChart } from 'scenes/insights/views/LineGraph/PieChart'
Expand Down Expand Up @@ -471,8 +471,27 @@ export function LineGraph_({
}}
renderCount={
tooltipConfig?.renderCount ||
((value: number): string =>
formatPercentStackAxisValue(trendsFilter, value, isPercentStackView))
((value: number): string => {
if (!isPercentStackView) {
return formatAggregationAxisValue(trendsFilter, value)
}

const total = seriesData.reduce((a, b) => a + b.count, 0)
const percentageLabel: number = parseFloat(
((value / total) * 100).toFixed(1)
)

const isNaN = Number.isNaN(percentageLabel)

if (isNaN) {
return formatAggregationAxisValue(trendsFilter, value)
}

return `${formatAggregationAxisValue(
trendsFilter,
value
)} (${percentageLabel}%)`
})
}
entitiesAsColumnsOverride={formula ? false : undefined}
hideInspectActorsSection={!onClick || !showPersonsModal}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2ce6105

Please sign in to comment.