-
Notifications
You must be signed in to change notification settings - Fork 197
Add support for margin to ordinal color legend. #1082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
da3a3e6
97bc43c
0ddd696
32e26ed
db49103
b7ffeb3
9a19a48
4d6a7c2
40ba5c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| import {path} from "d3"; | ||
| import {inferFontVariant} from "../axes.js"; | ||
| import {maybeAutoTickFormat} from "../axis.js"; | ||
| import {Context, create} from "../context.js"; | ||
| import {isNoneish, maybeColorChannel, maybeNumberChannel} from "../options.js"; | ||
| import {isOrdinalScale, isThresholdScale} from "../scales.js"; | ||
| import {applyInlineStyles, impliedString, maybeClassName} from "../style.js"; | ||
| import { path } from "d3"; | ||
| import { inferFontVariant } from "../axes.js"; | ||
| import { maybeAutoTickFormat } from "../axis.js"; | ||
| import { Context, create } from "../context.js"; | ||
| import { isNoneish, maybeColorChannel, maybeNumberChannel } from "../options.js"; | ||
| import { isOrdinalScale, isThresholdScale } from "../scales.js"; | ||
| import { applyInlineStyles, impliedString, maybeClassName } from "../style.js"; | ||
|
|
||
| function maybeScale(scale, key) { | ||
| if (key == null) return key; | ||
|
|
@@ -88,6 +88,9 @@ function legendItems(scale, options = {}, swatch, swatchStyle) { | |
| swatchSize = 15, | ||
| swatchWidth = swatchSize, | ||
| swatchHeight = swatchSize, | ||
| marginTop = 0, | ||
| marginRight = 0, | ||
| marginBottom = 0, | ||
| marginLeft = 0, | ||
| className, | ||
| style, | ||
|
|
@@ -170,18 +173,22 @@ function legendItems(scale, options = {}, swatch, swatchStyle) { | |
| div.insert("style", "*").text(` | ||
| .${className} { | ||
| font-family: system-ui, sans-serif; | ||
| font-size: 10px; | ||
| margin-bottom: 0.5em;${ | ||
| marginLeft === undefined | ||
| ? "" | ||
| : ` | ||
| margin-left: ${+marginLeft}px;` | ||
| }${ | ||
| width === undefined | ||
| font-size: 10px;${marginTop === undefined | ||
| ? "" | ||
| : ` | ||
| width: ${width}px;` | ||
| } | ||
| : `margin-top: ${+marginTop}px;` | ||
| }${marginRight === undefined | ||
| ? "" | ||
| : `margin-right: ${+marginRight}px;` | ||
| }${marginBottom === undefined | ||
| ? `margin-bottom: 0.5em;` | ||
| : `margin-bottom: ${+marginBottom}px;` | ||
|
||
| }${marginLeft === undefined | ||
| ? "" | ||
| : `margin-left: ${+marginLeft}px;` | ||
| }${width === undefined | ||
| ? "" | ||
| : `width: ${width}px;` | ||
| } | ||
| } | ||
| ${swatchStyle(className)} | ||
| ${extraStyle} | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.