Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 4 additions & 3 deletions src/transforms/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,10 @@ function binn(
groupFacet.push(i++);
groupData.push(reduceData.reduceIndex(b, data, extent));
if (K) GK.push(k);
if (Z) GZ.push(G === Z ? f : Z[b[0]]);
if (F) GF.push(G === F ? f : F[b[0]]);
if (S) GS.push(G === S ? f : S[b[0]]);
const u = b.length === 0 ? g[0] : b[0];
if (Z) GZ.push(G === Z ? f : Z[u]);
if (F) GF.push(G === F ? f : F[u]);
if (S) GS.push(G === S ? f : S[u]);
if (BX1) BX1.push(extent.x1), BX2.push(extent.x2);
if (BY1) BY1.push(extent.y1), BY2.push(extent.y2);
for (const o of outputs) o.reduce(b, extent);
Expand Down
105 changes: 105 additions & 0 deletions test/output/integerIntervalArea.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<figure class="plot-d6a7b5-figure" style="max-width: initial;">
<div class="plot-swatches plot-swatches-wrap">
<style>
.plot-swatches {
font-family: system-ui, sans-serif;
font-size: 10px;
margin-bottom: 0.5em;
}

.plot-swatch>svg {
margin-right: 0.5em;
overflow: visible;
}

.plot-swatches-wrap {
display: flex;
align-items: center;
min-height: 33px;
flex-wrap: wrap;
}

.plot-swatches-wrap .plot-swatch {
display: inline-flex;
align-items: center;
margin-right: 1em;
}
</style><span class="plot-swatch"><svg width="15" height="15" fill="#4e79a7" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect width="100%" height="100%"></rect>
</svg>a</span><span class="plot-swatch"><svg width="15" height="15" fill="#f28e2c" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect width="100%" height="100%"></rect>
</svg>b</span>
</div><svg class="plot" fill="currentColor" font-family="system-ui, sans-serif" font-size="10" text-anchor="middle" width="640" height="400" viewBox="0 0 640 400" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<style>
.plot {
display: block;
background: white;
height: auto;
height: intrinsic;
max-width: 100%;
}

.plot text,
.plot tspan {
white-space: pre;
}
</style>
<g aria-label="y-axis tick" fill="none" stroke="currentColor" transform="translate(0,0.5)">
<path transform="translate(40,370)" d="M0,0L-6,0"></path>
<path transform="translate(40,326.25)" d="M0,0L-6,0"></path>
<path transform="translate(40,282.5)" d="M0,0L-6,0"></path>
<path transform="translate(40,238.75)" d="M0,0L-6,0"></path>
<path transform="translate(40,195)" d="M0,0L-6,0"></path>
<path transform="translate(40,151.25)" d="M0,0L-6,0"></path>
<path transform="translate(40,107.5)" d="M0,0L-6,0"></path>
<path transform="translate(40,63.75)" d="M0,0L-6,0"></path>
<path transform="translate(40,20)" d="M0,0L-6,0"></path>
</g>
<g aria-label="y-axis tick label" text-anchor="end" font-variant="tabular-nums" transform="translate(-8.5,0.5)">
<text y="0.32em" transform="translate(40,370)">0</text>
<text y="0.32em" transform="translate(40,326.25)">2</text>
<text y="0.32em" transform="translate(40,282.5)">4</text>
<text y="0.32em" transform="translate(40,238.75)">6</text>
<text y="0.32em" transform="translate(40,195)">8</text>
<text y="0.32em" transform="translate(40,151.25)">10</text>
<text y="0.32em" transform="translate(40,107.5)">12</text>
<text y="0.32em" transform="translate(40,63.75)">14</text>
<text y="0.32em" transform="translate(40,20)">16</text>
</g>
<g aria-label="y-axis label" text-anchor="start" transform="translate(-36.5,-16.5)">
<text y="0.71em" transform="translate(40,20)">↑ y</text>
</g>
<g aria-label="x-axis tick" fill="none" stroke="currentColor" transform="translate(0.5,0)">
<path transform="translate(69,370)" d="M0,0L0,6"></path>
<path transform="translate(127,370)" d="M0,0L0,6"></path>
<path transform="translate(185,370)" d="M0,0L0,6"></path>
<path transform="translate(243,370)" d="M0,0L0,6"></path>
<path transform="translate(301,370)" d="M0,0L0,6"></path>
<path transform="translate(359,370)" d="M0,0L0,6"></path>
<path transform="translate(417,370)" d="M0,0L0,6"></path>
<path transform="translate(475,370)" d="M0,0L0,6"></path>
<path transform="translate(533,370)" d="M0,0L0,6"></path>
<path transform="translate(591,370)" d="M0,0L0,6"></path>
</g>
<g aria-label="x-axis tick label" font-variant="tabular-nums" transform="translate(0.5,9.5)">
<text y="0.71em" transform="translate(69,370)">3</text>
<text y="0.71em" transform="translate(127,370)">4</text>
<text y="0.71em" transform="translate(185,370)">5</text>
<text y="0.71em" transform="translate(243,370)">6</text>
<text y="0.71em" transform="translate(301,370)">7</text>
<text y="0.71em" transform="translate(359,370)">8</text>
<text y="0.71em" transform="translate(417,370)">9</text>
<text y="0.71em" transform="translate(475,370)">10</text>
<text y="0.71em" transform="translate(533,370)">11</text>
<text y="0.71em" transform="translate(591,370)">12</text>
</g>
<g aria-label="x-axis label" text-anchor="end" transform="translate(17.5,27.5)">
<text transform="translate(620,370)">x →</text>
</g>
<g aria-label="area" fill-opacity="0.7" stroke-width="2" stroke-linejoin="round" stroke-linecap="round">
<path fill="#4e79a7" stroke="#4e79a7" d="M40,260.625L330,216.875L620,370L620,370L330,370L40,370Z"></path>
<path fill="#f28e2c" stroke="#f28e2c" d="M40,260.625L330,20L620,282.5L620,370L330,216.875L40,260.625Z"></path>
</g>
<g aria-label="tip" fill="white" stroke="currentColor" pointer-events="none" text-anchor="start" transform="translate(0.5,0.5)"></g>
</svg>
</figure>
100 changes: 100 additions & 0 deletions test/output/integerIntervalAreaZ.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<figure class="plot-d6a7b5-figure" style="max-width: initial;">
<div class="plot-swatches plot-swatches-wrap">
<style>
.plot-swatches {
font-family: system-ui, sans-serif;
font-size: 10px;
margin-bottom: 0.5em;
}

.plot-swatch>svg {
margin-right: 0.5em;
overflow: visible;
}

.plot-swatches-wrap {
display: flex;
align-items: center;
min-height: 33px;
flex-wrap: wrap;
}

.plot-swatches-wrap .plot-swatch {
display: inline-flex;
align-items: center;
margin-right: 1em;
}
</style><span class="plot-swatch"><svg width="15" height="15" fill="#a6cee3" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect width="100%" height="100%"></rect>
</svg>P</span><span class="plot-swatch"><svg width="15" height="15" fill="#1f78b4" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect width="100%" height="100%"></rect>
</svg>R</span><span class="plot-swatch"><svg width="15" height="15" fill="#b2df8a" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect width="100%" height="100%"></rect>
</svg>a</span><span class="plot-swatch"><svg width="15" height="15" fill="#33a02c" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect width="100%" height="100%"></rect>
</svg>b</span><span class="plot-swatch"><svg width="15" height="15" fill="#fb9a99" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect width="100%" height="100%"></rect>
</svg>c</span>
</div><svg class="plot" fill="currentColor" font-family="system-ui, sans-serif" font-size="10" text-anchor="middle" width="640" height="400" viewBox="0 0 640 400" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<style>
.plot {
display: block;
background: white;
height: auto;
height: intrinsic;
max-width: 100%;
}

.plot text,
.plot tspan {
white-space: pre;
}
</style>
<g aria-label="y-axis tick" fill="none" stroke="currentColor" transform="translate(0,0.5)">
<path transform="translate(40,370)" d="M0,0L-6,0"></path>
<path transform="translate(40,328.8235294117647)" d="M0,0L-6,0"></path>
<path transform="translate(40,287.6470588235294)" d="M0,0L-6,0"></path>
<path transform="translate(40,246.4705882352941)" d="M0,0L-6,0"></path>
<path transform="translate(40,205.2941176470588)" d="M0,0L-6,0"></path>
<path transform="translate(40,164.11764705882354)" d="M0,0L-6,0"></path>
<path transform="translate(40,122.94117647058823)" d="M0,0L-6,0"></path>
<path transform="translate(40,81.76470588235296)" d="M0,0L-6,0"></path>
<path transform="translate(40,40.58823529411765)" d="M0,0L-6,0"></path>
</g>
<g aria-label="y-axis tick label" text-anchor="end" font-variant="tabular-nums" transform="translate(-8.5,0.5)">
<text y="0.32em" transform="translate(40,370)">0</text>
<text y="0.32em" transform="translate(40,328.8235294117647)">2</text>
<text y="0.32em" transform="translate(40,287.6470588235294)">4</text>
<text y="0.32em" transform="translate(40,246.4705882352941)">6</text>
<text y="0.32em" transform="translate(40,205.2941176470588)">8</text>
<text y="0.32em" transform="translate(40,164.11764705882354)">10</text>
<text y="0.32em" transform="translate(40,122.94117647058823)">12</text>
<text y="0.32em" transform="translate(40,81.76470588235296)">14</text>
<text y="0.32em" transform="translate(40,40.58823529411765)">16</text>
</g>
<g aria-label="y-axis label" text-anchor="start" transform="translate(-36.5,-16.5)">
<text y="0.71em" transform="translate(40,20)">↑ y</text>
</g>
<g aria-label="x-axis tick" fill="none" stroke="currentColor" transform="translate(0.5,0)">
<path transform="translate(40,370)" d="M0,0L0,6"></path>
<path transform="translate(233.33333333333331,370)" d="M0,0L0,6"></path>
<path transform="translate(426.66666666666663,370)" d="M0,0L0,6"></path>
<path transform="translate(620,370)" d="M0,0L0,6"></path>
</g>
<g aria-label="x-axis tick label" font-variant="tabular-nums" transform="translate(0.5,9.5)">
<text y="0.71em" transform="translate(40,370)">0.0</text>
<text y="0.71em" transform="translate(233.33333333333331,370)">1.0</text>
<text y="0.71em" transform="translate(426.66666666666663,370)">2.0</text>
<text y="0.71em" transform="translate(620,370)">3.0</text>
</g>
<g aria-label="x-axis label" text-anchor="end" transform="translate(17.5,27.5)">
<text transform="translate(620,370)">x →</text>
</g>
<g aria-label="area" fill-opacity="0.7" stroke-width="2" stroke-linejoin="round" stroke-linecap="round">
<path fill="#b2df8a" stroke="#a6cee3" d="M40,267.059L233.333,225.882L426.667,370L620,370L620,370L426.667,370L233.333,370L40,370Z"></path>
<path fill="#33a02c" stroke="#a6cee3" d="M40,267.059L233.333,40.588L426.667,287.647L620,370L620,370L426.667,370L233.333,225.882L40,267.059Z"></path>
<path fill="#fb9a99" stroke="#1f78b4" d="M40,267.059L233.333,20L426.667,287.647L620,225.882L620,370L426.667,287.647L233.333,40.588L40,267.059Z"></path>
</g>
<g aria-label="tip" fill="white" stroke="currentColor" pointer-events="none" text-anchor="start" transform="translate(0.5,0.5)"></g>
</svg>
</figure>
52 changes: 52 additions & 0 deletions test/plots/integer-interval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,55 @@ export async function integerInterval() {
marks: [Plot.line(requests)]
});
}

export async function integerIntervalArea() {
const series = [
{x: 0, y: 5, type: "a"},
{x: 5, y: 7, type: "a"},
{x: 5, y: 9, type: "b"},
{x: 10, y: 4, type: "b"}
];
return Plot.plot({
color: {legend: true},
marks: [
Plot.areaY(series, {
interval: 5,
x: "x",
y: "y",
fill: "type",
stroke: "type",
strokeWidth: 2,
fillOpacity: 0.7,
tip: true
})
]
});
}

export async function integerIntervalAreaZ() {
const series = [
{x: 0, y: 5, type: "a", category: "P"},
{x: 1, y: 7, type: "a", category: "P"},
{x: 1, y: 9, type: "b", category: "P"},
{x: 2, y: 4, type: "b", category: "P"},
{x: 1, y: 1, type: "c", category: "R"},
{x: 3, y: 7, type: "c", category: "R"}
];
return Plot.plot({
x: {interval: 1},
color: {scheme: "Paired", legend: true},
marks: [
Plot.areaY(series, {
x: "x",
y: "y",
interval: 1,
fill: "type",
stroke: "category",
z: "type",
strokeWidth: 2,
fillOpacity: 0.7,
tip: true
})
]
});
}