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
18 changes: 9 additions & 9 deletions src/marks/auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,12 @@ export function auto(data, {x, y, color, size, fx, fy, mark} = {}) {
if (isOptions(fx)) ({value: fx} = makeOptions(fx));
if (isOptions(fy)) ({value: fy} = makeOptions(fy));

const {value: xValue} = x;
const {value: yValue} = y;
const {value: sizeValue} = size;
const {value: colorValue, color: colorColor} = color;
let {value: xValue, reduce: xReduce, ...xOptions} = x;
let {value: yValue, reduce: yReduce, ...yOptions} = y;
let {value: sizeValue, reduce: sizeReduce} = size;
let {value: colorValue, color: colorColor, reduce: colorReduce} = color;

// Determine the default reducer, if any.
let {reduce: xReduce} = x;
let {reduce: yReduce} = y;
let {reduce: sizeReduce} = size;
let {reduce: colorReduce} = color;
if (xReduce === undefined)
xReduce = yReduce == null && xValue == null && sizeValue == null && yValue != null ? "count" : null;
if (yReduce === undefined)
Expand Down Expand Up @@ -175,7 +171,11 @@ export function auto(data, {x, y, color, size, fx, fy, mark} = {}) {
transform = isOrdinal(y) ? groupY : binY;
}
}
if (transform) options = transform(transformOptions, options);
if (transform) {
if (transform === bin || transform === binX) options.x = {value: x, ...xOptions};
if (transform === bin || transform === binY) options.y = {value: y, ...yOptions};
options = transform(transformOptions, options);
}

// If zero-ness is not specified, default based on whether the resolved mark
// type will include a zero baseline.
Expand Down
58 changes: 58 additions & 0 deletions test/output/autoLineMeanThresholds.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions test/plots/autoplot.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ export async function autoLineMeanColor() {
return Plot.auto(athletes, {x: "date_of_birth", y: {value: "height", reduce: "mean"}, color: "sex"}).plot();
}

export async function autoLineMeanThresholds() {
const weather = await d3.csv("data/seattle-weather.csv", d3.autoType);
return Plot.auto(weather, {x: {value: "date", thresholds: "month"}, y: {value: "temp_max", reduce: "mean"}}).plot();
}

export async function autoLineFacet() {
const industries = await d3.csv("data/bls-industry-unemployment.csv", d3.autoType);
return Plot.auto(industries, {x: "date", y: "unemployed", fy: "industry"}).plot();
Expand Down