forked from recharts/recharts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…echarts#4390) This adds support for percentage values for `barSize` as a workaround for recharts#3640. See also my comment at recharts#3640 (comment) This is not really the perfect solution, but it allows users to at least have a good workaround. If you know how many data points your axis domain expects, you can hard-code `barSize` to `100%/numberOfDataPoints` (e.g. `'10%'` for 10 data points). You can also combine this with the automatic calculation, e.g. `barSize={data.length > 1 ? undefined : '10%'}`. ``` <BarChart width={500} height={300} data={[[4.5, 10]]} barSize="30%" /* When there's only one data point on a numerical domain, we cannot automatically calculate the bar size */ margin={{ top: 5, right: 30, left: 20, bottom: 5, }} > <XAxis dataKey={v => v[0]} type="number" domain={[0, 10]} /> <YAxis /> <Tooltip /> <CartesianGrid strokeDasharray="3 3" /> <Bar dataKey={v => v[1]} /> </BarChart> ``` ![Screenshot 2024-04-04 at 16 31 49](https://github.com/recharts/recharts/assets/898549/d4fcbdad-d6ae-468d-b522-fb008c20a2a4) # Conflicts: # src/chart/generateCategoricalChart.tsx
- Loading branch information
Showing
6 changed files
with
95 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters