-
Notifications
You must be signed in to change notification settings - Fork 170
feat: add bar charts #2924
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
feat: add bar charts #2924
Conversation
@@ -0,0 +1 @@ | |||
export { ChartBarWrapper, ChartBar } from './BarCharts'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
types are not exported from here
componentName="LineChart" | ||
componentDescription="A Line Chart component built on top of Recharts with Blade design system styling." | ||
figmaURL="https://www.figma.com/design/jubmQL9Z8V7881ayUD95ps/Blade-DSL?node-id=92678-188716&p=f&m=dev" | ||
figmaURL="https://github.com/razorpay/blade/blob/master/packages/blade/src/components/Charts/_decisions/decisions.md" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong url
/** | ||
* The layout of the bar chart. | ||
*/ | ||
layout?: 'horizontal' | 'vertical'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
layout?: 'horizontal' | 'vertical'; | |
orientation?: 'horizontal' | 'vertical'; |
we call it orientation in other components right 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you fix the file naming? "AreaChart" but "BarCharts" 🙈
* Chart data to be rendered | ||
*/ | ||
data: data[]; | ||
} & Partial<Omit<BaseBoxProps, keyof FlexboxProps | keyof GridProps>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you mean to use StyledPropsBlade here? why does it support type like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you want to give margin padding to chartWrapper it should support that, right ?
even we should be able to define width of the container in chartWrapper it self
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets do & BoxProps
then? its fine if flex and grid is supported as well. We can avoid creating too many different combinations of styled props on different components
export const VerticalBarChart: StoryFn<typeof ChartBar> = () => { | ||
return ( | ||
<div style={{ width: '100%', height: '500px' }}> | ||
<ChartBarWrapper data={chartData.slice(0, 5)} layout="vertical"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this horizontal and the default one is vertical?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you that's true. recharts follow the same nomenclature. so i have not changed it. (plus layout is related to chartwrapper not chart. i think that's why it is named that way.)
https://recharts.org/en-US/storybook
export const BarChartWithInformationalColorTheme: StoryFn<typeof ChartBar> = () => { | ||
return ( | ||
<div style={{ width: '100%', height: '500px' }}> | ||
<ChartBarWrapper data={chartData.slice(0, 5)} layout="vertical" colorTheme="default"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The story name says its Informational Color Theme but the prop says its colorTheme="default"
. Is the default color theme informational color theme?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed it to default color theme
const ChartBarWrapper: React.FC<ChartBarWrapperProps & TestID & DataAnalyticsAttribute> = ({ | ||
children, | ||
colorTheme = 'default', | ||
layout = 'horizontal', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Screen.Recording.2025-09-23.at.10.24.57.AM.mov
Can you check with RK if we're expected to not have any transition when we hover over the chart items? right now it feels too sudden
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i did try to add custom transition with css classes but is not working.
so rechart render entire child's so you see sudden opacity change in rechart colors. i am trying to find work around of this.
the main issue is we use rect
to show the white bar between bars in barGraph. which does not allow us to have animated properties for fill 😢
Screen.Recording.2025-09-23.at.5.05.45.PM.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol was able to find a workaround for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tried using classes but that was working so.
i used framer motion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets skip it for now if its too hacky and complex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added some minor comments. rest looks good
* The orientation of the bar chart. | ||
*/ | ||
layout?: 'horizontal' | 'vertical'; | ||
orientation?: 'horizontal' | 'vertical'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can go back to layout like we discussed in meeting since orientation and layout are 2 different things
@@ -1,5 +1,5 @@ | |||
import React from 'react'; | |||
import { ChartBarWrapper, ChartBar } from '../BarCharts'; | |||
import { ChartBarWrapper, ChartBar } from '../BarChart.web'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { ChartBarWrapper, ChartBar } from '../BarChart.web'; | |
import { ChartBarWrapper, ChartBar } from '../BarChart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets skip it for now if its too hacky and complex
const MotionRectangle = (props: MotionRectProps): React.ReactElement => { | ||
const { fillOpacity, barIndex, initialOpacity, ...restProps } = props; | ||
return ( | ||
<LazyMotion features={domAnimation}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LazyMotion is added by consumers in their applications. We shouldn't add it in components
const isVertical = layout === 'vertical'; | ||
const isVertical = orientation === 'vertical'; | ||
|
||
const getInitialOpacity = (): number => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets skip it for now maybe? code seems too complex for just 1 transition. We'll figure out later
* Chart data to be rendered | ||
*/ | ||
data: data[]; | ||
} & Partial<Omit<BaseBoxProps, keyof FlexboxProps | keyof GridProps>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets do & BoxProps
then? its fine if flex and grid is supported as well. We can avoid creating too many different combinations of styled props on different components
Description
Changes
Additional Information
Component Checklist