Skip to content

Commit 64c8765

Browse files
committed
format
1 parent b842340 commit 64c8765

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

src/lib/helpers/time.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export function generalizeTimeInterval(interval, n) {
245245
if (duration % durationDay === 0 && durationDay < duration && duration < durationMonth) return; // not generalizable
246246
const [i] =
247247
tickIntervals[
248-
bisector(([, step]) => Math.log(step)).center(tickIntervals, Math.log(duration * n))
248+
bisector(([, step]) => Math.log(step)).center(tickIntervals, Math.log(duration * n))
249249
];
250250
return (interval[intervalType] === 'time' ? maybeTimeInterval : maybeUtcInterval)(i);
251251
}

src/lib/transforms/jitter.ts

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,28 @@ type JitterOptions = {
1313
width: number;
1414
/** standard deviation for normal jittering */
1515
std: number;
16-
}
16+
};
1717

18-
export function jitterX({ data, ...channels }: TransformArg<DataRecord>, options: JitterOptions): TransformArg<DataRecord> {
18+
export function jitterX(
19+
{ data, ...channels }: TransformArg<DataRecord>,
20+
options: JitterOptions
21+
): TransformArg<DataRecord> {
1922
return jitter('x', data, channels, options);
2023
}
2124

22-
export function jitterY({ data, ...channels }: TransformArg<DataRecord>, options: JitterOptions): TransformArg<DataRecord> {
25+
export function jitterY(
26+
{ data, ...channels }: TransformArg<DataRecord>,
27+
options: JitterOptions
28+
): TransformArg<DataRecord> {
2329
return jitter('y', data, channels, options);
2430
}
2531

26-
export function jitter(channel: 'x' | 'y', data: DataRecord[], channels: Channels, options: JitterOptions): TransformArg<DataRecord> {
32+
export function jitter(
33+
channel: 'x' | 'y',
34+
data: DataRecord[],
35+
channels: Channels,
36+
options: JitterOptions
37+
): TransformArg<DataRecord> {
2738
if (channels[channel]) {
2839
const type = options?.type ?? 'uniform';
2940
const width = parseNumber(options?.width ?? 0.35);
@@ -33,21 +44,26 @@ export function jitter(channel: 'x' | 'y', data: DataRecord[], channels: Channel
3344
const random = type === 'uniform' ? randomUniform(-width, width) : randomNormal(0, std);
3445
const accKey = channel === 'x' ? JITTER_X : JITTER_Y;
3546
return {
36-
data: data.map(row => {
47+
data: data.map((row) => {
3748
const value = resolveChannel(channel, row, channels);
3849
return {
3950
...row,
40-
[accKey]: typeof value === 'number' ? value + random() : isDate(value) ? new Date(value.getTime() + random()) : value
41-
}
51+
[accKey]:
52+
typeof value === 'number'
53+
? value + random()
54+
: isDate(value)
55+
? new Date(value.getTime() + random())
56+
: value
57+
};
4258
}),
4359
...channels,
4460
// point channel to new accessor symbol
4561
[channel]: accKey
46-
}
62+
};
4763
}
4864
return {
4965
data,
50-
...channels,
66+
...channels
5167
};
5268
}
5369

@@ -62,4 +78,4 @@ function parseNumber(value: number | string): number {
6278
}
6379
}
6480
return 0;
65-
}
81+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ In case you want to use SveltePlot transforms outside of a Svelte project you ca
9090
```js
9191
import { binX } from 'svelteplot/transforms';
9292
```
93+
9394
## Available Transforms
9495

9596
- [bin](/transforms/bin) - Groups data into discrete bins

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