Skip to content

Commit 4ca703a

Browse files
committed
fix: bandsize types
1 parent 9cdcf35 commit 4ca703a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ export type AxisOptionsBase = {
228228
tickLabelRotationDeg?: number
229229
innerBandPadding?: number
230230
outerBandPadding?: number
231+
minBandSize?: number
232+
maxBandSize?: number
231233
showGrid?: boolean
232234
// showTicks?: boolean
233235
// filterTicks?: <T extends string>(ticks: T[]) => T[]

src/utils/Utils.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,13 @@ export function getPrimaryLength<TDatum>(
135135
primaryAxis: Axis<TDatum>
136136
) {
137137
if (primaryAxis.axisFamily === 'band') {
138-
return Math.max(primaryAxis.scale.bandwidth(), primaryAxis.minBandSize ?? 1)
138+
return Math.min(
139+
Math.max(
140+
primaryAxis.scale.bandwidth(),
141+
primaryAxis.minBandSize ?? 99999999
142+
),
143+
primaryAxis.maxBandSize ?? 1
144+
)
139145
}
140146

141147
return Math.max(primaryAxis.bandScale.bandwidth(), 1)

0 commit comments

Comments
 (0)