Skip to content

fix axis labels in example (fix #54) #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/routes/transforms/interval/+page.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ The interval transform is often used for time-series bar charts. For example, co
import { Plot, BarY, RuleY } from 'svelteplot';
import type { Datasets } from '$lib/types.js';

const MONTH_YEAR = new Intl.DateTimeFormat('en-US', {
const DAY_MONTH = new Intl.DateTimeFormat('en-US', {
day: 'numeric',
month: 'short',
year: 'numeric'
});
const tickFormat = (date: Date) =>
MONTH_YEAR.format(date).split(' ');

const tickFormat = (date: Date) => DAY_MONTH.format(date).split(' ').reverse();

import { page } from '$app/state';
let { aapl } = $derived(page.data.data);
Expand All @@ -37,9 +37,15 @@ In contrast, a [rectY](/marks/rect) mark with the interval option and the day in

import { page } from '$app/state';
let { aapl } = $derived(page.data.data);

const DAY_MONTH = new Intl.DateTimeFormat('en-US', {
day: 'numeric',
month: 'short',
});
const tickFormat = (date: Date) => DAY_MONTH.format(date).split(' ').reverse();
</script>

<Plot marginLeft={40} x={{ type: 'time' }} grid>
<Plot marginLeft={40} x={{ tickFormat }} grid>
<RectY
data={aapl.slice(-40)}
x="Date"
Expand All @@ -51,7 +57,7 @@ In contrast, a [rectY](/marks/rect) mark with the interval option and the day in
```

```svelte
<Plot marginLeft={40} x={{ type: 'time' }} grid>
<Plot marginLeft={40} x={{ tickFormat }} grid>
<RectY
data={aapl.slice(-40)}
x="Date"
Expand All @@ -72,12 +78,12 @@ The meaning of the interval mark option depends on the associated mark, such as
import { page } from '$app/state';
let { aapl } = $derived(page.data.data);

const MONTH_DAY = new Intl.DateTimeFormat('en-US', {
const DAY_MONTH = new Intl.DateTimeFormat('en-US', {
day: 'numeric',
month: 'short',
date: 'numeric'
});
const tickFormat = (date: Date) =>
MONTH_DAY.format(date).split(' ');

const tickFormat = (date: Date) => DAY_MONTH.format(date).split(' ').reverse();
</script>

<Plot marginLeft={40} x={{ tickFormat }} grid>
Expand Down
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