Skip to content

Commit 180ad4e

Browse files
mkfreemanmbostock
andauthored
Update boolean scheme9 scales (#706)
* Update boolean scheme9 scales * Update src/scales/schemes.js Co-authored-by: Mike Bostock <[email protected]> * Update tests for boolean colors Co-authored-by: Mike Bostock <[email protected]>
1 parent 5ba59d9 commit 180ad4e

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/scales/schemes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ const ordinalSchemes = new Map([
144144
function scheme9(scheme, interpolate) {
145145
return ({length: n}) => {
146146
if (n === 1) return [scheme[3][1]]; // favor midpoint
147-
if (n === 2) return [scheme[3][0], scheme[3][2]]; // favor extrema
147+
if (n === 2) return [scheme[3][1], scheme[3][2]]; // favor darker
148148
n = Math.max(3, Math.floor(n));
149149
return n > 9 ? quantize(interpolate, n) : scheme[n];
150150
};

test/output/colorSchemesOrdinal.html

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3635,7 +3635,7 @@
36353635
align-items: center;
36363636
margin-right: 1em;
36373637
}
3638-
</style><span class="plot-107-swatch" style="--color: #deebf7;">blues</span><span class="plot-107-swatch" style="--color: #3182bd;">1</span>
3638+
</style><span class="plot-107-swatch" style="--color: #9ecae1;">blues</span><span class="plot-107-swatch" style="--color: #3182bd;">1</span>
36393639
</div>
36403640
<div class="plot-108" style="
36413641
--swatchWidth: 15px;
@@ -3805,7 +3805,7 @@
38053805
align-items: center;
38063806
margin-right: 1em;
38073807
}
3808-
</style><span class="plot-112-swatch" style="--color: #e5f5e0;">greens</span><span class="plot-112-swatch" style="--color: #31a354;">1</span>
3808+
</style><span class="plot-112-swatch" style="--color: #a1d99b;">greens</span><span class="plot-112-swatch" style="--color: #31a354;">1</span>
38093809
</div>
38103810
<div class="plot-113" style="
38113811
--swatchWidth: 15px;
@@ -3975,7 +3975,7 @@
39753975
align-items: center;
39763976
margin-right: 1em;
39773977
}
3978-
</style><span class="plot-117-swatch" style="--color: #f0f0f0;">greys</span><span class="plot-117-swatch" style="--color: #636363;">1</span>
3978+
</style><span class="plot-117-swatch" style="--color: #bdbdbd;">greys</span><span class="plot-117-swatch" style="--color: #636363;">1</span>
39793979
</div>
39803980
<div class="plot-118" style="
39813981
--swatchWidth: 15px;
@@ -4145,7 +4145,7 @@
41454145
align-items: center;
41464146
margin-right: 1em;
41474147
}
4148-
</style><span class="plot-122-swatch" style="--color: #fee6ce;">oranges</span><span class="plot-122-swatch" style="--color: #e6550d;">1</span>
4148+
</style><span class="plot-122-swatch" style="--color: #fdae6b;">oranges</span><span class="plot-122-swatch" style="--color: #e6550d;">1</span>
41494149
</div>
41504150
<div class="plot-123" style="
41514151
--swatchWidth: 15px;
@@ -4315,7 +4315,7 @@
43154315
align-items: center;
43164316
margin-right: 1em;
43174317
}
4318-
</style><span class="plot-127-swatch" style="--color: #efedf5;">purples</span><span class="plot-127-swatch" style="--color: #756bb1;">1</span>
4318+
</style><span class="plot-127-swatch" style="--color: #bcbddc;">purples</span><span class="plot-127-swatch" style="--color: #756bb1;">1</span>
43194319
</div>
43204320
<div class="plot-128" style="
43214321
--swatchWidth: 15px;
@@ -4485,7 +4485,7 @@
44854485
align-items: center;
44864486
margin-right: 1em;
44874487
}
4488-
</style><span class="plot-132-swatch" style="--color: #fee0d2;">reds</span><span class="plot-132-swatch" style="--color: #de2d26;">1</span>
4488+
</style><span class="plot-132-swatch" style="--color: #fc9272;">reds</span><span class="plot-132-swatch" style="--color: #de2d26;">1</span>
44894489
</div>
44904490
<div class="plot-133" style="
44914491
--swatchWidth: 15px;
@@ -6185,7 +6185,7 @@
61856185
align-items: center;
61866186
margin-right: 1em;
61876187
}
6188-
</style><span class="plot-182-swatch" style="--color: #e5f5f9;">bugn</span><span class="plot-182-swatch" style="--color: #2ca25f;">1</span>
6188+
</style><span class="plot-182-swatch" style="--color: #99d8c9;">bugn</span><span class="plot-182-swatch" style="--color: #2ca25f;">1</span>
61896189
</div>
61906190
<div class="plot-183" style="
61916191
--swatchWidth: 15px;
@@ -6355,7 +6355,7 @@
63556355
align-items: center;
63566356
margin-right: 1em;
63576357
}
6358-
</style><span class="plot-187-swatch" style="--color: #e0ecf4;">bupu</span><span class="plot-187-swatch" style="--color: #8856a7;">1</span>
6358+
</style><span class="plot-187-swatch" style="--color: #9ebcda;">bupu</span><span class="plot-187-swatch" style="--color: #8856a7;">1</span>
63596359
</div>
63606360
<div class="plot-188" style="
63616361
--swatchWidth: 15px;
@@ -6525,7 +6525,7 @@
65256525
align-items: center;
65266526
margin-right: 1em;
65276527
}
6528-
</style><span class="plot-192-swatch" style="--color: #e0f3db;">gnbu</span><span class="plot-192-swatch" style="--color: #43a2ca;">1</span>
6528+
</style><span class="plot-192-swatch" style="--color: #a8ddb5;">gnbu</span><span class="plot-192-swatch" style="--color: #43a2ca;">1</span>
65296529
</div>
65306530
<div class="plot-193" style="
65316531
--swatchWidth: 15px;
@@ -6695,7 +6695,7 @@
66956695
align-items: center;
66966696
margin-right: 1em;
66976697
}
6698-
</style><span class="plot-197-swatch" style="--color: #fee8c8;">orrd</span><span class="plot-197-swatch" style="--color: #e34a33;">1</span>
6698+
</style><span class="plot-197-swatch" style="--color: #fdbb84;">orrd</span><span class="plot-197-swatch" style="--color: #e34a33;">1</span>
66996699
</div>
67006700
<div class="plot-198" style="
67016701
--swatchWidth: 15px;
@@ -6865,7 +6865,7 @@
68656865
align-items: center;
68666866
margin-right: 1em;
68676867
}
6868-
</style><span class="plot-202-swatch" style="--color: #ece7f2;">pubu</span><span class="plot-202-swatch" style="--color: #2b8cbe;">1</span>
6868+
</style><span class="plot-202-swatch" style="--color: #a6bddb;">pubu</span><span class="plot-202-swatch" style="--color: #2b8cbe;">1</span>
68696869
</div>
68706870
<div class="plot-203" style="
68716871
--swatchWidth: 15px;
@@ -7035,7 +7035,7 @@
70357035
align-items: center;
70367036
margin-right: 1em;
70377037
}
7038-
</style><span class="plot-207-swatch" style="--color: #ece2f0;">pubugn</span><span class="plot-207-swatch" style="--color: #1c9099;">1</span>
7038+
</style><span class="plot-207-swatch" style="--color: #a6bddb;">pubugn</span><span class="plot-207-swatch" style="--color: #1c9099;">1</span>
70397039
</div>
70407040
<div class="plot-208" style="
70417041
--swatchWidth: 15px;
@@ -7205,7 +7205,7 @@
72057205
align-items: center;
72067206
margin-right: 1em;
72077207
}
7208-
</style><span class="plot-212-swatch" style="--color: #e7e1ef;">purd</span><span class="plot-212-swatch" style="--color: #dd1c77;">1</span>
7208+
</style><span class="plot-212-swatch" style="--color: #c994c7;">purd</span><span class="plot-212-swatch" style="--color: #dd1c77;">1</span>
72097209
</div>
72107210
<div class="plot-213" style="
72117211
--swatchWidth: 15px;
@@ -7375,7 +7375,7 @@
73757375
align-items: center;
73767376
margin-right: 1em;
73777377
}
7378-
</style><span class="plot-217-swatch" style="--color: #fde0dd;">rdpu</span><span class="plot-217-swatch" style="--color: #c51b8a;">1</span>
7378+
</style><span class="plot-217-swatch" style="--color: #fa9fb5;">rdpu</span><span class="plot-217-swatch" style="--color: #c51b8a;">1</span>
73797379
</div>
73807380
<div class="plot-218" style="
73817381
--swatchWidth: 15px;
@@ -7545,7 +7545,7 @@
75457545
align-items: center;
75467546
margin-right: 1em;
75477547
}
7548-
</style><span class="plot-222-swatch" style="--color: #f7fcb9;">ylgn</span><span class="plot-222-swatch" style="--color: #31a354;">1</span>
7548+
</style><span class="plot-222-swatch" style="--color: #addd8e;">ylgn</span><span class="plot-222-swatch" style="--color: #31a354;">1</span>
75497549
</div>
75507550
<div class="plot-223" style="
75517551
--swatchWidth: 15px;
@@ -7715,7 +7715,7 @@
77157715
align-items: center;
77167716
margin-right: 1em;
77177717
}
7718-
</style><span class="plot-227-swatch" style="--color: #edf8b1;">ylgnbu</span><span class="plot-227-swatch" style="--color: #2c7fb8;">1</span>
7718+
</style><span class="plot-227-swatch" style="--color: #7fcdbb;">ylgnbu</span><span class="plot-227-swatch" style="--color: #2c7fb8;">1</span>
77197719
</div>
77207720
<div class="plot-228" style="
77217721
--swatchWidth: 15px;
@@ -7885,7 +7885,7 @@
78857885
align-items: center;
78867886
margin-right: 1em;
78877887
}
7888-
</style><span class="plot-232-swatch" style="--color: #fff7bc;">ylorbr</span><span class="plot-232-swatch" style="--color: #d95f0e;">1</span>
7888+
</style><span class="plot-232-swatch" style="--color: #fec44f;">ylorbr</span><span class="plot-232-swatch" style="--color: #d95f0e;">1</span>
78897889
</div>
78907890
<div class="plot-233" style="
78917891
--swatchWidth: 15px;
@@ -8055,7 +8055,7 @@
80558055
align-items: center;
80568056
margin-right: 1em;
80578057
}
8058-
</style><span class="plot-237-swatch" style="--color: #ffeda0;">ylorrd</span><span class="plot-237-swatch" style="--color: #f03b20;">1</span>
8058+
</style><span class="plot-237-swatch" style="--color: #feb24c;">ylorrd</span><span class="plot-237-swatch" style="--color: #f03b20;">1</span>
80598059
</div>
80608060
<div class="plot-238" style="
80618061
--swatchWidth: 15px;

test/scales/scales-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ it("plot(…).scale('color') can return a threshold scale with an explicit schem
718718
scaleEqual(plot.scale("color"), {
719719
type: "threshold",
720720
domain: [0],
721-
range: [d3.schemeBlues[3][0], d3.schemeBlues[3][2]],
721+
range: [d3.schemeBlues[3][1], d3.schemeBlues[3][2]],
722722
label: "body_mass_g"
723723
});
724724
});

0 commit comments

Comments
 (0)