Skip to content

Commit

Permalink
fix rendering of one-dimensional rects (#817)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock authored Mar 21, 2022
1 parent db209c5 commit e466abe
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/marks/rect.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class Rect extends Mark {
const {insetTop, insetRight, insetBottom, insetLeft, dx, dy, rx, ry} = this;
return create("svg:g")
.call(applyIndirectStyles, this, dimensions)
.call(applyTransform, x, y, dx, dy)
.call(applyTransform, X1 && X2 ? x : null, Y1 && Y2 ? y : null, dx, dy)
.call(g => g.selectAll()
.data(index)
.enter()
Expand Down
72 changes: 72 additions & 0 deletions test/output/rectBand.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions test/plots/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export {default as randomBins} from "./random-bins.js";
export {default as randomBinsXY} from "./random-bins-xy.js";
export {default as randomQuantile} from "./random-quantile.js";
export {default as randomWalk} from "./random-walk.js";
export {default as rectBand} from "./rect-band.js";
export {default as seattlePrecipitationRule} from "./seattle-precipitation-rule.js";
export {default as seattleTemperatureBand} from "./seattle-temperature-band.js";
export {default as seattleTemperatureCell} from "./seattle-temperature-cell.js";
Expand Down
16 changes: 16 additions & 0 deletions test/plots/rect-band.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as Plot from "@observablehq/plot";

export default async function() {
return Plot.plot({
y: {
type: "band",
domain: "ABC",
grid: true
},
marks: [
Plot.frame(),
Plot.barX({length: 1}, {x1: [0], x2: [1], fill: "cyan", mixBlendMode: "multiply"}),
Plot.rectX({length: 1}, {x1: [0], x2: [1], fill: "magenta", mixBlendMode: "multiply"})
]
});
}

0 comments on commit e466abe

Please sign in to comment.