Skip to content

Commit

Permalink
[HIG-4752] make verbose tooltips the default (#8823)
Browse files Browse the repository at this point in the history
## Summary
- remove the "verbose" tooltip option and always show the key in the
tooltip, styled with a max width to avoid tooltip from becoming too
large
![Screen Shot 2024-06-20 at 5 08 35
PM](https://github.com/highlight/highlight/assets/86132398/b44711c3-99de-45ce-aaf6-eeee9923e6dc)

<!--
Ideally, there is an attached GitHub issue that will describe the "why".

If relevant, use this section to call out any additional information
you'd like to _highlight_ to the reviewer.
-->

## How did you test this change?
- clicktested locally
<!--
Frontend - Leave a screencast or a screenshot to visually describe the
changes.
-->

## Are there any deployment considerations?
- no
<!--
 Backend - Do we need to consider migrations or backfilling data?
-->

## Does this work require review from our design team?
- @julian-highlight 
<!--
 Request review from julian-highlight / our design team 
-->
  • Loading branch information
mayberryzane committed Jun 21, 2024
1 parent 43d0ddc commit f35dbbb
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 22 deletions.
1 change: 1 addition & 0 deletions frontend/src/__generated/index.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions frontend/src/pages/Graphing/components/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
isActive,
SeriesInfo,
TIMESTAMP_KEY,
TooltipConfig,
} from '@/pages/Graphing/components/Graph'

export type BarDisplay = 'Grouped' | 'Stacked'
Expand Down Expand Up @@ -78,9 +77,8 @@ export const BarChart = ({
showXAxis,
showYAxis,
showGrid,
verboseTooltip,
}: React.PropsWithChildren<
InnerChartProps<BarChartConfig> & SeriesInfo & AxisConfig & TooltipConfig
InnerChartProps<BarChartConfig> & SeriesInfo & AxisConfig
>) => {
const xAxisTickFormatter = getTickFormatter(xAxisMetric, data)
const yAxisTickFormatter = getTickFormatter(yAxisMetric, data)
Expand Down Expand Up @@ -170,7 +168,6 @@ export const BarChart = ({
xAxisMetric,
yAxisMetric,
yAxisFunction,
verboseTooltip,
)}
wrapperStyle={{ zIndex: 100 }}
cursor={{ fill: '#C8C7CB', fillOpacity: 0.5 }}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/Graphing/components/Graph.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const tooltipWrapper = style({

export const tooltipText = style({
lineHeight: '16px',
maxWidth: '300px',
})

export const tooltipDot = style({
Expand Down
25 changes: 13 additions & 12 deletions frontend/src/pages/Graphing/components/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ export interface AxisConfig {
showGrid?: boolean
}

export interface TooltipConfig {
verboseTooltip?: boolean
}

const strokeColors = [
'#0090FF',
'#D6409F',
Expand Down Expand Up @@ -257,17 +253,13 @@ export const getTickFormatter = (metric: string, data?: any[] | undefined) => {
}

export const getCustomTooltip =
(
xAxisMetric: string,
yAxisMetric: string,
yAxisFunction: string,
verbose?: boolean,
) =>
(xAxisMetric: string, yAxisMetric: string, yAxisFunction: string) =>
({ active, payload, label }: any) => {
const isValid = active && payload && payload.length
return (
<Box cssClass={style.tooltipWrapper}>
<Text
lines="1"
size="xxSmall"
weight="medium"
color="default"
Expand All @@ -289,13 +281,22 @@ export const getCustomTooltip =
cssClass={style.tooltipDot}
></Box>
<Text
lines="1"
size="xxSmall"
weight="medium"
color="default"
cssClass={style.tooltipText}
>
{p.name ? p.name + ': ' : yAxisFunction + ': '}
&nbsp;
</Text>
<Text
lines="1"
size="xxSmall"
weight="medium"
color="default"
cssClass={style.tooltipText}
>
{verbose &&
(p.name ? p.name + ': ' : yAxisFunction + ': ')}
{isValid && getTickFormatter(yAxisMetric)(p.value)}
</Text>
</Box>
Expand Down
5 changes: 1 addition & 4 deletions frontend/src/pages/Graphing/components/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
isActive,
SeriesInfo,
TIMESTAMP_KEY,
TooltipConfig,
} from '@/pages/Graphing/components/Graph'

export type LineNullHandling = 'Hidden' | 'Connected' | 'Zero'
Expand Down Expand Up @@ -56,10 +55,9 @@ export const LineChart = ({
showXAxis,
showYAxis,
showGrid,
verboseTooltip,
strokeColors,
}: React.PropsWithChildren<
InnerChartProps<LineChartConfig> & SeriesInfo & AxisConfig & TooltipConfig
InnerChartProps<LineChartConfig> & SeriesInfo & AxisConfig
>) => {
const xAxisTickFormatter = getTickFormatter(xAxisMetric, data)
const yAxisTickFormatter = getTickFormatter(yAxisMetric, data)
Expand Down Expand Up @@ -159,7 +157,6 @@ export const LineChart = ({
xAxisMetric,
yAxisMetric,
yAxisFunction,
verboseTooltip,
)}
cursor={{ stroke: '#C8C7CB', strokeDasharray: 4 }}
isAnimationActive={false}
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/pages/LogsPage/LogsHistogram/LogsHistogram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ const LogsHistogram = ({
}}
series={series}
showYAxis={false}
verboseTooltip
strokeColors={LEVEL_COLOR_MAPPING}
setTimeRange={onDatesChange}
>
Expand Down Expand Up @@ -187,7 +186,6 @@ const LogsHistogram = ({
}}
series={series}
showYAxis={false}
verboseTooltip
strokeColors={LEVEL_COLOR_MAPPING}
setTimeRange={onDatesChange}
>
Expand Down

0 comments on commit f35dbbb

Please sign in to comment.