-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[@mantine/charts] BarChart: Fix incorrect labels positions in some ca…
…ses (#7160) * [@mantine/charts] BarChart: Use `LabelList` instead of `BarLabel`, and add `valueLabelProps` option support. * [@mantine/charts] BarChart: Simplify position logic for LabelList based on orientation * [@mantine/charts] prettier format
- Loading branch information
Showing
8 changed files
with
98 additions
and
38 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
53 changes: 53 additions & 0 deletions
53
packages/@docs/demos/src/demos/charts/BarChart/BarChart.demo.valueLabelProps.tsx
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { BarChart } from '@mantine/charts'; | ||
import { MantineDemo } from '@mantinex/demo'; | ||
import { data, dataCode } from './_data'; | ||
|
||
const code = ` | ||
import { BarChart } from '@mantine/charts'; | ||
import { data } from './data'; | ||
function Demo() { | ||
return ( | ||
<BarChart | ||
h={300} | ||
data={data} | ||
dataKey="month" | ||
valueFormatter={(value) => new Intl.NumberFormat('en-US').format(value)} | ||
withBarValueLabel | ||
valueLabelProps={{ position: 'inside', fill: 'white' }} | ||
series={[ | ||
{ name: 'Smartphones', color: 'violet.6' }, | ||
{ name: 'Laptops', color: 'blue.6' }, | ||
{ name: 'Tablets', color: 'teal.6' }, | ||
]} | ||
/> | ||
); | ||
} | ||
`; | ||
|
||
function Demo() { | ||
return ( | ||
<BarChart | ||
h={300} | ||
data={data} | ||
dataKey="month" | ||
valueFormatter={(value) => new Intl.NumberFormat('en-US').format(value)} | ||
withBarValueLabel | ||
valueLabelProps={{ position: 'inside', fill: 'white' }} | ||
series={[ | ||
{ name: 'Smartphones', color: 'violet.6' }, | ||
{ name: 'Laptops', color: 'blue.6' }, | ||
{ name: 'Tablets', color: 'teal.6' }, | ||
]} | ||
/> | ||
); | ||
} | ||
|
||
export const valueLabelProps: MantineDemo = { | ||
type: 'code', | ||
component: Demo, | ||
code: [ | ||
{ code, language: 'tsx', fileName: 'Demo.tsx' }, | ||
{ code: dataCode, language: 'tsx', fileName: 'data.ts' }, | ||
], | ||
}; |
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 was deleted.
Oops, something went wrong.
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