diff --git a/frontend/src/queries/nodes/DataTable/renderColumnMeta.tsx b/frontend/src/queries/nodes/DataTable/renderColumnMeta.tsx index 1aee1ab0e87eb..f73466611bad4 100644 --- a/frontend/src/queries/nodes/DataTable/renderColumnMeta.tsx +++ b/frontend/src/queries/nodes/DataTable/renderColumnMeta.tsx @@ -11,12 +11,14 @@ import { getQueryFeatures, QueryFeature } from '~/queries/nodes/DataTable/queryF export interface ColumnMeta { title?: JSX.Element | string width?: number + align?: 'left' | 'right' | 'center' } export function renderColumnMeta(key: string, query: DataTableNode, context?: QueryContext): ColumnMeta { let width: number | undefined let title: JSX.Element | string | undefined const queryFeatures = getQueryFeatures(query.source) + let align: ColumnMeta['align'] if (isHogQLQuery(query.source)) { title = key @@ -43,6 +45,7 @@ export function renderColumnMeta(key: string, query: DataTableNode, context?: Qu ) : ( queryContextColumn?.title ?? column.replace('_', ' ') ) + align = queryContextColumn?.align } else if (key === 'person.$delete') { title = '' width = 0 @@ -71,5 +74,6 @@ export function renderColumnMeta(key: string, query: DataTableNode, context?: Qu return { title, ...(typeof width !== 'undefined' ? { width } : {}), + ...(align ? { align } : {}), } } diff --git a/frontend/src/queries/types.ts b/frontend/src/queries/types.ts index 3825db4f766c9..03e80d7490fe6 100644 --- a/frontend/src/queries/types.ts +++ b/frontend/src/queries/types.ts @@ -32,4 +32,5 @@ interface QueryContextColumn { title?: string renderTitle?: QueryContextColumnTitleComponent render?: QueryContextColumnComponent + align?: 'left' | 'right' | 'center' // default is left } diff --git a/frontend/src/scenes/web-analytics/WebDashboard.tsx b/frontend/src/scenes/web-analytics/WebDashboard.tsx index b91d2ad611abc..ba91a95fe856e 100644 --- a/frontend/src/scenes/web-analytics/WebDashboard.tsx +++ b/frontend/src/scenes/web-analytics/WebDashboard.tsx @@ -12,22 +12,14 @@ import { DateFilter } from 'lib/components/DateFilter/DateFilter' const PercentageCell: QueryContextColumnComponent = ({ value }) => { if (typeof value === 'number') { - return ( -
- {`${(value * 100).toFixed(1)}%`} -
- ) + return {`${(value * 100).toFixed(1)}%`} } else { return null } } const NumericCell: QueryContextColumnComponent = ({ value }) => { - return ( -
- {String(value)} -
- ) + return {typeof value === 'number' ? value.toLocaleString() : String(value)} } const BreakdownValueTitle: QueryContextColumnTitleComponent = (props) => { @@ -115,14 +107,17 @@ const queryContext: QueryContext = { bounce_rate: { title: 'Bounce Rate', render: PercentageCell, + align: 'right', }, views: { title: 'Views', render: NumericCell, + align: 'right', }, visitors: { title: 'Visitors', render: NumericCell, + align: 'right', }, }, }