Skip to content

Commit 2d13457

Browse files
committed
fix null order; add tests
1 parent b5322a0 commit 2d13457

16 files changed

+9871
-34
lines changed

src/channel.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,10 @@ export function inferChannelScale(name, channel) {
7878
// computed; i.e., if the scale’s domain is set explicitly, that takes priority
7979
// over the sort option, and we don’t need to do additional work.
8080
export function channelDomain(data, facets, channels, facetChannels, options) {
81+
const {order: defaultOrder, reverse: defaultReverse, reduce: defaultReduce = true, limit: defaultLimit} = options;
8182
for (const x in options) {
8283
if (!registry.has(x)) continue; // ignore unknown scale keys (including generic options)
83-
let {
84-
value: y,
85-
order = options.order,
86-
reverse = options.reverse,
87-
reduce = options.reduce === undefined ? true : options.reduce,
88-
limit = options.limit
89-
} = maybeValue(options[x]);
84+
let {value: y, order = defaultOrder, reverse = defaultReverse, reduce = defaultReduce, limit = defaultLimit} = maybeValue(options[x]); // prettier-ignore
9085
order = order === undefined ? y === "width" || y === "height" ? descendingGroup : ascendingGroup : maybeOrder(order); // prettier-ignore
9186
if (reduce == null || reduce === false) continue; // disabled reducer
9287
const X = x === "fx" || x === "fy" ? reindexFacetChannel(facets, facetChannels[x]) : findScaleChannel(channels, x);
@@ -161,7 +156,7 @@ function values(channels, name, alias) {
161156
}
162157

163158
function maybeOrder(order) {
164-
if (typeof order === "function") return order;
159+
if (order == null || typeof order === "function") return order;
165160
switch (`${order}`.toLowerCase()) {
166161
case "ascending":
167162
return ascendingGroup;
Lines changed: 104 additions & 0 deletions
Loading
Lines changed: 104 additions & 0 deletions
Loading

test/output/athletesNationality.svg renamed to test/output/channelDomainComparator.svg

Lines changed: 2 additions & 7 deletions
Loading

0 commit comments

Comments
 (0)