Skip to content

Commit 5e716de

Browse files
committed
remove maybeAutoTickFormat
1 parent 5f045ce commit 5e716de

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

src/axes.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
1-
import {format, utcFormat} from "d3";
2-
import {formatIsoDate} from "./format.js";
3-
import {constant, isTemporal, string} from "./options.js";
41
import {isOrdinalScale} from "./scales.js";
52

63
export function inferFontVariant(scale) {
74
return isOrdinalScale(scale) && scale.interval === undefined ? undefined : "tabular-nums";
85
}
9-
10-
// D3 doesn’t provide a tick format for ordinal scales; we want shorthand when
11-
// an ordinal domain is numbers or dates, and we want null to mean the empty
12-
// string, not the default identity format. TODO Remove this in favor of the
13-
// axis mark’s inferTickFormat.
14-
export function maybeAutoTickFormat(tickFormat, domain) {
15-
return tickFormat === undefined
16-
? isTemporal(domain)
17-
? formatIsoDate
18-
: string
19-
: typeof tickFormat === "function"
20-
? tickFormat
21-
: (typeof tickFormat === "string" ? (isTemporal(domain) ? utcFormat : format) : constant)(tickFormat);
22-
}

src/legends/swatches.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import {pathRound as path} from "d3";
2-
import {inferFontVariant, maybeAutoTickFormat} from "../axes.js";
3-
import {createContext, create} from "../context.js";
2+
import {inferFontVariant} from "../axes.js";
3+
import {create, createContext} from "../context.js";
44
import {isNoneish, maybeColorChannel, maybeNumberChannel} from "../options.js";
55
import {isOrdinalScale, isThresholdScale} from "../scales.js";
66
import {applyInlineStyles, impliedString, maybeClassName} from "../style.js";
7+
import {inferTickFormat} from "../marks/axis.js";
78

89
function maybeScale(scale, key) {
910
if (key == null) return key;
@@ -85,7 +86,7 @@ function legendItems(scale, options = {}, swatch) {
8586
} = options;
8687
const context = createContext(options);
8788
className = maybeClassName(className);
88-
tickFormat = maybeAutoTickFormat(tickFormat, scale.domain);
89+
if (typeof tickFormat !== "function") tickFormat = inferTickFormat(scale.scale, undefined, tickFormat);
8990

9091
const swatches = create("div", context).attr(
9192
"class",

0 commit comments

Comments
 (0)