Skip to content

Commit 52e6fce

Browse files
put day nuber above month in x-axis label
1 parent deb3d30 commit 52e6fce

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The interval transform is often used for time-series bar charts. For example, co
1616
month: 'short',
1717
});
1818
19-
const tickFormat = (date: Date) => DAY_MONTH.format(date).split(' ');
19+
const tickFormat = (date: Date) => DAY_MONTH.format(date).split(' ').reverse();
2020
2121
import { page } from '$app/state';
2222
let { aapl } = $derived(page.data.data);
@@ -37,9 +37,15 @@ In contrast, a [rectY](/marks/rect) mark with the interval option and the day in
3737
3838
import { page } from '$app/state';
3939
let { aapl } = $derived(page.data.data);
40+
41+
const DAY_MONTH = new Intl.DateTimeFormat('en-US', {
42+
day: 'numeric',
43+
month: 'short',
44+
});
45+
const tickFormat = (date: Date) => DAY_MONTH.format(date).split(' ').reverse();
4046
</script>
4147
42-
<Plot marginLeft={40} x={{ type: 'time' }} grid>
48+
<Plot marginLeft={40} x={{ tickFormat }} grid>
4349
<RectY
4450
data={aapl.slice(-40)}
4551
x="Date"
@@ -51,7 +57,7 @@ In contrast, a [rectY](/marks/rect) mark with the interval option and the day in
5157
```
5258

5359
```svelte
54-
<Plot marginLeft={40} x={{ type: 'time' }} grid>
60+
<Plot marginLeft={40} x={{ tickFormat }} grid>
5561
<RectY
5662
data={aapl.slice(-40)}
5763
x="Date"
@@ -77,7 +83,7 @@ The meaning of the interval mark option depends on the associated mark, such as
7783
month: 'short',
7884
});
7985
80-
const tickFormat = (date: Date) => DAY_MONTH.format(date).split(' ');
86+
const tickFormat = (date: Date) => DAY_MONTH.format(date).split(' ').reverse();
8187
</script>
8288
8389
<Plot marginLeft={40} x={{ tickFormat }} grid>

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