Skip to content

Commit

Permalink
fix: prevent invisible tooltips for the zero value of legendOpacity f…
Browse files Browse the repository at this point in the history
…rom the api
  • Loading branch information
TCL735 committed Sep 24, 2020
1 parent 651f2a6 commit 0d6d20a
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 36 deletions.
16 changes: 10 additions & 6 deletions src/shared/components/BandPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
BAND_LINE_WIDTH,
BAND_SHADE_OPACITY,
LEGEND_OPACITY_DEFAULT,
LEGEND_OPACITY_MINIMUM,
VIS_THEME,
VIS_THEME_LIGHT,
} from 'src/shared/constants'
Expand Down Expand Up @@ -107,12 +108,15 @@ const BandPlot: FC<Props> = ({
[selectedFunctions, upperColumnName, mainColumn, lowerColumnName]
)

const tooltipOpacity = useMemo(() => {
if (isFlagEnabled('legendOrientation')) {
return legendOpacity
}
return LEGEND_OPACITY_DEFAULT
}, [legendOpacity])
const tooltipOpacity = Math.max(
useMemo(() => {
if (isFlagEnabled('legendOrientation')) {
return legendOpacity
}
return LEGEND_OPACITY_DEFAULT
}, [legendOpacity]),
LEGEND_OPACITY_MINIMUM
)

const tooltipOrientationThreshold = useMemo(() => {
if (isFlagEnabled('legendOrientation')) {
Expand Down
16 changes: 10 additions & 6 deletions src/shared/components/HeatmapPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {getFormatter} from 'src/shared/utils/vis'
// Constants
import {
LEGEND_OPACITY_DEFAULT,
LEGEND_OPACITY_MINIMUM,
VIS_THEME,
VIS_THEME_LIGHT,
} from 'src/shared/constants'
Expand Down Expand Up @@ -60,12 +61,15 @@ const HeatmapPlot: FunctionComponent<Props> = ({
}) => {
const columnKeys = table.columnKeys

const tooltipOpacity = useMemo(() => {
if (isFlagEnabled('legendOrientation')) {
return legendOpacity
}
return LEGEND_OPACITY_DEFAULT
}, [legendOpacity])
const tooltipOpacity = Math.max(
useMemo(() => {
if (isFlagEnabled('legendOrientation')) {
return legendOpacity
}
return LEGEND_OPACITY_DEFAULT
}, [legendOpacity]),
LEGEND_OPACITY_MINIMUM
)

const tooltipOrientationThreshold = useMemo(() => {
if (isFlagEnabled('legendOrientation')) {
Expand Down
16 changes: 10 additions & 6 deletions src/shared/components/HistogramPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {getFormatter} from 'src/shared/utils/vis'
// Constants
import {
LEGEND_OPACITY_DEFAULT,
LEGEND_OPACITY_MINIMUM,
VIS_THEME,
VIS_THEME_LIGHT,
} from 'src/shared/constants'
Expand Down Expand Up @@ -49,12 +50,15 @@ const HistogramPlot: FunctionComponent<Props> = ({
}) => {
const columnKeys = table.columnKeys

const tooltipOpacity = useMemo(() => {
if (isFlagEnabled('legendOrientation')) {
return legendOpacity
}
return LEGEND_OPACITY_DEFAULT
}, [legendOpacity])
const tooltipOpacity = Math.max(
useMemo(() => {
if (isFlagEnabled('legendOrientation')) {
return legendOpacity
}
return LEGEND_OPACITY_DEFAULT
}, [legendOpacity]),
LEGEND_OPACITY_MINIMUM
)

const tooltipOrientationThreshold = useMemo(() => {
if (isFlagEnabled('legendOrientation')) {
Expand Down
16 changes: 10 additions & 6 deletions src/shared/components/MosaicPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {getFormatter, defaultXColumn, mosaicYcolumn} from 'src/shared/utils/vis'
// Constants
import {
LEGEND_OPACITY_DEFAULT,
LEGEND_OPACITY_MINIMUM,
VIS_THEME,
VIS_THEME_LIGHT,
} from 'src/shared/constants'
Expand Down Expand Up @@ -65,12 +66,15 @@ const MosaicPlot: FunctionComponent<Props> = ({
}
const columnKeys = table.columnKeys

const tooltipOpacity = useMemo(() => {
if (isFlagEnabled('legendOrientation')) {
return legendOpacity
}
return LEGEND_OPACITY_DEFAULT
}, [legendOpacity])
const tooltipOpacity = Math.max(
useMemo(() => {
if (isFlagEnabled('legendOrientation')) {
return legendOpacity
}
return LEGEND_OPACITY_DEFAULT
}, [legendOpacity]),
LEGEND_OPACITY_MINIMUM
)

const tooltipOrientationThreshold = useMemo(() => {
if (isFlagEnabled('legendOrientation')) {
Expand Down
16 changes: 10 additions & 6 deletions src/shared/components/ScatterPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
// Constants
import {
LEGEND_OPACITY_DEFAULT,
LEGEND_OPACITY_MINIMUM,
VIS_THEME,
VIS_THEME_LIGHT,
} from 'src/shared/constants'
Expand Down Expand Up @@ -70,12 +71,15 @@ const ScatterPlot: FunctionComponent<Props> = ({

const columnKeys = table.columnKeys

const tooltipOpacity = useMemo(() => {
if (isFlagEnabled('legendOrientation')) {
return legendOpacity
}
return LEGEND_OPACITY_DEFAULT
}, [legendOpacity])
const tooltipOpacity = Math.max(
useMemo(() => {
if (isFlagEnabled('legendOrientation')) {
return legendOpacity
}
return LEGEND_OPACITY_DEFAULT
}, [legendOpacity]),
LEGEND_OPACITY_MINIMUM
)

const tooltipOrientationThreshold = useMemo(() => {
if (isFlagEnabled('legendOrientation')) {
Expand Down
16 changes: 10 additions & 6 deletions src/shared/components/XYPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
// Constants
import {
LEGEND_OPACITY_DEFAULT,
LEGEND_OPACITY_MINIMUM,
VIS_THEME,
VIS_THEME_LIGHT,
} from 'src/shared/constants'
Expand Down Expand Up @@ -85,12 +86,15 @@ const XYPlot: FC<Props> = ({
},
theme,
}) => {
const tooltipOpacity = useMemo(() => {
if (isFlagEnabled('legendOrientation')) {
return legendOpacity
}
return LEGEND_OPACITY_DEFAULT
}, [legendOpacity])
const tooltipOpacity = Math.max(
useMemo(() => {
if (isFlagEnabled('legendOrientation')) {
return legendOpacity
}
return LEGEND_OPACITY_DEFAULT
}, [legendOpacity]),
LEGEND_OPACITY_MINIMUM
)

const tooltipOrientationThreshold = useMemo(() => {
if (isFlagEnabled('legendOrientation')) {
Expand Down

0 comments on commit 0d6d20a

Please sign in to comment.