Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Tooltip Overlapping Charts due to a low z-index #1087

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
2 changes: 1 addition & 1 deletion src/components/chart-elements/AreaChart/AreaChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ const AreaChart = React.forwardRef<HTMLDivElement, AreaChartProps>((props, ref)
)}
</YAxis>
<Tooltip
wrapperStyle={{ outline: "none" }}
wrapperStyle={{ outline: "none", zIndex: 100 }}
isAnimationActive={false}
cursor={{ stroke: "#d1d5db", strokeWidth: 1 }}
content={
Expand Down
2 changes: 1 addition & 1 deletion src/components/chart-elements/BarChart/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>((props, ref) =>
</YAxis>
)}
<Tooltip
wrapperStyle={{ outline: "none" }}
wrapperStyle={{ outline: "none", zIndex: 100 }}
isAnimationActive={false}
cursor={{ fill: "#d1d5db", opacity: "0.15" }}
content={
Expand Down
2 changes: 1 addition & 1 deletion src/components/chart-elements/DonutChart/DonutChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const DonutChart = React.forwardRef<HTMLDivElement, DonutChartProps>((props, ref
/>
) : null} */}
<Tooltip
wrapperStyle={{ outline: "none" }}
wrapperStyle={{ outline: "none", zIndex: 100 }}
isAnimationActive={false}
content={
showTooltip ? (
Expand Down
1 change: 1 addition & 0 deletions src/components/chart-elements/FunnelChart/FunnelChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ const FunnelChartPrimitive = React.forwardRef<HTMLDivElement, FunnelChartProps>(
className={tremorTwMerge(
"absolute top-0 pointer-events-none",
tooltip.data ? "visible" : "hidden",
"z-50",
)}
tabIndex={-1}
role="dialog"
Expand Down
2 changes: 1 addition & 1 deletion src/components/chart-elements/LineChart/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ const LineChart = React.forwardRef<HTMLDivElement, LineChartProps>((props, ref)
)}
</YAxis>
<Tooltip
wrapperStyle={{ outline: "none" }}
wrapperStyle={{ outline: "none", zIndex: 100 }}
isAnimationActive={false}
cursor={{ stroke: "#d1d5db", strokeWidth: 1 }}
content={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ const ScatterChart = React.forwardRef<HTMLDivElement, ScatterChartProps>((props,
</YAxis>
) : null}
<Tooltip
wrapperStyle={{ outline: "none" }}
wrapperStyle={{ outline: "none", zIndex: 100 }}
isAnimationActive={false}
cursor={{ stroke: "#d1d5db", strokeWidth: 1 }}
content={
Expand Down
36 changes: 36 additions & 0 deletions src/stories/chart-elements/BarChart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
longBaseChartData,
longIndexBaseChartData,
simpleBaseChartWithNegativeValues,
longDataName,
} from "./helpers/testData";

const meta: Meta<typeof BarChart> = {
Expand Down Expand Up @@ -387,3 +388,38 @@ export const AxisLabels: Story = {
yAxisLabel: "Amount (USD)",
},
};

export function LongTooltip() {
return (
<>
<div className="grid grid-cols-2">
<div className="flex flex-wrap">
<BarChart
className="mt-6"
data={longDataName}
index="name"
categories={[
'Group A',
'Group B',
'Group C',
]}
colors={['blue', 'teal', 'amber']}
/>
</div>
<div className="flex flex-wrap">
<BarChart
className="mt-6"
data={longDataName}
index="name"
categories={[
'Group A',
'Group B',
'Group C',
]}
colors={['blue', 'teal', 'amber']}
/>
</div>
</div>
</>
);
}
9 changes: 9 additions & 0 deletions src/stories/chart-elements/helpers/testData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1751,3 +1751,12 @@ export const singleAndMultipleData = [
Sales: 3612,
},
];

export const longDataName = [
{
name: 'Very very looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong Topic 1',
'Group A': 890,
'Group B': 338,
'Group C': 538,
},
];
Loading