Skip to content

Commit

Permalink
Fix Tooltip styling for charts (#11)
Browse files Browse the repository at this point in the history
* fix: add a default gap for tooltip labels between label and value

* fix: allow tooltip style overrides for SymbiosisAreaChart

* chore: enhance stories to showcase tooltip style overrides
  • Loading branch information
DGiannaris authored Sep 12, 2024
1 parent 63be826 commit 35d8dfc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@ export const CustomUI: Story = {
{...args}
className="bg-slate-400 [&_.recharts-cartesian-axis-tick_text]:fill-white [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-white"
legendClassName="text-white"
tooltipClassName="rounded-none border-green-400 border-2"
/>
);
},
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/Charts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const ChartTooltipContent = React.forwardRef<
)}
<div
className={cn(
"flex flex-1 justify-between leading-none text-inherit",
"flex flex-1 justify-between leading-none text-inherit gap-2",
nestLabel ? "items-end" : "items-center",
)}
>
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/components/SymbiosisAreaChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const SymbiosisAreaChart = ({
tooltipLabelFormatter,
className,
legendClassName,
tooltipClassName,
}: SymbiosisAreaChartProps) => {
const defaultTickFormatter = React.useCallback((value: string) => {
const date = new Date(value);
Expand Down Expand Up @@ -48,6 +49,7 @@ const SymbiosisAreaChart = ({
<Chart.TooltipContent
labelFormatter={tooltipLabelFormatter ?? defaultTooltipLabelFormatter}
indicator="dot"
className={tooltipClassName}
/>
}
/>
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/components/SymbiosisAreaChart/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export type SymbiosisAreaChartProps = {
tooltipLabelFormatter?: (value: string) => string;
className?: string;
legendClassName?: string;
tooltipClassName?: string;
};

0 comments on commit 35d8dfc

Please sign in to comment.