Skip to content

Commit

Permalink
legends
Browse files Browse the repository at this point in the history
  • Loading branch information
Fil committed Oct 2, 2024
1 parent b703132 commit cac2324
Show file tree
Hide file tree
Showing 120 changed files with 1,935 additions and 1,933 deletions.
2 changes: 2 additions & 0 deletions src/legends/ramp.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export function legendRamp(color, options) {
if (tickFormat === null) tickFormat = () => null;

const svg = create("svg", context)
.attr("xmlns", "http://www.w3.org/2000/svg")
.attr("xmlns:xlink", "http://www.w3.org/1999/xlink")
.attr("class", `${className}-ramp`)
.attr("font-family", "system-ui, sans-serif")
.attr("font-size", 10)
Expand Down
4 changes: 4 additions & 0 deletions src/legends/swatches.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export function legendSwatches(color, {opacity, ...options} = {}) {
return legendItems(color, options, (selection, scale, width, height) =>
selection
.append("svg")
.attr("xmlns", "http://www.w3.org/2000/svg")
.attr("xmlns:xlink", "http://www.w3.org/1999/xlink")
.attr("width", width)
.attr("height", height)
.attr("fill", scale.scale)
Expand Down Expand Up @@ -53,6 +55,8 @@ export function legendSymbols(
return legendItems(symbol, options, (selection, scale, width, height) =>
selection
.append("svg")
.attr("xmlns", "http://www.w3.org/2000/svg")
.attr("xmlns:xlink", "http://www.w3.org/1999/xlink")
.attr("viewBox", "-8 -8 16 16")
.attr("width", width)
.attr("height", height)
Expand Down
20 changes: 10 additions & 10 deletions test/output/athletesSortNationality.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@
align-items: center;
margin-right: 1em;
}
</style><span class="plot-swatch"><svg width="15" height="15" fill="#4269d0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</style><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#4269d0">
<rect width="100%" height="100%"></rect>
</svg>ESP</span><span class="plot-swatch"><svg width="15" height="15" fill="#efb118" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>ESP</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#efb118">
<rect width="100%" height="100%"></rect>
</svg>KOR</span><span class="plot-swatch"><svg width="15" height="15" fill="#ff725c" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>KOR</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#ff725c">
<rect width="100%" height="100%"></rect>
</svg>CAN</span><span class="plot-swatch"><svg width="15" height="15" fill="#6cc5b0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>CAN</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#6cc5b0">
<rect width="100%" height="100%"></rect>
</svg>MDA</span><span class="plot-swatch"><svg width="15" height="15" fill="#3ca951" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>MDA</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#3ca951">
<rect width="100%" height="100%"></rect>
</svg>NZL</span><span class="plot-swatch"><svg width="15" height="15" fill="#ff8ab7" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>NZL</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#ff8ab7">
<rect width="100%" height="100%"></rect>
</svg>AUS</span><span class="plot-swatch"><svg width="15" height="15" fill="#a463f2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>AUS</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#a463f2">
<rect width="100%" height="100%"></rect>
</svg>USA</span><span class="plot-swatch"><svg width="15" height="15" fill="#97bbf5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>USA</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#97bbf5">
<rect width="100%" height="100%"></rect>
</svg>ETH</span><span class="plot-swatch"><svg width="15" height="15" fill="#9c6b4e" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>ETH</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#9c6b4e">
<rect width="100%" height="100%"></rect>
</svg>BRN</span><span class="plot-swatch"><svg width="15" height="15" fill="#9498a0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>BRN</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#9498a0">
<rect width="100%" height="100%"></rect>
</svg>IOA</span>
</div><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="plot" fill="currentColor" font-family="system-ui, sans-serif" font-size="10" text-anchor="middle" width="640" height="400" viewBox="0 0 640 400">
Expand Down
20 changes: 10 additions & 10 deletions test/output/athletesSortNullLimit.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@
align-items: center;
margin-right: 1em;
}
</style><span class="plot-swatch"><svg width="15" height="15" fill="#4269d0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</style><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#4269d0">
<rect width="100%" height="100%"></rect>
</svg>ESP</span><span class="plot-swatch"><svg width="15" height="15" fill="#efb118" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>ESP</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#efb118">
<rect width="100%" height="100%"></rect>
</svg>KOR</span><span class="plot-swatch"><svg width="15" height="15" fill="#ff725c" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>KOR</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#ff725c">
<rect width="100%" height="100%"></rect>
</svg>CAN</span><span class="plot-swatch"><svg width="15" height="15" fill="#6cc5b0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>CAN</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#6cc5b0">
<rect width="100%" height="100%"></rect>
</svg>MDA</span><span class="plot-swatch"><svg width="15" height="15" fill="#3ca951" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>MDA</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#3ca951">
<rect width="100%" height="100%"></rect>
</svg>NZL</span><span class="plot-swatch"><svg width="15" height="15" fill="#ff8ab7" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>NZL</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#ff8ab7">
<rect width="100%" height="100%"></rect>
</svg>AUS</span><span class="plot-swatch"><svg width="15" height="15" fill="#a463f2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>AUS</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#a463f2">
<rect width="100%" height="100%"></rect>
</svg>USA</span><span class="plot-swatch"><svg width="15" height="15" fill="#97bbf5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>USA</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#97bbf5">
<rect width="100%" height="100%"></rect>
</svg>ETH</span><span class="plot-swatch"><svg width="15" height="15" fill="#9c6b4e" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>ETH</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#9c6b4e">
<rect width="100%" height="100%"></rect>
</svg>BRN</span><span class="plot-swatch"><svg width="15" height="15" fill="#9498a0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>BRN</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#9498a0">
<rect width="100%" height="100%"></rect>
</svg>IOA</span>
</div><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="plot" fill="currentColor" font-family="system-ui, sans-serif" font-size="10" text-anchor="middle" width="640" height="400" viewBox="0 0 640 400">
Expand Down
2 changes: 1 addition & 1 deletion test/output/bigintOrdinal.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<figure class="plot-d6a7b5-figure" style="max-width: initial;"><svg class="plot-ramp" font-family="system-ui, sans-serif" font-size="10" width="240" height="50" viewBox="0 0 240 50" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<figure class="plot-d6a7b5-figure" style="max-width: initial;"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="plot-ramp" font-family="system-ui, sans-serif" font-size="10" width="240" height="50" viewBox="0 0 240 50">
<style>
:where(.plot-ramp) {
display: block;
Expand Down
6 changes: 3 additions & 3 deletions test/output/binFillFirstEmpty.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
align-items: center;
margin-right: 1em;
}
</style><span class="plot-swatch"><svg width="15" height="15" fill="#4269d0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</style><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#4269d0">
<rect width="100%" height="100%"></rect>
</svg>FEMALE</span><span class="plot-swatch"><svg width="15" height="15" fill="#efb118" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>FEMALE</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#efb118">
<rect width="100%" height="100%"></rect>
</svg>MALE</span><span class="plot-swatch"><svg width="15" height="15" fill="#ff725c" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>MALE</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#ff725c">
<rect width="100%" height="100%"></rect>
</svg>null</span>
</div><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="plot" fill="currentColor" font-family="system-ui, sans-serif" font-size="10" text-anchor="middle" width="640" height="400" viewBox="0 0 640 400">
Expand Down
6 changes: 3 additions & 3 deletions test/output/caltrain.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
align-items: center;
margin-right: 1em;
}
</style><span class="plot-swatch"><svg width="15" height="15" fill="currentColor" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</style><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="currentColor">
<rect width="100%" height="100%"></rect>
</svg>N</span><span class="plot-swatch"><svg width="15" height="15" fill="peru" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>N</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="peru">
<rect width="100%" height="100%"></rect>
</svg>L</span><span class="plot-swatch"><svg width="15" height="15" fill="brown" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>L</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="brown">
<rect width="100%" height="100%"></rect>
</svg>B</span>
</div><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="plot" fill="currentColor" font-family="system-ui, sans-serif" font-size="10" text-anchor="middle" width="240" height="520" viewBox="0 0 240 520">
Expand Down
2 changes: 1 addition & 1 deletion test/output/carsHexbin.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<figure class="plot-d6a7b5-figure" style="max-width: initial;"><svg class="plot-ramp" font-family="system-ui, sans-serif" font-size="10" width="240" height="50" viewBox="0 0 240 50" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<figure class="plot-d6a7b5-figure" style="max-width: initial;"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="plot-ramp" font-family="system-ui, sans-serif" font-size="10" width="240" height="50" viewBox="0 0 240 50">
<style>
:where(.plot-ramp) {
display: block;
Expand Down
2 changes: 1 addition & 1 deletion test/output/carsJitter.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<figure class="plot-d6a7b5-figure" style="max-width: initial;"><svg class="plot-ramp" font-family="system-ui, sans-serif" font-size="10" width="240" height="50" viewBox="0 0 240 50" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<figure class="plot-d6a7b5-figure" style="max-width: initial;"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="plot-ramp" font-family="system-ui, sans-serif" font-size="10" width="240" height="50" viewBox="0 0 240 50">
<style>
:where(.plot-ramp) {
display: block;
Expand Down
20 changes: 10 additions & 10 deletions test/output/colorLegendCategorical.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@
align-items: center;
margin-right: 1em;
}
</style><span class="plot-swatch"><svg width="15" height="15" fill="#4269d0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</style><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#4269d0">
<rect width="100%" height="100%"></rect>
</svg>A</span><span class="plot-swatch"><svg width="15" height="15" fill="#efb118" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>A</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#efb118">
<rect width="100%" height="100%"></rect>
</svg>B</span><span class="plot-swatch"><svg width="15" height="15" fill="#ff725c" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>B</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#ff725c">
<rect width="100%" height="100%"></rect>
</svg>C</span><span class="plot-swatch"><svg width="15" height="15" fill="#6cc5b0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>C</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#6cc5b0">
<rect width="100%" height="100%"></rect>
</svg>D</span><span class="plot-swatch"><svg width="15" height="15" fill="#3ca951" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>D</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#3ca951">
<rect width="100%" height="100%"></rect>
</svg>E</span><span class="plot-swatch"><svg width="15" height="15" fill="#ff8ab7" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>E</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#ff8ab7">
<rect width="100%" height="100%"></rect>
</svg>F</span><span class="plot-swatch"><svg width="15" height="15" fill="#a463f2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>F</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#a463f2">
<rect width="100%" height="100%"></rect>
</svg>G</span><span class="plot-swatch"><svg width="15" height="15" fill="#97bbf5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>G</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#97bbf5">
<rect width="100%" height="100%"></rect>
</svg>H</span><span class="plot-swatch"><svg width="15" height="15" fill="#9c6b4e" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>H</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#9c6b4e">
<rect width="100%" height="100%"></rect>
</svg>I</span><span class="plot-swatch"><svg width="15" height="15" fill="#9498a0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>I</span><span class="plot-swatch"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" fill="#9498a0">
<rect width="100%" height="100%"></rect>
</svg>J</span>
</div>
Loading

0 comments on commit cac2324

Please sign in to comment.