Skip to content

Commit 129d89d

Browse files
committed
strokeWidth defaults to 1.5
1 parent 5a334a4 commit 129d89d

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

docs/marks/area.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Plot.areaY(aapl, {x: "Date", y: "Close"}).plot()
2020

2121
The area mark has three constructors: [areaY](#areaY) for when the baseline and topline share *x* values, as in a time-series area chart where time goes right→ (or ←left); [areaX](#areaX) for when the baseline and topline share *y* values, as in a time-series area chart where time goes up↑ (or down↓); and lastly the rarely-used [area](#area) where the baseline and topline share neither *x* nor *y* values.
2222

23-
The area mark is often paired with a [line](./line.md) and [rule](./rule.md) mark to accentuate the topline and baseline.
23+
The area mark is often paired with a [rule](./rule.md) to accentuate the baseline, and the [**line** option](#area-options) to accentuate the topline.
2424

2525
:::plot https://observablehq.com/@observablehq/plot-area-and-line
2626
```js
@@ -29,8 +29,7 @@ Plot.plot({
2929
grid: true
3030
},
3131
marks: [
32-
Plot.areaY(aapl, {x: "Date", y: "Close", fillOpacity: 0.3}),
33-
Plot.lineY(aapl, {x: "Date", y: "Close"}),
32+
Plot.areaY(aapl, {x: "Date", y: "Close", fillOpacity: 0.3, line: true}),
3433
Plot.ruleY([0])
3534
]
3635
})
@@ -94,8 +93,7 @@ Plot.plot({
9493
reverse: true
9594
},
9695
marks: [
97-
Plot.areaY(aapl, {x: "Date", y: "Close", fillOpacity: 0.3}),
98-
Plot.lineY(aapl, {x: "Date", y: "Close"}),
96+
Plot.areaY(aapl, {x: "Date", y: "Close", fillOpacity: 0.3, line: true}),
9997
Plot.ruleY([0])
10098
]
10199
})
@@ -111,8 +109,7 @@ Plot.plot({
111109
grid: true
112110
},
113111
marks: [
114-
Plot.areaX(aapl, {y: "Date", x: "Close", fillOpacity: 0.3}),
115-
Plot.lineX(aapl, {y: "Date", x: "Close"}),
112+
Plot.areaX(aapl, {y: "Date", x: "Close", fillOpacity: 0.3, line: true}),
116113
Plot.ruleX([0])
117114
]
118115
})
@@ -128,8 +125,7 @@ Plot.plot({
128125
grid: true
129126
},
130127
marks: [
131-
Plot.areaY(aapl, {x: "Date", y: (d) => d.Date.getUTCMonth() < 3 ? NaN : d.Close, fillOpacity: 0.3}),
132-
Plot.lineY(aapl, {x: "Date", y: (d) => d.Date.getUTCMonth() < 3 ? NaN : d.Close}),
128+
Plot.areaY(aapl, {x: "Date", y: (d) => d.Date.getUTCMonth() < 3 ? NaN : d.Close, fillOpacity: 0.3, line: true}),
133129
Plot.ruleY([0])
134130
]
135131
})
@@ -300,7 +296,7 @@ Points along the baseline and topline are connected in input order. Likewise, if
300296

301297
The area mark supports [curve options](../features/curves.md) to control interpolation between points. If any of the **x1**, **y1**, **x2**, or **y2** values are invalid (undefined, null, or NaN), the baseline and topline will be interrupted, resulting in a break that divides the area shape into multiple segments. (See [d3-shape’s *area*.defined](https://d3js.org/d3-shape/area#area_defined) for more.) If an area segment consists of only a single point, it may appear invisible unless rendered with rounded or square line caps. In addition, some curves such as *cardinal-open* only render a visible segment if it contains multiple points.
302298

303-
The **line** option <VersionBadge pr="2133" /> (boolean, defaults to false) indicates whether the mark should draw a line connecting the points with coordinates **x2** and **y2** (the “top of the area”). In that case, the **stroke** attribute defaults to *currentColor* and is applied to the line only, as well as the stroke opacity. The line uses the same **curve** as the area.
299+
The **line** option <VersionBadge pr=2133 /> (boolean, defaults to false) draws a line on the area along the topline (**x2**, **y2**). The **stroke** defaults to *currentColor*, the **strokeWidth** to 1.5, and both are only visible on the line (the area has no stroke); all other options apply to both.
304300

305301
## areaY(*data*, *options*) {#areaY}
306302

src/marks/area.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class Area extends Mark {
3535
z: {value: maybeZ(options), optional: true}
3636
},
3737
options,
38-
line ? {...defaults, stroke: "currentColor"} : defaults
38+
line ? {...defaults, stroke: "currentColor", strokeWidth: 1.5} : defaults
3939
);
4040
this.z = z;
4141
this.curve = maybeCurve(curve, tension);

0 commit comments

Comments
 (0)