Skip to content

Commit

Permalink
fix(scales): fix time scale when value is date
Browse files Browse the repository at this point in the history
  • Loading branch information
wyze committed Jun 22, 2021
1 parent 191e3e0 commit 4a125b8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
2 changes: 1 addition & 1 deletion packages/scales/src/timeHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const createDateNormalizer = ({
const precisionFn = createPrecisionMethod(precision)

return (value: Date | string) => {
if (format === 'native') {
if (format === 'native' || value instanceof Date) {
return precisionFn(value as Date)
}

Expand Down
7 changes: 0 additions & 7 deletions packages/scales/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ export interface ScaleLinear<Output> extends D3ScaleLinear<number, Output, never
// default to `false`
stacked: boolean
}
export const isScaleLinearSpec = (spec: ScaleSpec): spec is ScaleLinearSpec =>
spec.type === 'linear'

export interface ScaleLogSpec {
type: 'log'
Expand All @@ -72,7 +70,6 @@ export interface ScaleLogSpec {
export interface ScaleLog extends D3ScaleLogarithmic<number, number> {
type: 'log'
}
export const isScaleLogSpec = (spec: ScaleSpec): spec is ScaleLogSpec => spec.type === 'log'

export interface ScaleSymLogSpec {
type: 'symlog'
Expand All @@ -87,16 +84,13 @@ export interface ScaleSymLogSpec {
export interface ScaleSymLog extends D3ScaleSymLog<number, number> {
type: 'symlog'
}
export const isScaleSymLogSpec = (spec: ScaleSpec): spec is ScaleSymLogSpec =>
spec.type === 'symlog'

export type ScalePointSpec = {
type: 'point'
}
export interface ScalePoint<Input extends StringValue> extends D3ScalePoint<Input> {
type: 'point'
}
export const isScalePointSpec = (spec: ScaleSpec): spec is ScalePointSpec => spec.type === 'point'

export type ScaleBandSpec = {
type: 'band'
Expand All @@ -105,7 +99,6 @@ export type ScaleBandSpec = {
export interface ScaleBand<Input extends StringValue> extends D3ScaleBand<Input> {
type: 'band'
}
export const isScaleBandSpec = (spec: ScaleSpec): spec is ScaleBandSpec => spec.type === 'band'

export type ScaleTimeSpec = {
type: 'time'
Expand Down

0 comments on commit 4a125b8

Please sign in to comment.