arealineY custom mark

Plot allows the creation of custom composite marks, such as this one comprising a rule, area, and line:

function arealineY(data, {color, fillOpacity = 0.1, ...options} = {}) {
  return Plot.marks(
    Plot.ruleY([0]),
    Plot.areaY(data, {fill: color, fillOpacity, ...options}),
    Plot.lineY(data, {stroke: color, ...options})
  );
}

You can use this composite mark like any built-in mark:

arealineY(aapl, {x: "Date", y: "Close", color: "steelblue"}).plot()
const aapl = FileAttachment("data/AAPL.csv").csv({typed: true}).then(display);
✎ Suggest changes to this page