Skip to content

Commit 989431f

Browse files
committed
fix: line chart grouping (resolves #45)
1 parent 36a337e commit 989431f

File tree

5 files changed

+38
-21
lines changed

5 files changed

+38
-21
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"svg-path-parser": "^1.1.0",
9494
"topojson-client": "^3.1.0",
9595
"tslib": "^2.8.1",
96-
"typedoc": "^0.28.4",
96+
"typedoc": "^0.28.5",
9797
"typedoc-plugin-markdown": "^4.6.3",
9898
"typescript": "^5.8.3",
9999
"vite": "^6.3.5",

pnpm-lock.yaml

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/marks/Line.svelte

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
outlineStroke?: string;
2222
outlineStrokeWidth?: number;
2323
outlineStrokeOpacity?: number;
24-
curve?: CurveName | CurveFactory;
24+
curve?: CurveName | CurveFactory | 'auto';
2525
tension?: number;
2626
sort?: ConstantAccessor<RawValue> | { channel: 'stroke' | 'fill' };
2727
text?: ConstantAccessor<string>;
@@ -76,10 +76,6 @@
7676
if (groupValue === lastGroupValue) {
7777
group.push(d);
7878
} else {
79-
if (group.length === 1) {
80-
// just one point makes a bad line, add this one, too
81-
group.push(d);
82-
}
8379
// new group
8480
group = [d];
8581
groups.push(group);

src/routes/transforms/jitter/+page.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,6 @@ The jitter transform accepts the following options:
7676
- Useful for deterministic jittering (testing or reproducibility)
7777
- Can be used with d3's random generators: `randomLcg()` from d3-random
7878

79-
The following time interval strings are supported for temporal jittering:
80-
81-
- `'1 day'`, `'3 days'`
82-
- `'1 week'`, `'2 weeks'`, `'3 weeks'`
83-
- `'1 month'`, `'2 months'`
84-
- `'1 quarter'`
85-
- `'1 year'`
8679

8780
## jitterX
8881

src/tests/line.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,32 @@ describe('Line mark', () => {
227227
// Verify we have two distinct lines with different stroke colors
228228
expect(lines[0]?.style.stroke).not.toBe(lines[1]?.style.stroke);
229229
});
230+
231+
it('does not connect points from different groups', () => {
232+
233+
const { container } = render(LineTest, {
234+
props: {
235+
data: [
236+
{ x: 0, y: 0, category: 'A' },
237+
{ x: 1, y: 1, category: 'A' },
238+
{ x: 0, y: 1, category: 'B' },
239+
{ x: 0.5, y: 1, category: 'C' }
240+
],
241+
x: 'x',
242+
y: 'y',
243+
z: 'category'
244+
}
245+
});
246+
247+
const lines = container.querySelectorAll(
248+
'g.lines > g > path'
249+
) as NodeListOf<SVGPathElement>;
250+
expect(lines).toHaveLength(3);
251+
252+
const ds = Array.from(lines).map(l => l.getAttribute('d'));
253+
expect(ds[0]).toBe('M1,95L96,5');
254+
expect(ds[1]).toBe('M1,5Z');
255+
expect(ds[2]).toBe('M48.5,5Z');
256+
257+
})
230258
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy