Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/legends/swatches.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ function legendItems(scale, options = {}, swatch) {
swatchSize = 15,
swatchWidth = swatchSize,
swatchHeight = swatchSize,
marginLeft = 0,
marginTop,
marginBottom,
marginLeft,
marginRight,
className,
style,
width
Expand Down Expand Up @@ -153,7 +156,6 @@ function legendItems(scale, options = {}, swatch) {
`.${className}-swatches {
font-family: system-ui, sans-serif;
font-size: 10px;
margin-bottom: 0.5em;
}
.${className}-swatch > svg {
margin-right: 0.5em;
Expand All @@ -162,6 +164,9 @@ function legendItems(scale, options = {}, swatch) {
${extraStyle}`
)
)
.style("margin-top", marginTop ? `${+marginTop}px` : null)
.style("margin-right", marginRight ? `${+marginRight}px` : null)
.style("margin-bottom", `${marginBottom === undefined ? "0.5em" : `${+marginBottom}px`}`)
.style("margin-left", marginLeft ? `${+marginLeft}px` : null)
.style("width", width === undefined ? null : `${+width}px`)
.style("font-variant", impliedString(fontVariant, "normal"))
Expand Down
3 changes: 1 addition & 2 deletions test/output/athletesSortNationality.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<figure class="plot-d6a7b5-figure" style="max-width: initial;">
<div class="plot-swatches plot-swatches-wrap">
<div class="plot-swatches plot-swatches-wrap" style="margin-bottom: 0.5em;">
<style>
.plot-swatches {
font-family: system-ui, sans-serif;
font-size: 10px;
margin-bottom: 0.5em;
}

.plot-swatch>svg {
Expand Down
3 changes: 1 addition & 2 deletions test/output/athletesSortNullLimit.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<figure class="plot-d6a7b5-figure" style="max-width: initial;">
<div class="plot-swatches plot-swatches-wrap">
<div class="plot-swatches plot-swatches-wrap" style="margin-bottom: 0.5em;">
<style>
.plot-swatches {
font-family: system-ui, sans-serif;
font-size: 10px;
margin-bottom: 0.5em;
}

.plot-swatch>svg {
Expand Down
3 changes: 1 addition & 2 deletions test/output/binFillFirstEmpty.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<figure class="plot-d6a7b5-figure" style="max-width: initial;">
<div class="plot-swatches plot-swatches-wrap">
<div class="plot-swatches plot-swatches-wrap" style="margin-bottom: 0.5em;">
<style>
.plot-swatches {
font-family: system-ui, sans-serif;
font-size: 10px;
margin-bottom: 0.5em;
}

.plot-swatch>svg {
Expand Down
3 changes: 1 addition & 2 deletions test/output/caltrain.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<figure class="plot-d6a7b5-figure" style="max-width: initial;">
<div class="plot-swatches plot-swatches-wrap">
<div class="plot-swatches plot-swatches-wrap" style="margin-bottom: 0.5em;">
<style>
.plot-swatches {
font-family: system-ui, sans-serif;
font-size: 10px;
margin-bottom: 0.5em;
}

.plot-swatch>svg {
Expand Down
3 changes: 1 addition & 2 deletions test/output/colorLegendCategorical.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<div class="plot-swatches plot-swatches-wrap">
<div class="plot-swatches plot-swatches-wrap" style="margin-bottom: 0.5em;">
<style>
.plot-swatches {
font-family: system-ui, sans-serif;
font-size: 10px;
margin-bottom: 0.5em;
}

.plot-swatch>svg {
Expand Down
3 changes: 1 addition & 2 deletions test/output/colorLegendCategoricalColumns.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<div class="plot-swatches plot-swatches-columns" style="columns: 180px;">
<div class="plot-swatches plot-swatches-columns" style="columns: 180px; margin-bottom: 0.5em;">
<style>
.plot-swatches {
font-family: system-ui, sans-serif;
font-size: 10px;
margin-bottom: 0.5em;
}

.plot-swatch>svg {
Expand Down
3 changes: 1 addition & 2 deletions test/output/colorLegendCategoricalReverse.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<div class="plot-swatches plot-swatches-wrap">
<div class="plot-swatches plot-swatches-wrap" style="margin-bottom: 0.5em;">
<style>
.plot-swatches {
font-family: system-ui, sans-serif;
font-size: 10px;
margin-bottom: 0.5em;
}

.plot-swatch>svg {
Expand Down
3 changes: 1 addition & 2 deletions test/output/colorLegendCategoricalScheme.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<div class="plot-swatches plot-swatches-wrap">
<div class="plot-swatches plot-swatches-wrap" style="margin-bottom: 0.5em;">
<style>
.plot-swatches {
font-family: system-ui, sans-serif;
font-size: 10px;
margin-bottom: 0.5em;
}

.plot-swatch>svg {
Expand Down
3 changes: 1 addition & 2 deletions test/output/colorLegendOpacity.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<div class="plot-swatches plot-swatches-wrap">
<div class="plot-swatches plot-swatches-wrap" style="margin-bottom: 0.5em;">
<style>
.plot-swatches {
font-family: system-ui, sans-serif;
font-size: 10px;
margin-bottom: 0.5em;
}

.plot-swatch>svg {
Expand Down
3 changes: 1 addition & 2 deletions test/output/colorLegendOrdinal.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<div class="plot-swatches plot-swatches-wrap">
<div class="plot-swatches plot-swatches-wrap" style="margin-bottom: 0.5em;">
<style>
.plot-swatches {
font-family: system-ui, sans-serif;
font-size: 10px;
margin-bottom: 0.5em;
}

.plot-swatch>svg {
Expand Down
3 changes: 1 addition & 2 deletions test/output/colorLegendOrdinalScheme.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<div class="plot-swatches plot-swatches-wrap">
<div class="plot-swatches plot-swatches-wrap" style="margin-bottom: 0.5em;">
<style>
.plot-swatches {
font-family: system-ui, sans-serif;
font-size: 10px;
margin-bottom: 0.5em;
}

.plot-swatch>svg {
Expand Down
3 changes: 1 addition & 2 deletions test/output/colorLegendOrdinalTickFormat.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<div class="plot-swatches plot-swatches-wrap">
<div class="plot-swatches plot-swatches-wrap" style="margin-bottom: 0.5em;">
<style>
.plot-swatches {
font-family: system-ui, sans-serif;
font-size: 10px;
margin-bottom: 0.5em;
}

.plot-swatch>svg {
Expand Down
3 changes: 1 addition & 2 deletions test/output/colorLegendOrdinalTickFormatFunction.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<div class="plot-swatches plot-swatches-wrap">
<div class="plot-swatches plot-swatches-wrap" style="margin-bottom: 0.5em;">
<style>
.plot-swatches {
font-family: system-ui, sans-serif;
font-size: 10px;
margin-bottom: 0.5em;
}

.plot-swatch>svg {
Expand Down
3 changes: 1 addition & 2 deletions test/output/colorLegendQuantileSwatches.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<div class="plot-swatches plot-swatches-wrap" style="font-variant: tabular-nums;">
<div class="plot-swatches plot-swatches-wrap" style="margin-bottom: 0.5em; font-variant: tabular-nums;">
<style>
.plot-swatches {
font-family: system-ui, sans-serif;
font-size: 10px;
margin-bottom: 0.5em;
}

.plot-swatch>svg {
Expand Down
Loading