Skip to content

Commit

Permalink
Turn the scale picker into a segmented button
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes committed Jun 19, 2024
1 parent c85d199 commit 87b7a7b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 23 deletions.
12 changes: 10 additions & 2 deletions frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { ReactNode } from 'react'
import { funnelDataLogic } from 'scenes/funnels/funnelDataLogic'
import { axisLabel } from 'scenes/insights/aggregationAxisFormat'
import { PercentStackViewFilter } from 'scenes/insights/EditorFilters/PercentStackViewFilter'
import { ScalePicker } from 'scenes/insights/EditorFilters/ScalePicker'
import { ShowLegendFilter } from 'scenes/insights/EditorFilters/ShowLegendFilter'
import { ValueOnSeriesFilter } from 'scenes/insights/EditorFilters/ValueOnSeriesFilter'
import { YAxisScaleSettings } from 'scenes/insights/EditorFilters/YAxisScaleSettings'
import { InsightDateFilter } from 'scenes/insights/filters/InsightDateFilter'
import { RetentionMeanCheckbox } from 'scenes/insights/filters/RetentionMeanCheckbox'
import { RetentionReferencePicker } from 'scenes/insights/filters/RetentionReferencePicker'
Expand Down Expand Up @@ -50,6 +50,7 @@ export function InsightDisplayConfig(): JSX.Element {
showPercentStackView,
supportsPercentStackView,
yAxisScaleType,
isNonTimeSeriesDisplay,
} = useValues(insightVizDataLogic(insightProps))
const { isTrendsFunnel, isStepsFunnel, isTimeToConvertFunnel, isEmptyFunnel } = useValues(
funnelDataLogic(insightProps)
Expand All @@ -74,7 +75,6 @@ export function InsightDisplayConfig(): JSX.Element {
...(supportsValueOnSeries ? [{ label: () => <ValueOnSeriesFilter /> }] : []),
...(supportsPercentStackView ? [{ label: () => <PercentStackViewFilter /> }] : []),
...(hasLegend ? [{ label: () => <ShowLegendFilter /> }] : []),
...(isTrends ? [{ label: () => <YAxisScaleSettings /> }] : []),
],
},
]
Expand All @@ -87,6 +87,14 @@ export function InsightDisplayConfig(): JSX.Element {
},
]
: []),
...(!isNonTimeSeriesDisplay && isTrends
? [
{
title: 'Y-axis scale',
items: [{ label: () => <ScalePicker /> }],
},
]
: []),
...(mightContainFractionalNumbers && isTrends
? [
{
Expand Down
25 changes: 25 additions & 0 deletions frontend/src/scenes/insights/EditorFilters/ScalePicker.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { LemonSegmentedButton } from '@posthog/lemon-ui'
import { useActions, useValues } from 'kea'
import { insightLogic } from 'scenes/insights/insightLogic'

import { insightVizDataLogic } from '../insightVizDataLogic'

export function ScalePicker(): JSX.Element | null {
const { insightProps } = useValues(insightLogic)
const { yAxisScaleType } = useValues(insightVizDataLogic(insightProps))
const { updateInsightFilter } = useActions(insightVizDataLogic(insightProps))

return (
<LemonSegmentedButton
className="pb-2 px-2"
onChange={(value) => updateInsightFilter({ yAxisScaleType: value })}
value={yAxisScaleType || 'linear'}
options={[
{ value: 'linear', label: 'Linear' },
{ value: 'log10', label: 'Logarithmic' },
]}
size="small"
fullWidth
/>
)
}
21 changes: 0 additions & 21 deletions frontend/src/scenes/insights/EditorFilters/YAxisScaleSettings.tsx

This file was deleted.

1 change: 1 addition & 0 deletions frontend/src/scenes/insights/aggregationAxisFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const axisLabel = (chartDisplayType: ChartDisplayType | null | undefined)
case ChartDisplayType.ActionsLineGraph:
case ChartDisplayType.ActionsLineGraphCumulative:
case ChartDisplayType.ActionsBar:
case ChartDisplayType.ActionsAreaGraph:
return 'Y-axis unit'
case ChartDisplayType.ActionsBarValue:
return 'X-axis unit'
Expand Down

0 comments on commit 87b7a7b

Please sign in to comment.