Skip to content

Commit

Permalink
fix: BarChart tooltip vertical (#33)
Browse files Browse the repository at this point in the history
* update bar chart tooltip

* update gap

* remove radius

* update barcategorygap

* Update changelog.md
  • Loading branch information
severinlandolt authored Jun 11, 2024
1 parent 2d16feb commit 9d2ba1e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/components/BarChart/BarChart.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Tremor Raw BarChart [v0.0.0]
// Tremor Raw BarChart [v0.0.1]

"use client"

Expand Down Expand Up @@ -672,6 +672,7 @@ const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>(
}}
stackOffset={type === "percent" ? "expand" : undefined}
layout={layout}
barCategoryGap={barCategoryGap}
>
{showGridLines ? (
<CartesianGrid
Expand Down Expand Up @@ -782,7 +783,10 @@ const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>(
animationDuration={100}
cursor={{ fill: "#d1d5db", opacity: "0.15" }}
offset={20}
position={{ y: 0 }}
position={{
y: layout === "horizontal" ? 0 : undefined,
x: layout === "horizontal" ? undefined : yAxisWidth + 20,
}}
content={
showTooltip ? (
({ active, payload, label }) => (
Expand Down Expand Up @@ -840,7 +844,6 @@ const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>(
renderShape(props, activeBar, activeLegend, layout)
}
onClick={onBarClick}
radius={20}
/>
))}
</RechartsBarChart>
Expand Down
6 changes: 6 additions & 0 deletions src/components/BarChart/barchart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ export const WithLargeTickGap: Story = {
},
}

export const WithBarCategoryGap: Story = {
args: {
barCategoryGap: "30%",
},
}

export const WithLayoutVertical: Story = {
args: {
categories: ["SolarCells"],
Expand Down
5 changes: 4 additions & 1 deletion src/components/BarChart/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Tremor Raw BarChart Changelog

## 0.0.0
## 0.0.1

### Changes

- Fix: Dynamic tooltip position on vertical layout
- Fix: `barCategoryGap` propagation

0 comments on commit 9d2ba1e

Please sign in to comment.