Skip to content

Commit 93f953a

Browse files
authored
Auto mark: zero baseline default for rules (#1341)
* Auto mark: zero baseline default for rules * fix existing tests, commit new test output
1 parent c489290 commit 93f953a

File tree

3 files changed

+133
-2
lines changed

3 files changed

+133
-2
lines changed

src/marks/auto.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,10 @@ export function auto(data, options) {
216216

217217
// If zero-ness is not specified, default based on whether the resolved mark
218218
// type will include a zero baseline. TODO Move this to autoSpec.
219-
if (xZero === undefined) xZero = transform !== binX && (mark === barX || mark === areaX || mark === rectX);
220-
if (yZero === undefined) yZero = transform !== binY && (mark === barY || mark === areaY || mark === rectY);
219+
if (xZero === undefined)
220+
xZero = X && transform !== binX && (mark === barX || mark === areaX || mark === rectX || mark === ruleY);
221+
if (yZero === undefined)
222+
yZero = Y && transform !== binY && (mark === barY || mark === areaY || mark === rectY || mark === ruleX);
221223

222224
// In the case of filled marks (particularly bars and areas) the frame and
223225
// rules should come after the mark; in the case of stroked marks

test/output/autoRuleZero.svg

Lines changed: 124 additions & 0 deletions
Loading

test/plots/autoplot.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ export async function autoRectColorReducer() {
162162
return Plot.auto(penguins, {x: "culmen_length_mm", color: {value: "island", reduce: "mode"}}).plot();
163163
}
164164

165+
export async function autoRuleZero() {
166+
const athletes = await d3.csv<any>("data/athletes.csv", d3.autoType);
167+
return Plot.auto(athletes, {x: "date_of_birth", y: {value: "height", reduce: "mean"}, mark: "rule"}).plot();
168+
}
169+
165170
export async function autoLineColor() {
166171
const aapl = await d3.csv<any>("data/aapl.csv", d3.autoType);
167172
return Plot.auto(aapl, {x: "Date", y: "Close", color: "Close"}).plot();

0 commit comments

Comments
 (0)