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

[charts] Add label to be displayed inside bars in BarChart #12988

Merged
merged 49 commits into from
May 21, 2024
Merged
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
84afe67
Add initial BarElementLabel
JCQuintas May 16, 2024
2ccbfba
Ignore types
JCQuintas May 16, 2024
02c11b7
Make label not animated on exit/leave
JCQuintas May 16, 2024
67bdd1d
Pass slots down
JCQuintas May 16, 2024
5efaa78
Adjust min/max size
JCQuintas May 16, 2024
076f0af
Add element to prevent unnecessary computation
JCQuintas May 16, 2024
ae8ae25
Pass typography settings to bet label
JCQuintas May 16, 2024
be8ae02
Move bar label to its own folder
JCQuintas May 16, 2024
cf858c5
Start renaming props
JCQuintas May 16, 2024
553952d
Work with barlabel func
JCQuintas May 16, 2024
d4e09e4
fix types
JCQuintas May 16, 2024
7e518d9
Enable highlight and fade
JCQuintas May 16, 2024
32cf323
Move label types to folder
JCQuintas May 16, 2024
83e3d17
Remove unused props
JCQuintas May 16, 2024
e49de5b
Inline barlabel func type
JCQuintas May 16, 2024
4aad244
barrel export
JCQuintas May 16, 2024
6b7ff18
Update packages/x-charts/src/BarChart/BarLabel/BarLabel.tsx
JCQuintas May 16, 2024
df7e5c7
Add theme augmentation
JCQuintas May 16, 2024
acd74c4
Move barLabel to series & add value/formattedValue behavior
JCQuintas May 16, 2024
39cd974
Remove spacing
JCQuintas May 16, 2024
a993ec6
Revert "Remove spacing"
JCQuintas May 16, 2024
5b8556f
Revert "Move barLabel to series & add value/formattedValue behavior"
JCQuintas May 16, 2024
5e94ec3
Apply code suggestions
JCQuintas May 16, 2024
36ee44f
Add simple "value" option
JCQuintas May 16, 2024
f98f428
fix slots classes
JCQuintas May 16, 2024
b61b5cc
Remove clsx
JCQuintas May 16, 2024
a959868
Add docs
JCQuintas May 16, 2024
fdad2bc
feat: Add BarLabel component to React Bar chart
JCQuintas May 16, 2024
0d0f802
Fix getBarLabel return undefined
JCQuintas May 16, 2024
6d4f3e9
Run scripts
JCQuintas May 16, 2024
f952f71
Run docsapi
JCQuintas May 16, 2024
010c1e6
Update packages/x-charts/src/BarChart/BarPlot.tsx
JCQuintas May 16, 2024
a0dafc2
Add skipanimation back
JCQuintas May 16, 2024
79b2cb7
Update enter/leave style
JCQuintas May 16, 2024
6e8fa78
Fix typo and doc changes
JCQuintas May 16, 2024
cf23a07
Re-use type from BarLabelProps
JCQuintas May 16, 2024
36efc62
Fix typescript error
JCQuintas May 16, 2024
5cd058f
Cleanup exported types
JCQuintas May 16, 2024
9efec8d
Remove bar-label.js
JCQuintas May 16, 2024
32ce464
Add proper svg text element
JCQuintas May 16, 2024
b25d8ac
index.tsx to index.ts
JCQuintas May 16, 2024
6a70447
Use immediate exports
JCQuintas May 16, 2024
2488988
Export BarLabel for users
JCQuintas May 16, 2024
f89cd77
Improve user api
JCQuintas May 16, 2024
e59975c
Fix proptypes
JCQuintas May 16, 2024
4d4a0f1
rename types file
JCQuintas May 21, 2024
205a707
Remove barLabel from sparkline
JCQuintas May 21, 2024
d1da5f2
Pass ownerstate props as direct props to final component
JCQuintas May 21, 2024
c4fdb79
Refactor BarLabel component PropTypes
JCQuintas May 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Ignore types
JCQuintas committed May 16, 2024
commit 2ccbfbae41eda5bab4ddf166905a2277b8a521a5
12 changes: 7 additions & 5 deletions packages/x-charts/src/BarChart/BarPlot.tsx
Original file line number Diff line number Diff line change
@@ -335,11 +335,13 @@ function BarPlot(props: BarPlotProps) {
id={seriesId}
dataIndex={dataIndex}
color={color}
style={{
...style,
x: to([style.x, style.width], (x, width) => (x ?? 0) + width / 2),
y: to([style.y, style.height], (x, width) => (x ?? 0) + width / 2),
}}
style={
{
...style,
x: to([(style as any).x, (style as any).width], (x, width) => (x ?? 0) + width / 2),
y: to([(style as any).y, (style as any).height], (x, width) => (x ?? 0) + width / 2),
} as any
}
// When value is 0 we don't want to show the label either
labelText={value ? value.toString() : null}
/>