Skip to content

Commit 0537768

Browse files
committed
avoid re-computing the facet scales
1 parent 84c2696 commit 0537768

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/options.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export const indexOf = (d, i) => i;
4848
export const identity = {transform: (d) => d};
4949
export const zero = () => 0;
5050
export const one = () => 1;
51-
export const yes = () => true;
5251
export const string = (x) => (x == null ? x : `${x}`);
5352
export const number = (x) => (x == null ? x : +x);
5453
export const boolean = (x) => (x == null ? x : !!x);

src/plot.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {defined} from "./defined.js";
66
import {Dimensions} from "./dimensions.js";
77
import {facetTranslate, filterFacets, maybeFacet, facetReindex} from "./facet.js";
88
import {Legends, exposeLegends} from "./legends.js";
9-
import {arrayify, isDomainSort, isScaleOptions, map, maybeNamed, range, where, yes} from "./options.js";
9+
import {arrayify, isDomainSort, isScaleOptions, map, maybeNamed, range, where} from "./options.js";
1010
import {Scales, ScaleFunctions, autoScaleRange, exposeScales} from "./scales.js";
1111
import {position, registry as scaleRegistry} from "./scales/index.js";
1212
import {applyInlineStyles, maybeClassName, maybeClip, styles} from "./style.js";
@@ -514,7 +514,10 @@ export function plot(options = {}) {
514514
}
515515

516516
// Initalize the scales and axes.
517-
const scaleDescriptors = Scales(addScaleChannels(channelsByScale, stateByMark), options);
517+
const scaleDescriptors = Scales(
518+
addScaleChannels(channelsByScale, stateByMark, (scale) => !["fx", "fy"].includes(scale)),
519+
options
520+
);
518521
const scales = ScaleFunctions(scaleDescriptors);
519522
const axes = Axes(scaleDescriptors, options);
520523
const dimensions = Dimensions(scaleDescriptors, axes, options);
@@ -848,7 +851,7 @@ function inferChannelScale(channels) {
848851
}
849852
}
850853

851-
function addScaleChannels(channelsByScale, stateByMark, filter = yes) {
854+
function addScaleChannels(channelsByScale, stateByMark, filter) {
852855
for (const {channels} of stateByMark.values()) {
853856
for (const name in channels) {
854857
const channel = channels[name];

0 commit comments

Comments
 (0)