Skip to content

Commit 31feedf

Browse files
Merge branch 'main' of github.com:svelteplot/svelteplot into examples
2 parents c09264d + 8e106d5 commit 31feedf

35 files changed

+615
-257
lines changed

eslint.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ import svelteParser from 'svelte-eslint-parser';
33
import tsParser from '@typescript-eslint/parser';
44

55
export default [
6+
{
7+
rules: {
8+
'no-console': ['error', { allow: ['error'] }]
9+
}
10+
},
611
...svelte.configs.recommended,
712
{
813
files: ['**/*.svelte', '*.svelte'],
914
rules: {
10-
'svelte/no-object-in-text-mustaches': 'warn'
15+
'svelte/no-object-in-text-mustaches': 'warn',
16+
'svelte/no-inspect': 'warn'
1117
},
1218
ignores: ['dist/*', '.sveltepress/*'],
1319
languageOptions: {

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@
7272
"@types/d3-scale": "^4.0.9",
7373
"@types/d3-scale-chromatic": "^3.1.0",
7474
"@types/d3-shape": "^3.1.7",
75-
"@typescript-eslint/eslint-plugin": "^8.32.1",
76-
"@typescript-eslint/parser": "^8.32.1",
75+
"@typescript-eslint/eslint-plugin": "^8.33.0",
76+
"@typescript-eslint/parser": "^8.33.0",
7777
"csstype": "^3.1.3",
7878
"d3-dsv": "^3.0.1",
7979
"d3-fetch": "^3.0.1",
8080
"d3-force": "^3.0.0",
81-
"eslint": "^9.27.0",
81+
"eslint": "^9.28.0",
8282
"eslint-config-prettier": "^10.1.5",
8383
"eslint-plugin-svelte": "3.9.0",
8484
"jsdom": "^26.1.0",
@@ -122,6 +122,6 @@
122122
"es-toolkit": "^1.38.0",
123123
"fast-equals": "^5.2.2",
124124
"merge-deep": "^3.0.3",
125-
"svelte": "5.33.2"
125+
"svelte": "5.33.10"
126126
}
127127
}

pnpm-lock.yaml

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

src/lib/Mark.svelte

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
5757
const channelsWithFacets: ScaledChannelName[] = $derived([...channels, 'fx', 'fy']);
5858
59-
const { addMark, updateMark, updatePlotState, removeMark, getTopLevelFacet, getPlotState } =
59+
const { addMark, removeMark, getTopLevelFacet, getPlotState } =
6060
getContext<PlotContext>('svelteplot');
6161
6262
const plot = $derived(getPlotState());
@@ -258,16 +258,17 @@
258258
if (options?.[channel] != null && out[channel] === undefined) {
259259
// resolve value
260260
const value = row[channel];
261-
262261
const scaled = usedScales[channel]
263262
? scale === 'x'
264263
? projectX(channel as 'x' | 'x1' | 'x2', plot.scales, value)
265264
: scale === 'y'
266265
? projectY(channel as 'y' | 'y1' | 'y1', plot.scales, value)
267-
: plot.scales[scale].fn(value)
266+
: scale === 'color' && !isValid(value)
267+
? plot.options.color.unknown
268+
: plot.scales[scale].fn(value)
268269
: value;
269270
270-
out.valid = out.valid && isValid(value);
271+
out.valid = out.valid && (scale === 'color' || isValid(value));
271272
272273
// apply dx/dy transform
273274
out[channel] =

src/lib/Plot.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
scales,
118118
...restProps
119119
})}
120-
<svelte:boundary onerror={(err) => console.warn(err)}>
120+
<svelte:boundary onerror={(err) => console.error(err)}>
121121
<!-- implicit axes -->
122122
{#if !hasProjection && !hasExplicitAxisX}
123123
{#if options.axes && (options.x.axis === 'top' || options.x.axis === 'both')}

src/lib/core/Plot.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
initialWidth: 500,
6363
inset: 0,
6464
colorScheme: 'turbo',
65-
unknown: '#cccccc',
65+
unknown: '#cccccc99',
6666
dotRadius: 3,
6767
frame: false,
6868
axes: true,
@@ -450,7 +450,7 @@
450450
padding: 0,
451451
align: 0
452452
},
453-
color: { type: 'auto' },
453+
color: { type: 'auto', unknown: DEFAULTS.unknown },
454454
length: { type: 'linear' },
455455
symbol: { type: 'ordinal' },
456456
fx: { type: 'band', axis: 'top' },

src/lib/helpers/scales.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import isDataRecord from './isDataRecord.js';
3030

3131
import { createProjection } from './projection.js';
3232
import { maybeInterval } from './autoTicks.js';
33+
import { IS_SORTED } from 'svelteplot/transforms/sort.js';
3334

3435
/**
3536
* compute the plot scales
@@ -183,7 +184,10 @@ export function createScale<T extends ScaleOptions>(
183184
// we're deliberately checking for !== undefined and not for != null
184185
// since the explicit sort transforms like shuffle will set the
185186
// sort channel to null to we know that there's an explicit order
186-
if (mark.channels.sort !== undefined) sortOrdinalDomain = false;
187+
if ((name === 'x' || name === 'y') && mark.options[IS_SORTED] != undefined) {
188+
sortOrdinalDomain = false;
189+
}
190+
187191
for (const channel of mark.channels) {
188192
// channelOptions can be passed as prop, but most often users will just
189193
// pass the channel accessor or constant value, so we may need to wrap
@@ -278,6 +282,13 @@ export function createScale<T extends ScaleOptions>(
278282
}
279283
}
280284

285+
if ((name === 'x' || name === 'y') && scaleOptions.sort) {
286+
sortOrdinalDomain = true;
287+
}
288+
if ((name === 'x' || name === 'y') && scaleOptions.sort === false) {
289+
sortOrdinalDomain = false;
290+
}
291+
281292
// construct domain from data values
282293
const valueArr = [...dataValues.values(), ...(scaleOptions.domain || [])].filter(
283294
(d) => d != null

src/lib/marks/AxisX.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
const ticks: RawValue[] = $derived(
100100
data.length > 0
101101
? // use custom tick values if user passed any as prop
102-
data
102+
Array.from(new Set(data))
103103
: // use custom scale tick values if user passed any as plot scale option
104104
autoTicks(
105105
plot.scales.x.type,

src/lib/marks/ColorLegend.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
.swatch {
168168
display: inline-flex;
169169
align-items: center;
170+
column-gap: 0.3rem;
170171
}
171172
.item-label {
172173
vertical-align: super;

src/lib/marks/Dot.svelte

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@
4949
return d3Symbol(maybeSymbol(symbolType), size)();
5050
}
5151
52-
const { getTestFacet } = getContext<FacetContext>('svelteplot/facet');
5352
const { dotRadius } = getContext<PlotDefaults>('svelteplot/_defaults');
54-
let testFacet = $derived(getTestFacet());
5553
5654
const args = $derived(
5755
// todo: move sorting to Mark
@@ -84,7 +82,7 @@
8482
defaults={{ r: dotRadius, symbol: 'circle' }}
8583
{...args}>
8684
{#snippet children({ mark, usedScales, scaledData })}
87-
<g class="dots {className || ''}">
85+
<g class="dot {className || ''}">
8886
{#if canvas}
8987
<DotCanvas data={scaledData} {mark} />
9088
{:else}

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