Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite2d384b

Browse files
committed
fix: don't lose missing values in stacking
1 parent971886a commite2d384b

File tree

7 files changed

+10
-6
lines changed

7 files changed

+10
-6
lines changed

‎src/lib/helpers/resolve.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function resolveProp<K, T>(
3030
// so we're passing the original value to accessor functions instead of our wrapped record
3131
returndatum==null
3232
?accessor()
33-
:accessor(datum[RAW_VALUE]!=null ?datum[RAW_VALUE] :datum,datum[INDEX]);
33+
:accessor(datum.hasOwnProperty(RAW_VALUE) ?datum[RAW_VALUE] :datum,datum[INDEX]);
3434
}elseif(
3535
(typeofaccessor==='string'||typeofaccessor==='symbol')&&
3636
datum&&

‎src/lib/transforms/stack.test.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ describe('stackX transform', () => {
212212
});
213213

214214
it('stacks recordized array',()=>{
215-
constdata=[10,20,30,40];
215+
constdata=[10,20,30,undefined,40];
216216
const{data:stackedData, ...channels}=stackX(recordizeX({ data,x1:0,x2:0}));
217217
const{ y, x1, x2}=channels;
218218
constresult=stackedData.map((d)=>({
@@ -224,7 +224,8 @@ describe('stackX transform', () => {
224224
{y:0,x1:0,x2:10},
225225
{y:1,x1:0,x2:20},
226226
{y:2,x1:0,x2:30},
227-
{y:3,x1:0,x2:40}
227+
{y:3,x1:0,x2:NaN},
228+
{y:4,x1:0,x2:40}
228229
]);
229230
});
230231
});

‎src/lib/transforms/stack.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function stackXY<T>(
179179
)
180180
.keys(keys)
181181
.value((d,key,i,data)=>{
182-
returnd[key]?.v;
182+
returnd[key]?.v==null ?undefined :d[key]?.v;
183183
})(stackData);
184184

185185
// and combine it all back into a flat array

‎src/routes/examples/area/from-numbers.svelte‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
</script>
1010

1111
<Plotgrid>
12-
<AreaYdata={[1.5,2,3.5,2.5,5.5,8.5,6]} />
12+
<AreaYdata={[1,3,2,4,undefined,6,8,7]} />
1313
</Plot>

‎src/routes/marks/area/+page.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ In order to interpolate across undefined values you need to filter them, e.g. us
9191
9292
<Plot grid height={255}>
9393
<AreaY
94-
filter={(d) => d !== undefined}
94+
filter={(d) => {
95+
console.log(d);
96+
return d !== undefined;
97+
}}
9598
canvas={$useCanvas}
9699
data={[
97100
1.5,
-1.39 KB
Loading
-1.45 KB
Loading

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp