Skip to content

remove default white background #1489

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

Merged
merged 4 commits into from
Oct 27, 2023
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 5 additions & 15 deletions docs/.vitepress/theme/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@

.vp-doc .plot,
.vp-doc .plot-ramp {
background: none;
--plot-background: var(--vp-c-bg);
overflow: visible;
position: relative;
z-index: 1;
}

.vp-doc .plot [aria-label="tip"] {
--plot-background: var(--vp-c-bg-alt);
}

.vp-doc .plot-figure {
margin: 16px 0 0;
}
Expand All @@ -71,20 +75,6 @@
text-decoration: initial;
}

:root [aria-label="tip"][fill="white"],
:root [aria-label="tip"] [fill="white"] {
fill: var(--vp-c-bg-alt);
}

:root.dark marker[stroke="white"],
:root.dark [aria-label^="crosshair"][stroke="white"] {
stroke: var(--vp-c-bg);
}

:root.dark marker[fill="white"] {
fill: var(--vp-c-bg);
}

.vp-doc :not(pre) > code {
line-height: 1.5;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/features/plots.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ Plot.plot({
```
:::

The **style** option allows custom styles to override Plot’s defaults. It may be specified either as a string of inline styles (*e.g.*, `"color: red;"`, in the same fashion as assigning [*element*.style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style)) or an object of properties (*e.g.*, `{color: "red"}`, in the same fashion as assigning [*element*.style properties](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration)). By default, the returned plot has a white background, a max-width of 100%, and the system-ui font. Plot’s marks and axes default to [currentColor](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#currentcolor_keyword), meaning that they will inherit the surrounding content’s color.
The **style** option allows custom styles to override Plot’s defaults. It may be specified either as a string of inline styles (*e.g.*, `"color: red;"`, in the same fashion as assigning [*element*.style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style)) or an object of properties (*e.g.*, `{color: "red"}`, in the same fashion as assigning [*element*.style properties](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration)). By default, the returned plot has a max-width of 100%, and the system-ui font. Plot’s marks and axes default to [currentColor](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#currentcolor_keyword), meaning that they will inherit the surrounding content’s color.

:::warning CAUTION
Unitless numbers ([quirky lengths](https://www.w3.org/TR/css-values-4/#deprecated-quirky-length)) such as `{padding: 20}` are not supported by some browsers; you should instead specify a string with units such as `{padding: "20px"}`.
Expand Down
1 change: 0 additions & 1 deletion src/legends/ramp.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export function legendRamp(color, options) {
svg.append("style").text(
`.${className}-ramp {
display: block;
background: white;
height: auto;
height: intrinsic;
max-width: 100%;
Expand Down
4 changes: 2 additions & 2 deletions src/marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function markerCircleFill(color, context) {
.attr("markerWidth", 6.67)
.attr("markerHeight", 6.67)
.attr("fill", color)
.attr("stroke", "white")
.attr("stroke", "var(--plot-background)")
.attr("stroke-width", 1.5)
.call((marker) => marker.append("circle").attr("r", 3))
.node();
Expand All @@ -72,7 +72,7 @@ function markerCircleStroke(color, context) {
.attr("viewBox", "-5 -5 10 10")
.attr("markerWidth", 6.67)
.attr("markerHeight", 6.67)
.attr("fill", "white")
.attr("fill", "var(--plot-background)")
.attr("stroke", color)
.attr("stroke-width", 1.5)
.call((marker) => marker.append("circle").attr("r", 3))
Expand Down
2 changes: 1 addition & 1 deletion src/marks/crosshair.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function textOptions(k, pointerOptions, options) {
color = "currentColor",
textFill: fill = color,
textFillOpacity: fillOpacity,
textStroke: stroke = "white",
textStroke: stroke = "var(--plot-background)",
textStrokeOpacity: strokeOpacity,
textStrokeWidth: strokeWidth = 5
} = options;
Expand Down
2 changes: 1 addition & 1 deletion src/marks/tip.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {cut, clipper, splitter, maybeTextOverflow} from "./text.js";

const defaults = {
ariaLabel: "tip",
fill: "white",
fill: "var(--plot-background)",
stroke: "currentColor"
};

Expand Down
2 changes: 1 addition & 1 deletion src/marks/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function tree(
markerEnd = marker,
dot: dotDot = isNoneish(markerStart) && isNoneish(markerEnd),
text: textText = "node:name",
textStroke = "white",
textStroke = "var(--plot-background)",
title = "node:path",
dx,
dy,
Expand Down
14 changes: 3 additions & 11 deletions src/plot.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,9 @@ export interface PlotOptions extends ScaleDefaults {
* properties][2]). Note that unitless numbers ([quirky lengths][3]) such as
* `{padding: 20}` may not supported by some browsers; you should instead
* specify a string with units such as `{padding: "20px"}`. By default, the
* returned plot has a white background, a max-width of 100%, and the
* system-ui font. Plot’s marks and axes default to [currentColor][4], meaning
* that they will inherit the surrounding content’s color. For example, a dark
* theme:
*
* ```js
* Plot.plot({
* style: "background: black; color: white;",
* marks: …
* })
* ```
* returned plot has a max-width of 100%, and the system-ui font. Plot’s marks
* and axes default to [currentColor][4], meaning that they will inherit the
* surrounding content’s color.
*
* [1]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
* [2]: https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration
Expand Down
2 changes: 1 addition & 1 deletion src/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ export function plot(options = {}) {
// Warning: if you edit this, change defaultClassName.
svg.append("style").text(
`.${className} {
--plot-background: white;
display: block;
background: white;
height: auto;
height: intrinsic;
max-width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion test/output/aaplBollinger.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplBollingerCandlestick.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplBollingerGridInterval.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplBollingerGridSpacing.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplCandlestick.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplChangeVolume.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplClose.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplCloseClip.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplCloseDataTicks.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplCloseGridColor.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplCloseGridInterval.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplCloseGridIntervalName.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplCloseGridIterable.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplCloseImplicitGrid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplCloseNormalize.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplCloseUntyped.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplFancyAxis.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplInterval.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplMonthly.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplVolume.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/aaplVolumeRect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/anscombeQuartet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/arcCollatz.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/arcCollatzUp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/arcMiserables.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/armadillo.svg
Loading