Skip to content

Commit 0e7c864

Browse files
authored
Merge pull request #67 from svelteplot/fix/line-grouping
fix: line chart grouping (resolves #45)
2 parents 36a337e + 6825029 commit 0e7c864

File tree

8 files changed

+88
-35
lines changed

8 files changed

+88
-35
lines changed

.github/workflows/npm-prerelease.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ on:
55
branches: [main]
66

77
permissions:
8-
contents: write
9-
pull-requests: write
8+
contents: write
9+
pull-requests: write
1010

1111
jobs:
1212
test:
1313
runs-on: ubuntu-latest
14-
14+
1515
steps:
1616
- uses: actions/checkout@v4
1717

@@ -32,16 +32,15 @@ jobs:
3232

3333
- name: Run Vitest tests
3434
run: pnpm test
35-
35+
3636
publish-preview:
3737
# Prevent this job from running on forks
38-
if: github.repository == 'svelteplot/svelteplot'
39-
if: github.event.pull_request.draft == false
38+
if: github.repository == 'svelteplot/svelteplot' && github.event.pull_request.draft == false
4039
needs: test
4140
runs-on: ubuntu-latest
4241
environment:
4342
name: npm
44-
43+
4544
steps:
4645
- uses: actions/checkout@v4
4746

@@ -56,7 +55,7 @@ jobs:
5655
with:
5756
node-version: '22'
5857
cache: 'pnpm'
59-
registry-url: "https://registry.npmjs.org"
58+
registry-url: 'https://registry.npmjs.org'
6059

6160
- name: Install dependencies
6261
run: pnpm install
@@ -100,8 +99,6 @@ jobs:
10099
101100
echo "Generated version: $(node -p "require('./package.json').version")"
102101
103-
104-
105102
- name: Publish to npm
106103
env:
107104
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH }}
@@ -110,14 +107,14 @@ jobs:
110107
# Save version for use in PR comment
111108
- name: Save version
112109
run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
113-
110+
114111
- name: Comment on PR
115112
uses: peter-evans/create-or-update-comment@v3
116113
with:
117114
issue-number: ${{ github.event.pull_request.number }}
118115
body: |
119116
📦 Preview package for this PR is published!
120-
117+
121118
Version: `${{ env.PACKAGE_VERSION }}`
122119
123120
Install it with:

.vscode/extensions.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"esbenp.prettier-vscode",
4+
"svelte.svelte-vscode",
5+
"dbaeumer.vscode-eslint",
6+
"typescript-svelte-plugin"
7+
]
8+
}

.vscode/settings.json

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,35 @@
1-
{}
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.defaultFormatter": "esbenp.prettier-vscode",
4+
"editor.codeActionsOnSave": {
5+
"source.fixAll.eslint": true
6+
},
7+
"[javascript]": {
8+
"editor.defaultFormatter": "esbenp.prettier-vscode"
9+
},
10+
"[typescript]": {
11+
"editor.defaultFormatter": "esbenp.prettier-vscode"
12+
},
13+
"[svelte]": {
14+
"editor.defaultFormatter": "esbenp.prettier-vscode"
15+
},
16+
"eslint.validate": [
17+
"javascript",
18+
"javascriptreact",
19+
"typescript",
20+
"typescriptreact",
21+
"svelte"
22+
],
23+
"prettier.useTabs": false,
24+
"prettier.singleQuote": true,
25+
"prettier.tabWidth": 4,
26+
"prettier.trailingComma": "none",
27+
"prettier.printWidth": 100,
28+
"svelte.plugin.svelte.format.enable": false,
29+
"eslint.probe": [
30+
"javascript",
31+
"typescript",
32+
"svelte"
33+
],
34+
"eslint.experimental.useFlatConfig": true
35+
}

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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +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'`
86-
8779
## jitterX
8880

8981
Jitters along the x dimension:

src/tests/line.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,30 @@ 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+
const { container } = render(LineTest, {
233+
props: {
234+
data: [
235+
{ x: 0, y: 0, category: 'A' },
236+
{ x: 1, y: 1, category: 'A' },
237+
{ x: 0, y: 1, category: 'B' },
238+
{ x: 0.5, y: 1, category: 'C' }
239+
],
240+
x: 'x',
241+
y: 'y',
242+
z: 'category'
243+
}
244+
});
245+
246+
const lines = container.querySelectorAll(
247+
'g.lines > g > path'
248+
) as NodeListOf<SVGPathElement>;
249+
expect(lines).toHaveLength(3);
250+
251+
const ds = Array.from(lines).map((l) => l.getAttribute('d'));
252+
expect(ds[0]).toBe('M1,95L96,5');
253+
expect(ds[1]).toBe('M1,5Z');
254+
expect(ds[2]).toBe('M48.5,5Z');
255+
});
230256
});

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