Skip to content
20 changes: 7 additions & 13 deletions src/marks/area.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ import {area as shapeArea} from "d3";
import {create} from "../context.js";
import {maybeCurve} from "../curve.js";
import {Mark} from "../mark.js";
import {first, indexOf, maybeZ, second} from "../options.js";
import {
applyDirectStyles,
applyIndirectStyles,
applyTransform,
applyGroupedChannelStyles,
groupIndex
} from "../style.js";
import {first, maybeZ, second} from "../options.js";
import {applyDirectStyles, applyIndirectStyles, applyTransform, applyGroupedChannelStyles} from "../style.js";
import {groupIndex} from "../style.js";
import {maybeDenseIntervalX, maybeDenseIntervalY} from "../transforms/bin.js";
import {maybeIdentityX, maybeIdentityY} from "../transforms/identity.js";
import {maybeStackX, maybeStackY} from "../transforms/stack.js";

const defaults = {
Expand Down Expand Up @@ -77,11 +71,11 @@ export function area(data, options) {
}

export function areaX(data, options) {
const {y = indexOf, ...rest} = maybeDenseIntervalY(options);
return new Area(data, maybeStackX(maybeIdentityX({...rest, y1: y, y2: undefined}, y === indexOf ? "x2" : "x")));
const {y, ...rest} = maybeDenseIntervalY(options);
return new Area(data, maybeStackX({...rest, y1: y, y2: undefined}));
}

export function areaY(data, options) {
const {x = indexOf, ...rest} = maybeDenseIntervalX(options);
return new Area(data, maybeStackY(maybeIdentityY({...rest, x1: x, x2: undefined}, x === indexOf ? "y2" : "y")));
const {x, ...rest} = maybeDenseIntervalX(options);
return new Area(data, maybeStackY({...rest, x1: x, x2: undefined}));
}
19 changes: 7 additions & 12 deletions src/marks/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ import {create} from "../context.js";
import {curveAuto, maybeCurveAuto} from "../curve.js";
import {Mark} from "../mark.js";
import {applyGroupedMarkers, markers} from "../marker.js";
import {coerceNumbers, indexOf, identity, maybeTuple, maybeZ} from "../options.js";
import {
applyDirectStyles,
applyIndirectStyles,
applyTransform,
applyGroupedChannelStyles,
groupIndex
} from "../style.js";
import {coerceNumbers, maybeTuple, maybeZ} from "../options.js";
import {applyDirectStyles, applyIndirectStyles, applyTransform, applyGroupedChannelStyles} from "../style.js";
import {groupIndex} from "../style.js";
import {maybeDenseIntervalX, maybeDenseIntervalY} from "../transforms/bin.js";

const defaults = {
Expand Down Expand Up @@ -103,10 +98,10 @@ export function line(data, {x, y, ...options} = {}) {
return new Line(data, {...options, x, y});
}

export function lineX(data, {x = identity, y = indexOf, ...options} = {}) {
return new Line(data, maybeDenseIntervalY({...options, x, y}));
export function lineX(data, options) {
return new Line(data, maybeDenseIntervalY(options));
}

export function lineY(data, {x = indexOf, y = identity, ...options} = {}) {
return new Line(data, maybeDenseIntervalX({...options, x, y}));
export function lineY(data, options) {
return new Line(data, maybeDenseIntervalX(options));
}
9 changes: 5 additions & 4 deletions src/transforms/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
coerceDate,
coerceNumbers,
identity,
indexOf,
isInterval,
isIterable,
isTemporal,
Expand Down Expand Up @@ -77,12 +78,12 @@ function maybeDenseInterval(bin, k, options = {}) {
return bin(outputs, options);
}

export function maybeDenseIntervalX(options = {}) {
return maybeDenseInterval(binX, "y", withTip(options, "x"));
export function maybeDenseIntervalX({y = identity, x = indexOf, ...options} = {}) {
return maybeDenseInterval(binX, "y", withTip({x, y, ...options}, "x"));
}

export function maybeDenseIntervalY(options = {}) {
return maybeDenseInterval(binY, "x", withTip(options, "y"));
export function maybeDenseIntervalY({x = identity, y = indexOf, ...options} = {}) {
return maybeDenseInterval(binY, "x", withTip({x, y, ...options}, "y"));
}

function binn(
Expand Down
64 changes: 64 additions & 0 deletions test/output/denseIntervalAreaX.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 64 additions & 0 deletions test/output/denseIntervalAreaY.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 64 additions & 0 deletions test/output/denseIntervalLineX.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading