Skip to content

area line option#2133

Open
Fil wants to merge 11 commits intomainfrom
fil/area-line
Open

area line option#2133
Fil wants to merge 11 commits intomainfrom
fil/area-line

Conversation

@Fil
Copy link
Copy Markdown
Contributor

@Fil Fil commented Aug 12, 2024

Adding a line option to the area mark makes it quite a bit more convenient to use than the areaY + lineY combo.

closes #1866 (line option on the area mark)
closes #2111 (The ridgeline plot example doesn’t handle overlapping correctly)

will need to update https://observablehq.com/@observablehq/plot-ridgeline

needs (and rebased on) #2390 (stack invalid values as NaN)

@Fil Fil changed the base branch from main to fil/stack-nan March 19, 2026 13:04
.call(applyDirectStyles, this)
.call(applyGroupedChannelStyles, this, channels)
.attr("fill", "none")
.attr("transform", offset ? `translate(${offset},${offset})` : null)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a bit unfortunate that we have to care for offset here; reason is that the area mark doesn't have an offset, but the line mark has one.

reduce: sum,
curve: "step"
}),
Plot.areaY(data, {x: "date", y: "value", interval: "day", curve: "step", fill: "#f2f2fe", line: true}),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is even further simplification from #2389

@Fil Fil requested a review from mbostock March 19, 2026 13:14
@Fil Fil marked this pull request as ready for review March 19, 2026 13:14
@Fil Fil mentioned this pull request Mar 19, 2026
Base automatically changed from fil/stack-nan to main April 1, 2026 16:34
Copy link
Copy Markdown
Member

@mbostock mbostock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the feature, but it needs a little more work.

I’d like it to work “out of the box” if you add line: true to an area. Right now you also need to set fillOpacity: 0.3 or set fill to a different color than stroke (since both default to currentColor). Probably defaulting fillOpacity to 0.3 if line is true is simplest.

It makes sense that stroke is disabled on the area path when using the line option, but probably other stroke-related attributes should also not be set on the area path. (See “Some marks don’t support stroke (e.g., image)” in style.js.) Ideally we’d avoid setting these attributes, rather than setting them and then immediately setting them back to none.

It also makes sense that we don’t support projections here (auto curve; see the line mark). But what about applyGroupedMarkers? Should we accept marker options if you set the line option? Or maybe in all cases (but just shift the markers to the line if you set the line option)? Are there any other inconsistencies with the line mark implementation here?

@Fil
Copy link
Copy Markdown
Contributor Author

Fil commented Apr 4, 2026

I've started work on your review comments here #2405. More later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The ridgeline plot example doesn’t handle overlapping correctly Add a line option to the area mark

2 participants