Skip to content

Commit

Permalink
Merge pull request #249 from chenz24/fix-charts
Browse files Browse the repository at this point in the history
pass recharts props
  • Loading branch information
chenz24 authored Feb 28, 2023
2 parents 3e11e13 + 0fdd7d1 commit 52ec7a5
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/serious-dots-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@kubed/charts': patch
---

pass recharts props
3 changes: 2 additions & 1 deletion packages/charts/src/charts/AreaChart/AreaChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const AreaChart = ({
legendAlign = 'right',
legendFormatter,
maxActiveCategories = 50,
...rest
}: AreaChartProps) => {
const initialActiveCats = categories.slice(0, maxActiveCategories);
const [activeCategories, setActiveCategories] = useState(initialActiveCats);
Expand All @@ -66,7 +67,7 @@ export const AreaChart = ({

return (
<ResponsiveContainer width="100%" height="100%">
<ReChartsAreaChart data={data}>
<ReChartsAreaChart data={data} {...rest}>
{showGridLines ? (
<CartesianGrid stroke="#d8dee5" strokeDasharray="2 2" horizontal vertical={false} />
) : null}
Expand Down
2 changes: 2 additions & 0 deletions packages/charts/src/charts/BarChart/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const BarChart = ({
legendAlign = 'right',
legendFormatter,
maxActiveCategories = 50,
...rest
}: BarChartProps) => {
const initialActiveCats = categories.slice(0, maxActiveCategories);
const [activeCategories, setActiveCategories] = useState(initialActiveCats);
Expand All @@ -74,6 +75,7 @@ export const BarChart = ({
data={data}
stackOffset={relative ? 'expand' : 'none'}
layout={layout === 'vertical' ? 'vertical' : 'horizontal'}
{...rest}
>
{showGridLines ? (
<CartesianGrid
Expand Down
3 changes: 2 additions & 1 deletion packages/charts/src/charts/LineChart/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const LineChart = ({
legendAlign = 'right',
legendFormatter,
maxActiveCategories = 50,
...rest
}: LineChartProps) => {
const initialActiveCats = categories.slice(0, maxActiveCategories);
const [activeCategories, setActiveCategories] = useState(initialActiveCats);
Expand All @@ -62,7 +63,7 @@ export const LineChart = ({

return (
<ResponsiveContainer width="100%" height="100%">
<ReChartsLineChart data={data}>
<ReChartsLineChart data={data} {...rest}>
{showGridLines ? (
<CartesianGrid stroke="#d8dee5" strokeDasharray="2 2" horizontal vertical={false} />
) : null}
Expand Down
5 changes: 3 additions & 2 deletions packages/charts/src/charts/PieChart/PieChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ export const PieChart = ({
legendVerticalAlign = 'top',
legendAlign = 'right',
legendFormatter,
maxActiveCategories = 50,
// maxActiveCategories = 50,
...rest
}: PieChartProps) => {
const isDonut = variant === 'donut';

return (
<ResponsiveContainer width="100%" height="100%">
<ReChartsDonutChart>
<ReChartsDonutChart {...rest}>
<Pie
data={parseData(data, colors)}
cx="50%"
Expand Down
4 changes: 2 additions & 2 deletions packages/charts/src/components/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ export function Tooltip({
<TooltipWrapper className={className}>
<TooltipLabel>{label}</TooltipLabel>
<ItemWrapper>
{payload.map((item) => {
{payload.map((item, index) => {
const legend = legendFormatter ? legendFormatter(item) : item.name;
const color = item.color || item.payload?.fill;
return (
<TooltipItem color={color}>
<TooltipItem color={color} key={`tooltip-${item.name}-${index}`}>
{legend}: {valueFormatter(item.value)}
</TooltipItem>
);
Expand Down
1 change: 1 addition & 0 deletions packages/charts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './charts/AreaChart/AreaChart';
export * from './charts/LineChart/LineChart';
export * from './charts/BarChart/BarChart';
export * from './charts/PieChart/PieChart';
export * from './types';
9 changes: 5 additions & 4 deletions packages/charts/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export interface ChartBaseProps {
data: any[];
import { CategoricalChartProps } from 'recharts/types/chart/generateCategoricalChart';

export interface ChartBaseProps extends CategoricalChartProps {
categories: string[];
colors?: string[];
height?: number | string;
width?: number | string;
// height?: number | string;
// width?: number | string;
dataKey: string;
showXAxis?: boolean;
showYAxis?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion scripts/storybook-start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'path';
import storybook from '@storybook/react/standalone';

storybook({
port: 7000,
port: 7001,
mode: 'dev',
configDir: path.join(__dirname, '../configs/storybook'),
});

1 comment on commit 52ec7a5

@vercel
Copy link

@vercel vercel bot commented on 52ec7a5 Feb 28, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

kube-design – ./

kube-design-git-master-chenz8606.vercel.app
kube-design.vercel.app
kube-design-chenz8606.vercel.app

Please sign in to comment.