Skip to content

Commit 8eee048

Browse files
committed
Merge branch 'beta' of https://github.com/react-tools/react-charts into beta
2 parents d258d13 + be2808d commit 8eee048

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/components/Chart.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ export function Chart<TDatum>({
201201
{...rest}
202202
className={`ReactChart ${className || ''}`}
203203
style={{
204+
fontFamily: 'sans-serif',
204205
...style,
205206
position: 'absolute',
206207
width,
@@ -686,11 +687,7 @@ function ChartInner<TDatum>({
686687

687688
return (
688689
<ChartContextProvider value={useGetLatest(contextValue)}>
689-
<div
690-
style={{
691-
fontFamily: 'sans-serif',
692-
}}
693-
>
690+
<div>
694691
<svg
695692
ref={svgRef}
696693
style={{

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ export type AxisOptionsBase = {
241241
minTickPaddingForRotation?: number
242242
tickLabelRotationDeg?: number
243243
tickCount?: number
244+
shouldNice?: boolean
244245
innerBandPadding?: number
245246
outerBandPadding?: number
246247
innerSeriesBandPadding?: number

src/utils/buildAxis.linear.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function defaultAxisOptions<TDatum>(
4242
outerSeriesBandPadding: options.outerSeriesBandPadding ?? 0,
4343
show: options.show ?? true,
4444
stacked: options.stacked ?? false,
45+
shouldNice: options.shouldNice ?? true,
4546
}
4647
}
4748

@@ -119,24 +120,25 @@ function buildTimeAxis<TDatum>(
119120
return value
120121
})
121122

122-
let shouldNice = true
123+
let shouldNice = options.shouldNice
123124

124-
if (typeof options.min === 'number') {
125+
// see https://stackoverflow.com/a/2831422
126+
if (Object.prototype.toString.call(options.min) === '[object Date]') {
125127
minValue = min([options.min, minValue as Date])
126128
shouldNice = false
127129
}
128130

129-
if (typeof options.max === 'number') {
131+
if (Object.prototype.toString.call(options.max) === '[object Date]') {
130132
maxValue = max([options.max, maxValue as Date])
131133
shouldNice = false
132134
}
133135

134-
if (typeof options.hardMin === 'number') {
136+
if (Object.prototype.toString.call(options.hardMin) === '[object Date]') {
135137
minValue = options.hardMin
136138
shouldNice = false
137139
}
138140

139-
if (typeof options.hardMax === 'number') {
141+
if (Object.prototype.toString.call(options.hardMax) === '[object Date]') {
140142
maxValue = options.hardMax
141143
shouldNice = false
142144
}
@@ -250,7 +252,7 @@ function buildLinearAxis<TDatum>(
250252
return value
251253
})
252254

253-
let shouldNice = true
255+
let shouldNice = options.shouldNice
254256

255257
if (typeof options.min === 'number') {
256258
minValue = min([options.min, minValue as number])

0 commit comments

Comments
 (0)