Skip to content

Commit

Permalink
Merge branch 'beta' into fix/noaxes
Browse files Browse the repository at this point in the history
  • Loading branch information
severinlandolt authored Oct 24, 2023
2 parents 414cb80 + 416c2ab commit 1222c62
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/components/chart-elements/AreaChart/AreaChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface AreaChartProps extends BaseChartProps {
stack?: boolean;
curveType?: CurveType;
connectNulls?: boolean;
showGradient?: boolean;
}

interface ActiveDot {
Expand Down Expand Up @@ -75,6 +76,7 @@ const AreaChart = React.forwardRef<HTMLDivElement, AreaChartProps>((props, ref)
onValueChange,
enableLegendSlider = false,
customTooltip,
rotateLabelX,
...other
} = props;
const CustomTooltip = customTooltip;
Expand Down Expand Up @@ -181,6 +183,9 @@ const AreaChart = React.forwardRef<HTMLDivElement, AreaChartProps>((props, ref)
tickLine={false}
axisLine={false}
minTickGap={5}
angle={rotateLabelX?.angle}
dy={rotateLabelX?.verticalShift}
height={rotateLabelX?.xAxisHeight}
/>
<YAxis
width={yAxisWidth}
Expand Down
7 changes: 7 additions & 0 deletions src/components/chart-elements/BarChart/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>((props, ref) =>
noDataText,
onValueChange,
customTooltip,
rotateLabelX,
className,
enableLegendSlider = false,
...other
Expand Down Expand Up @@ -177,6 +178,9 @@ const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>((props, ref) =>
)}
tickLine={false}
axisLine={false}
angle={rotateLabelX?.angle}
dy={rotateLabelX?.verticalShift}
height={rotateLabelX?.xAxisHeight}
/>
) : (
<XAxis
Expand All @@ -199,6 +203,9 @@ const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>((props, ref) =>
tickFormatter={valueFormatter}
minTickGap={5}
allowDecimals={allowDecimals}
angle={rotateLabelX?.angle}
dy={rotateLabelX?.verticalShift}
height={rotateLabelX?.xAxisHeight}
/>
)}
{layout !== "vertical" ? (
Expand Down
4 changes: 4 additions & 0 deletions src/components/chart-elements/LineChart/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const LineChart = React.forwardRef<HTMLDivElement, LineChartProps>((props, ref)
onValueChange,
enableLegendSlider = false,
customTooltip,
rotateLabelX,
...other
} = props;
const CustomTooltip = customTooltip;
Expand Down Expand Up @@ -178,6 +179,9 @@ const LineChart = React.forwardRef<HTMLDivElement, LineChartProps>((props, ref)
tickLine={false}
axisLine={false}
minTickGap={5}
angle={rotateLabelX?.angle}
dy={rotateLabelX?.verticalShift}
height={rotateLabelX?.xAxisHeight}
/>
<YAxis
width={yAxisWidth}
Expand Down
9 changes: 9 additions & 0 deletions src/components/chart-elements/ScatterChart/ScatterChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ export interface ScatterChartProps
enableLegendSlider?: boolean;
onValueChange?: (value: EventProps) => void;
customTooltip?: React.ComponentType<CustomTooltipType>;
rotateLabelX?: {
angle: number;
verticalShift: number;
xAxisHeight: number;
};
}

const renderShape = (props: any, activeNode: any | undefined, activeLegend: string | undefined) => {
Expand Down Expand Up @@ -130,6 +135,7 @@ const ScatterChart = React.forwardRef<HTMLDivElement, ScatterChartProps>((props,
noDataText,
onValueChange,
customTooltip,
rotateLabelX,
className,
enableLegendSlider = false,
...other
Expand Down Expand Up @@ -235,6 +241,9 @@ const ScatterChart = React.forwardRef<HTMLDivElement, ScatterChartProps>((props,
minTickGap={5}
domain={xAxisDomain as AxisDomain}
allowDataOverflow={true}
angle={rotateLabelX?.angle}
dy={rotateLabelX?.verticalShift}
height={rotateLabelX?.xAxisHeight}
/>
) : null}
{y ? (
Expand Down
6 changes: 5 additions & 1 deletion src/components/chart-elements/common/BaseChartProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ interface BaseChartProps extends BaseAnimationTimingProps, React.HTMLAttributes<
yAxisWidth?: number;
intervalType?: IntervalType;
showTooltip?: boolean;
showGradient?: boolean;
showLegend?: boolean;
showGridLines?: boolean;
autoMinValue?: boolean;
Expand All @@ -36,6 +35,11 @@ interface BaseChartProps extends BaseAnimationTimingProps, React.HTMLAttributes<
onValueChange?: (value: EventProps) => void;
enableLegendSlider?: boolean;
customTooltip?: React.ComponentType<CustomTooltipType>;
rotateLabelX?: {
angle: number;
verticalShift: number;
xAxisHeight: number;
};
}

export default BaseChartProps;
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const ProgressCircle = React.forwardRef<HTMLDivElement, ProgressCircleProps>((pr
: "stroke-tremor-brand-muted/50 dark:stroke-dark-tremor-brand-muted",
)}
/>
{value > 0 ? (
{value >= 0 ? (
<circle
r={normalizedRadius}
cx={radius}
Expand Down
7 changes: 7 additions & 0 deletions src/stories/chart-elements/AreaChart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ export const MultipleZeroValues: Story = {
},
};

export const RotateXLabels: Story = {
args: {
data: longBaseChartData,
rotateLabelX: { angle: -45, verticalShift: 15, xAxisHeight: 50 },
},
};

export const WithoutLegendScroll: Story = {
args: { enableLegendSlider: false },
};
Expand Down
20 changes: 15 additions & 5 deletions src/stories/chart-elements/BarChart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ export const OtherColors: Story = {
args: { colors: ["blue", "green"] },
};

// @sev
export const NoGradient: Story = {
args: { showGradient: false },
};

export const ChangedCategoriesOrder: Story = {
args: { categories: ["Successful Payments", "Sales"] },
};
Expand Down Expand Up @@ -177,6 +172,21 @@ export const NoAxes: Story = {
showXAxis: false,
showYAxis: false,
},
};

Check failure on line 175 in src/stories/chart-elements/BarChart.stories.tsx

View workflow job for this annotation

GitHub Actions / Build dist

Delete `·`

Check failure on line 175 in src/stories/chart-elements/BarChart.stories.tsx

View workflow job for this annotation

GitHub Actions / Build dist

Delete `·`

export const RotateXLabelsHorizontal: Story = {
args: {
data: longBaseChartData,
rotateLabelX: { angle: -45, verticalShift: 15, xAxisHeight: 50 },
},
};

export const RotateXLabelVertical: Story = {
args: {
data: longBaseChartData,
rotateLabelX: { angle: -45, verticalShift: 15, xAxisHeight: 50 },
layout: "vertical",
},
};

//Custom tooltips
Expand Down
7 changes: 7 additions & 0 deletions src/stories/chart-elements/LineChart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ export const NoAxes: Story = {
},
};

export const RotateXLabels: Story = {
args: {
data: longBaseChartData,
rotateLabelX: { angle: -45, verticalShift: 15, xAxisHeight: 50 },
},
};

//Custom tooltips
const customTooltipColors: Color[] = ["cyan"];
const customTooltipIndex = "month";
Expand Down
6 changes: 6 additions & 0 deletions src/stories/chart-elements/ScatterChart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ export const MultipleZeroValues: Story = {
},
};

export const RotateXLabel: Story = {
args: {
rotateLabelX: { angle: -45, verticalShift: 15, xAxisHeight: 50 },
},
};

//Custom tooltips
const customTooltipColors: Color[] = ["red", "green", "blue", "yellow"];
const customTooltipIndex = "location";
Expand Down

0 comments on commit 1222c62

Please sign in to comment.