Skip to content

Commit

Permalink
allow toggling axisline for all chart types
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbalonperin committed May 24, 2024
1 parent 0a6c9a0 commit 84c94c7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/components/chart-elements/AreaChart/AreaChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const AreaChart = React.forwardRef<HTMLDivElement, AreaChartProps>((props, ref)
showTooltip = true,
showLegend = true,
showGridLines = true,
showAxisLine = false,
showGradient = true,
autoMinValue = false,
curveType = "linear",
Expand Down Expand Up @@ -191,7 +192,7 @@ const AreaChart = React.forwardRef<HTMLDivElement, AreaChartProps>((props, ref)
)}
interval={startEndOnly ? "preserveStartEnd" : intervalType}
tickLine={false}
axisLine={false}
axisLine={showAxisLine}
minTickGap={tickGap}
angle={rotateLabelX?.angle}
dy={rotateLabelX?.verticalShift}
Expand All @@ -210,7 +211,7 @@ const AreaChart = React.forwardRef<HTMLDivElement, AreaChartProps>((props, ref)
<YAxis
width={yAxisWidth}
hide={!showYAxis}
axisLine={false}
axisLine={showAxisLine}
tickLine={false}
type="number"
domain={yAxisDomain as AxisDomain}
Expand Down
9 changes: 5 additions & 4 deletions src/components/chart-elements/BarChart/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>((props, ref) =>
showTooltip = true,
showLegend = true,
showGridLines = true,
showAxisLine = false,
autoMinValue = false,
minValue,
maxValue,
Expand Down Expand Up @@ -204,7 +205,7 @@ const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>((props, ref) =>
"dark:fill-dark-tremor-content",
)}
tickLine={false}
axisLine={false}
axisLine={showAxisLine}
angle={rotateLabelX?.angle}
dy={rotateLabelX?.verticalShift}
height={rotateLabelX?.xAxisHeight}
Expand Down Expand Up @@ -237,7 +238,7 @@ const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>((props, ref) =>
"dark:fill-dark-tremor-content",
)}
tickLine={false}
axisLine={false}
axisLine={showAxisLine}
tickFormatter={valueFormatter}
minTickGap={tickGap}
allowDecimals={allowDecimals}
Expand All @@ -260,7 +261,7 @@ const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>((props, ref) =>
<YAxis
width={yAxisWidth}
hide={!showYAxis}
axisLine={false}
axisLine={showAxisLine}
tickLine={false}
type="number"
domain={yAxisDomain as AxisDomain}
Expand Down Expand Up @@ -297,7 +298,7 @@ const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>((props, ref) =>
width={yAxisWidth}
hide={!showYAxis}
dataKey={index}
axisLine={false}
axisLine={showAxisLine}
tickLine={false}
ticks={startEndOnly ? [data[0][index], data[data.length - 1][index]] : undefined}
type="category"
Expand Down
5 changes: 3 additions & 2 deletions src/components/chart-elements/LineChart/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const LineChart = React.forwardRef<HTMLDivElement, LineChartProps>((props, ref)
showTooltip = true,
showLegend = true,
showGridLines = true,
showAxisLine = false,
autoMinValue = false,
curveType = "linear",
minValue,
Expand Down Expand Up @@ -187,7 +188,7 @@ const LineChart = React.forwardRef<HTMLDivElement, LineChartProps>((props, ref)
"dark:fill-dark-tremor-content",
)}
tickLine={false}
axisLine={false}
axisLine={showAxisLine}
minTickGap={tickGap}
angle={rotateLabelX?.angle}
dy={rotateLabelX?.verticalShift}
Expand All @@ -206,7 +207,7 @@ const LineChart = React.forwardRef<HTMLDivElement, LineChartProps>((props, ref)
<YAxis
width={yAxisWidth}
hide={!showYAxis}
axisLine={false}
axisLine={showAxisLine}
tickLine={false}
type="number"
domain={yAxisDomain as AxisDomain}
Expand Down
6 changes: 4 additions & 2 deletions src/components/chart-elements/ScatterChart/ScatterChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export interface ScatterChartProps
showTooltip?: boolean;
showLegend?: boolean;
showGridLines?: boolean;
showAxisLine?: boolean;
autoMinXValue?: boolean;
minXValue?: number;
maxXValue?: number;
Expand Down Expand Up @@ -129,6 +130,7 @@ const ScatterChart = React.forwardRef<HTMLDivElement, ScatterChartProps>((props,
showTooltip = true,
showLegend = true,
showGridLines = true,
showAxisLine = false,
autoMinXValue = false,
minXValue,
maxXValue,
Expand Down Expand Up @@ -249,7 +251,7 @@ const ScatterChart = React.forwardRef<HTMLDivElement, ScatterChartProps>((props,
)}
tickLine={false}
tickFormatter={valueFormatter.x}
axisLine={false}
axisLine={showAxisLine}
minTickGap={tickGap}
domain={xAxisDomain as AxisDomain}
allowDataOverflow={true}
Expand All @@ -272,7 +274,7 @@ const ScatterChart = React.forwardRef<HTMLDivElement, ScatterChartProps>((props,
<YAxis
width={yAxisWidth}
hide={!showYAxis}
axisLine={false}
axisLine={showAxisLine}
tickLine={false}
dataKey={y}
type="number"
Expand Down
1 change: 1 addition & 0 deletions src/components/chart-elements/common/BaseChartProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface BaseChartProps extends BaseAnimationTimingProps, React.HTMLAttributes<
showTooltip?: boolean;
showLegend?: boolean;
showGridLines?: boolean;
showAxisLine?: boolean;
autoMinValue?: boolean;
minValue?: number;
maxValue?: number;
Expand Down

0 comments on commit 84c94c7

Please sign in to comment.