Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
e7e3ef4
feat: line chart pocs
tewarig Aug 7, 2025
4513e87
fix: lint
tewarig Aug 7, 2025
f38b3ec
chore: pie charts
tewarig Aug 7, 2025
76ed2c6
feat: add area charts
tewarig Aug 11, 2025
27f260f
Merge remote-tracking branch 'origin' into feat/recharts-poc
tewarig Aug 26, 2025
b2e5fae
feat: add line chart
tewarig Aug 26, 2025
26c822b
refactor: charts and base components
tewarig Aug 26, 2025
8310cb2
chore: code refactor
tewarig Aug 26, 2025
b14f469
fix: line chart styling and offset colors
tewarig Aug 27, 2025
9e0f88f
fix: legend color in recharts
tewarig Aug 27, 2025
de5d214
chore: update legend styles
tewarig Aug 27, 2025
d3fed65
fix: add color in reference line
tewarig Aug 27, 2025
da0d881
chore: update color tokens
tewarig Aug 27, 2025
f177c6f
chore: add lable in chart
tewarig Aug 28, 2025
9b45b94
fix: spacing
tewarig Aug 28, 2025
5f2530e
fix: add custom label
tewarig Aug 28, 2025
1aa02c5
feat: add colors
tewarig Aug 28, 2025
7efc234
feat: support new colors in line charts & colors update
tewarig Aug 28, 2025
263731a
chore: update color logic & exmaple color values
tewarig Aug 28, 2025
ab4bd23
chore: update blade color theme
tewarig Aug 28, 2025
b60d9a9
refactor: reference line props
tewarig Aug 28, 2025
ee3d062
fix: more color props
tewarig Aug 28, 2025
1311652
fix: line chart errors
tewarig Aug 28, 2025
67d5518
fix: ts errors
tewarig Aug 28, 2025
201f28d
chore: more update
tewarig Aug 28, 2025
535ca53
chore: more style changes
tewarig Aug 28, 2025
5d23d9c
chore: change vars
tewarig Aug 28, 2025
806a8fd
feat: add line charts
tewarig Aug 28, 2025
3cf1ba3
chore: update cursor values
tewarig Aug 28, 2025
5282030
chore: revert changes
tewarig Aug 29, 2025
cf58f98
chore: update spacing
tewarig Aug 29, 2025
261e123
feat: inital code for area charts
tewarig Aug 31, 2025
1338253
chore: area charts
tewarig Aug 31, 2025
8524a8c
chore: code refactor
tewarig Aug 31, 2025
fe8a5e8
chore: refactor responsive container
tewarig Aug 31, 2025
82b5f1a
chore: added more example
tewarig Aug 31, 2025
0a48c83
chore: update types
tewarig Aug 31, 2025
68899ea
chore: make x and y optional
tewarig Aug 31, 2025
3a7547d
chore: add x and y props
tewarig Aug 31, 2025
41f667f
chore: update area charts
tewarig Aug 31, 2025
3dd2bda
refactor: area chart changes
tewarig Sep 1, 2025
f246bb1
feat: initial commit
tewarig Sep 1, 2025
baa2c22
chore: add spacing b/w charts
tewarig Sep 1, 2025
c28022e
fix: gap b/w bar charts
tewarig Sep 1, 2025
8de429c
chore: update example
tewarig Sep 1, 2025
36fa5d6
chore: remove cursor from tooltip
tewarig Sep 2, 2025
36f1c12
fix: make animation work
tewarig Sep 2, 2025
e8dda48
chore: update final review
tewarig Sep 2, 2025
26bbf54
feat: update color theme token
tewarig Sep 8, 2025
85588b6
feat: expose color theme
tewarig Sep 8, 2025
0aa935f
feat: update line charts
tewarig Sep 8, 2025
016e9e3
fix: update snaps
tewarig Sep 8, 2025
eaaf45f
chore: add review notes
tewarig Sep 8, 2025
e1f8a97
fix: change to vairables
tewarig Sep 8, 2025
befed08
chore: more changes
tewarig Sep 8, 2025
67696cf
Create calm-peas-work.md
tewarig Sep 8, 2025
a221c55
Merge remote-tracking branch 'origin' into feat/add-area-charts
tewarig Sep 8, 2025
fc7d69a
Merge remote-tracking branch 'origin' into feat/add-line-charts
tewarig Sep 8, 2025
1a00f8f
Merge branch 'feat/add-line-charts' into feat/add-area-charts
tewarig Sep 8, 2025
23e3cc0
chore: more code changes
tewarig Sep 8, 2025
9d76c53
Merge branch 'feat/add-line-charts' into feat/add-area-charts
tewarig Sep 8, 2025
f5dae27
fix: update name
tewarig Sep 8, 2025
dbf3912
feat: update area charts to support color tokens
tewarig Sep 8, 2025
1c0388a
Merge branch 'feat/add-area-charts' into feat/add-bar-charts
tewarig Sep 8, 2025
c4f1e3a
feat: update bar charts for review
tewarig Sep 8, 2025
e2e367b
chore: errors in charts
tewarig Sep 8, 2025
df8de7e
chore: update animation token and colors
tewarig Sep 8, 2025
1992e99
fea: update bar charts
tewarig Sep 8, 2025
dd70df0
Merge remote-tracking branch 'origin' into feat/add-line-charts
tewarig Sep 9, 2025
1f0df67
Revert "feat: add area charts" (#2936)
tewarig Sep 9, 2025
a5d6fd7
Merge branch 'feat/add-line-charts' into feat/add-area-charts
tewarig Sep 9, 2025
c5005a5
Merge branch 'feat/add-area-charts' into feat/add-bar-charts
tewarig Sep 9, 2025
bdb7bc7
chore: update change set
tewarig Sep 10, 2025
d70e2ab
review: update export types
tewarig Sep 10, 2025
62efbbe
chore: update example
tewarig Sep 10, 2025
049e0e0
fix: update baseChart components
tewarig Sep 10, 2025
c58ff8b
chore: update forecasted data
tewarig Sep 10, 2025
3428965
Merge branch 'feat/add-line-charts' into feat/add-area-charts
tewarig Sep 10, 2025
e9c1bd9
chore: add changeset
tewarig Sep 10, 2025
f9e046b
feat: add bar chart
tewarig Sep 10, 2025
94da90d
fix: add bar chart
tewarig Sep 10, 2025
8449366
chore: remove logs from bar chart
tewarig Sep 10, 2025
3aa90bb
chore: sync with master
tewarig Sep 17, 2025
9b8e700
Merge remote-tracking branch 'origin' into feat/add-bar-charts
tewarig Sep 18, 2025
0ab2051
refactor: bar charts
tewarig Sep 18, 2025
2b3e8f4
fix: add area chart types
tewarig Sep 18, 2025
4ae36ec
feat: add test cases
tewarig Sep 18, 2025
2afee81
feat: add bar chart
tewarig Sep 18, 2025
4083df8
feat: add changset
tewarig Sep 18, 2025
be35727
fix: update bar chart
tewarig Sep 19, 2025
023b593
fix: opacity
tewarig Sep 19, 2025
eff0834
fix: bar chart review
tewarig Sep 19, 2025
213613e
fix: bar chart review
tewarig Sep 19, 2025
d02a393
chore: update mcp docs
tewarig Sep 22, 2025
ef9eda0
chore: resolve review comments
tewarig Sep 22, 2025
e0df6a2
fix:linting issue
tewarig Sep 22, 2025
b1daa9c
chore: update lint
tewarig Sep 22, 2025
b5f4511
chore: rename chartBarwrapper
tewarig Sep 22, 2025
c07dff3
fix: update opacity
tewarig Sep 22, 2025
08ded0a
fix: set animation easing to linear
tewarig Sep 22, 2025
f80e366
chore: export types
tewarig Sep 23, 2025
27ffef4
feat: update chart layout
tewarig Sep 23, 2025
1f88647
chore: rename to charts
tewarig Sep 23, 2025
4bd36fa
chore: rename story
tewarig Sep 23, 2025
a3bc3e9
chore: update barchart stories
tewarig Sep 23, 2025
2deae8c
fix: add animation
tewarig Sep 23, 2025
fd2825b
fix: animation speed
tewarig Sep 23, 2025
51d9688
fix: animation logic and stacked bar logic
tewarig Sep 23, 2025
c8892f7
chore: more animation fixes
tewarig Sep 23, 2025
6346b23
fix: update animation
tewarig Sep 23, 2025
0283740
chore: update snaps
tewarig Sep 23, 2025
e23e82a
fix: ts issue
tewarig Sep 24, 2025
e9c088d
chore: add stacking
tewarig Sep 24, 2025
8fd2bff
refactor: code animation
tewarig Sep 24, 2025
01535f7
chore: update snaps
tewarig Sep 24, 2025
e3a8769
chore: remove animation :(
tewarig Sep 24, 2025
5328255
review: change orientation to layout
tewarig Sep 24, 2025
4fc94f2
chore: update layout
tewarig Sep 24, 2025
37cb2c4
chore: update types
tewarig Sep 24, 2025
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
7 changes: 7 additions & 0 deletions .changeset/fluffy-impalas-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@razorpay/blade': minor
---

feat(blade): add BarChart component

[Docs Link](https://blade.razorpay.com/?path=/docs/components-charts-barchart--docs)
5 changes: 5 additions & 0 deletions .changeset/yellow-lamps-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@razorpay/blade-mcp': minor
---

feat(blade-mcp): update knowledgebase with BarChart
4 changes: 2 additions & 2 deletions packages/blade-mcp/knowledgebase/components/AreaChart.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type ChartAreaWrapperProps = {
children?: React.ReactNode;
colorTheme?: colorTheme;
data: data[];
};
} & BoxProps;

type ChartReferenceLineProps = {
/**
Expand Down Expand Up @@ -136,4 +136,4 @@ function BasicAreaChart() {
</Box>
);
}
```
```
178 changes: 178 additions & 0 deletions packages/blade-mcp/knowledgebase/components/BarChart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# BarChart

## Component Name

BarChart

## Description

BarChart is a comprehensive data visualization component that renders interactive bar charts with support for grouped, stacked, and vertical layouts. It provides customizable colors, animations, and interactive features like hover states and tooltips. The component is built on top of Recharts and integrates seamlessly with Blade's design system, offering consistent styling and accessibility features. BarChart supports multiple data series, custom color themes, and various chart configurations for displaying categorical data effectively.

## Important Constraints

- `ChartBarWrapper` component only accepts `ChartBar`, `ChartXAxis`, `ChartYAxis`, `ChartCartesianGrid`, `ChartTooltip`, `ChartLegend`, and `ChartReferenceLine` components as children.
- `data` prop is required and must be an array of objects with consistent data structure
- `dataKey` prop is required for each `ChartBar` component and must correspond to a property in the data array
- `stackId` must be consistent across all bars that should be stacked together
- `layout="vertical"` requires `ChartXAxis` to have `type="number"` and `ChartYAxis` to have `type="category"`
- Color tokens must follow the exact format: `chart.background.categorical.{color}.{emphasis}` or `chart.background.sequential.{color}.{number}`

## TypeScript Types

These types define the props that the BarChart component and its subcomponents accept:

```typescript
type ChartBarProps = Omit<RechartsBarProps, 'fill' | 'dataKey' | 'name' | 'label' | 'activeBar'> & {
/**
* The data key of the bar chart.
*/
dataKey: RechartsBarProps['dataKey'];
/**
* The name of the bar chart.
*/
name?: RechartsBarProps['name'];
/**
* The color of the bar chart.
*/
color?: ChartsCategoricalColorToken | ChartSequentialColorToken;
/**
* The stack id of the bar chart.
*/
stackId?: RechartsBarProps['stackId'];
/**
* The active bar of the bar chart.
*/
activeBar?: RechartsBarProps['activeBar'];
/**
* The label of the bar chart.
*/
label?: RechartsBarProps['label'];
/**
* The show legend of the bar chart.
*/
showLegend?: boolean;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no showLegend prop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added


type data = {
[key: string]: unknown;
};

type ChartBarWrapperProps = {
children?: React.ReactNode;
/**
* The color theme of the bar chart.
*/
colorTheme?: colorTheme;
/**
* The orientation of the bar chart.
*/
layout?: 'horizontal' | 'vertical';
/**
* Chart data to be rendered
*/
data: data[];
} & BoxProps;


type ChartsCategoricalColorToken = `chart.background.categorical.${ChartColorCategories}.${keyof ChartCategoricalEmphasis}`;

type ChartSequentialColorToken = `chart.background.sequential.${Exclude<ChartColorCategories, 'gray'>}.${keyof ChartSequentialEmphasis}`;

type colorTheme = 'default';

type ChartXAxisProps = Omit<RechartsXAxisProps, 'tick' | 'label' | 'dataKey' | 'stroke'> & {
/**
* The label of the x-axis.
*/
label?: string;
/**
* The data key of the x-axis.
*/
dataKey?: string;
};

type ChartYAxisProps = Omit<RechartsYAxisProps, 'tick' | 'label' | 'dataKey' | 'stroke'> & {
/**
* The label of the y-axis.
*/
label?: string;
/**
* The data key of the y-axis.
*/
dataKey?: string;
};

type ChartTooltipProps = ComponentProps<typeof RechartsTooltip>;

type ChartLegendProps = ComponentProps<typeof RechartsLegend>;

type ChartCartesianGridProps = Omit<RechartsCartesianGridProps, 'strokeDasharray' | 'verticalFill' | 'horizontalFill'>;

type ChartReferenceLineProps = {
/**
* The y-coordinate of the reference line.
*/
y?: RechartsReferenceLineProps['y'];
/**
* The x-coordinate of the reference line.
*/
x?: RechartsReferenceLineProps['x'];
/**
* The label of the reference line.
*/
label: string;
};
```

## Example

### Basic BarChart with Multiple Series

```tsx
import React from 'react';
import {
ChartBar,
ChartBarWrapper,
ChartXAxis,
ChartYAxis,
ChartCartesianGrid,
ChartTooltip,
ChartLegend,
} from '@razorpay/blade/components';

const salesData = [
{ month: 'Jan', revenue: 4000, profit: 2000, expenses: 1000 },
{ month: 'Feb', revenue: 3000, profit: 1500, expenses: 800 },
{ month: 'Mar', revenue: 5000, profit: 3000, expenses: 1200 },
{ month: 'Apr', revenue: 4500, profit: 2500, expenses: 1100 },
];

const BasicBarChart = () => {
return (
<div style={{ width: '100%', height: '400px' }}>
<ChartBarWrapper data={salesData}>
<ChartCartesianGrid />
<ChartXAxis dataKey="month" />
<ChartYAxis />
<ChartTooltip />
<ChartLegend />
<ChartBar
dataKey="revenue"
name="Revenue"
color="chart.background.categorical.azure.moderate"
/>
<ChartBar
dataKey="profit"
name="Profit"
color="chart.background.categorical.emerald.moderate"
/>
<ChartBar
dataKey="expenses"
name="Expenses"
color="chart.background.categorical.crimson.moderate"
/>
</ChartBarWrapper>
</div>
);
};
```
2 changes: 1 addition & 1 deletion packages/blade-mcp/knowledgebase/components/LineChart.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type ChartLineWrapperProps = {
*/
data: data[];
children: React.ReactNode;
} & Partial<Omit<BaseBoxProps, keyof FlexboxProps | keyof GridProps>>;
} & BoxProps;

type ChartReferenceLineProps = {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Page = (): React.ReactElement => {
componentName="AreaChart"
componentDescription="An Area Chart component built on top of Recharts with Blade design system styling."
apiDecisionLink={
'https://github.com/razorpay/blade/blob/5920fbd32c70793454f8c8c6ff544b2a7413afb5/packages/blade/src/components/Charts/_decisions/decisions.md'
'https://github.com/razorpay/blade/blob/master/packages/blade/src/components/Charts/_decisions/decisions.md'
}
figmaURL="https://www.figma.com/design/jubmQL9Z8V7881ayUD95ps/Blade-DSL?node-id=92678-188717&p=f&m=dev"
>
Expand Down Expand Up @@ -252,6 +252,14 @@ export const StackedAreaChart: StoryFn<typeof ChartArea> = ({
color="chart.background.categorical.azure.moderate"
{...args}
/>
<ChartArea
dataKey={dataKey}
name={name}
type="monotone"
stackId="1"
color="chart.background.categorical.crimson.moderate"
{...args}
/>
</ChartAreaWrapper>
</Box>
);
Expand Down
8 changes: 2 additions & 6 deletions packages/blade/src/components/Charts/AreaChart/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import type { AreaProps as RechartAreaProps } from 'recharts';
import type { ChartsCategoricalColorToken } from '../CommonChartComponents/types';
import type { colorTheme } from '../utils';
import type {
BaseBoxProps,
FlexboxProps,
GridProps,
} from '~components/Box/BaseBox/types/propsTypes';
import type { BoxProps } from '~components/Box';

type ChartAreaProps = {
/**
Expand Down Expand Up @@ -68,6 +64,6 @@ type ChartAreaWrapperProps = {
* Chart data to be rendered
*/
data: data[];
} & Partial<Omit<BaseBoxProps, keyof FlexboxProps | keyof GridProps>>;
} & BoxProps;

export type { ChartAreaProps, ChartAreaWrapperProps };
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import type { ChartBarProps, ChartBarWrapperProps } from './types';
import { Text } from '~components/Typography';
import { throwBladeError } from '~utils/logger';

const ChartBar = (_prop: ChartBarProps): React.ReactElement => {
throwBladeError({
message: 'ChartBar is not yet implemented for native',
moduleName: 'ChartBar',
});

return <Text>ChartBar is not available for Native mobile apps.</Text>;
};

const ChartBarWrapper = (_prop: ChartBarWrapperProps): React.ReactElement => {
throwBladeError({
message: 'ChartBarWrapper is not yet implemented for native',
moduleName: 'ChartBarWrapper',
});

return <Text>ChartLine is not available for Native mobile apps.</Text>;
};

export type { ChartBarProps, ChartBarWrapperProps };
export { ChartBar, ChartBarWrapper };
Loading
Loading