Skip to content

Commit

Permalink
fix: added interval logic startendonly
Browse files Browse the repository at this point in the history
  • Loading branch information
severinlandolt committed Oct 23, 2023
1 parent b2c22ab commit a764308
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/chart-elements/AreaChart/AreaChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ const AreaChart = React.forwardRef<HTMLDivElement, AreaChartProps>((props, ref)
// dark
"dark:fill-dark-tremor-content",
)}
interval={intervalType}
interval={startEndOnly ? "preserveStartEnd" : intervalType}
tickLine={false}
axisLine={false}
minTickGap={5}
Expand Down
2 changes: 1 addition & 1 deletion src/components/chart-elements/BarChart/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>((props, ref) =>
<XAxis
hide={!showXAxis}
dataKey={index}
interval={intervalType}
interval={startEndOnly ? "preserveStartEnd" : intervalType}
tick={{ transform: "translate(0, 6)" }}
ticks={startEndOnly ? [data[0][index], data[data.length - 1][index]] : undefined}
fill=""
Expand Down
2 changes: 1 addition & 1 deletion src/components/chart-elements/LineChart/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const LineChart = React.forwardRef<HTMLDivElement, LineChartProps>((props, ref)
<XAxis
hide={!showXAxis}
dataKey={index}
interval={intervalType}
interval={startEndOnly ? "preserveStartEnd" : intervalType}
tick={{ transform: "translate(0, 6)" }}
ticks={startEndOnly ? [data[0][index], data[data.length - 1][index]] : undefined}
fill=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ const ScatterChart = React.forwardRef<HTMLDivElement, ScatterChartProps>((props,
<XAxis
hide={!showXAxis}
dataKey={x}
interval={intervalType}
interval={startEndOnly ? "preserveStartEnd" : intervalType}
tick={{ transform: "translate(0, 6)" }}
ticks={startEndOnly ? [data[0][x], data[data.length - 1][x]] : undefined}
type="number"
Expand Down
4 changes: 3 additions & 1 deletion src/lib/inputTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ export type ValueFormatter = {

export type CurveType = "linear" | "natural" | "monotone" | "step";

export type IntervalType = "preserveStartEnd" | "equidistantPreserveStart";
export type Interval = "preserveStartEnd" | "equidistantPreserveStart";

export type IntervalType = "preserveStartEnd" | Interval;

const iconVariantValues = ["simple", "light", "shadow", "solid", "outlined"] as const;

Expand Down

0 comments on commit a764308

Please sign in to comment.