Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/transforms/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,13 @@ export function bin(outputs = {fill: "count"}, options = {}) {
}

function maybeDenseInterval(bin, k, options = {}) {
return options?.interval == null
? options
: bin({[k]: options?.reduce === undefined ? reduceFirst : options.reduce, filter: null}, options);
if (options?.interval == null) return options;
const {reduce = reduceFirst} = options;
const outputs = {filter: null};
if (options[k] != null) outputs[k] = reduce;
if (options[`${k}1`] != null) outputs[`${k}1`] = reduce;
if (options[`${k}2`] != null) outputs[`${k}2`] = reduce;
return bin(outputs, options);
}

export function maybeDenseIntervalX(options = {}) {
Expand Down
53 changes: 53 additions & 0 deletions 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.
7 changes: 7 additions & 0 deletions test/plots/aapl-interval.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as Plot from "@observablehq/plot";
import * as d3 from "d3";

export async function aaplInterval() {
const aapl = await d3.csv<any>("data/aapl.csv", d3.autoType);
return Plot.areaY(aapl.slice(0, 81), {x: "Date", y1: "Low", y2: "High", interval: "day", curve: "step"}).plot();
}
1 change: 1 addition & 0 deletions test/plots/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from "./aapl-change-volume.js";
export * from "./aapl-close-untyped.js";
export * from "./aapl-close.js";
export * from "./aapl-fancy-axis.js";
export * from "./aapl-interval.js";
export * from "./aapl-monthly.js";
export * from "./aapl-volume-rect.js";
export * from "./aapl-volume.js";
Expand Down