Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

add pages of examples translated from ObservablePlot docs#72

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
jamesscottbrown wants to merge20 commits intosvelteplot:main
base:main
Choose a base branch
Loading
fromjamesscottbrown:examples
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
20 commits
Select commitHold shift + click to select a range
c535083
add pages of examples translated from ObservablePlot docs
jamesscottbrownMay 28, 2025
32269fb
Merge branch 'main' of github.com:svelteplot/svelteplot into examples
jamesscottbrownMay 28, 2025
49bcf66
add rule/tick examples
jamesscottbrownMay 28, 2025
ee0aa2e
fix links in sidebar
jamesscottbrownMay 28, 2025
bab3ce8
add axis examples
jamesscottbrownMay 28, 2025
e686b41
edits to examples
jamesscottbrownMay 28, 2025
684af53
ad dnot about bug
jamesscottbrownMay 28, 2025
0c10887
Merge branch 'main' of github.com:svelteplot/svelteplot into examples
jamesscottbrownMay 29, 2025
9c264f2
link to issues
jamesscottbrownMay 29, 2025
214211d
update page of rule/tick examples
jamesscottbrownMay 29, 2025
6c3d52f
add link to issues for line mark examples
jamesscottbrownMay 29, 2025
1b71990
link to issues
jamesscottbrownMay 29, 2025
d9e2581
fix build by disabling broken chart
jamesscottbrownMay 29, 2025
432dd2c
more links to issues
jamesscottbrownMay 29, 2025
75f4891
fix build
jamesscottbrownMay 29, 2025
8fc63e7
Merge branch 'main' of github.com:svelteplot/svelteplot into examples
jamesscottbrownMay 29, 2025
91cf061
remove waring as bug fixed
jamesscottbrownMay 29, 2025
c09264d
fix build
jamesscottbrownMay 29, 2025
31feedf
Merge branch 'main' of github.com:svelteplot/svelteplot into examples
jamesscottbrownJun 2, 2025
17c888c
remove a note as issue fixed
jamesscottbrownJun 2, 2025
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: 26 additions & 0 deletionsconfig/sidebar.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -121,6 +121,32 @@ export default {
to: '/features/gradients'
}
]
},
{
title: 'Examples',
collapsible: true,
items: [
{
title: 'Bar/Cell/Rect',
to: '/examples/bar-cell-rect'
},
{
title: 'Dot',
to: '/examples/dot'
},
{
title: 'Line',
to: '/examples/line'
},
{
title: 'Rule/Tick',
to: '/examples/rule-tick'
},
{
title: 'Axes',
to: '/examples/axes'
},
]
}
]
};
122 changes: 122 additions & 0 deletionssrc/routes/examples/axes/+page.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
---
title: Examples of customizing Axes
---

This page shows many examples of using Axes translated from the [Observable Plot Plot Gallery](https://observablehq.com/@observablehq/plot-gallery).
It only includes examples using the standard demo datasets from the [@observablehq/sample-datasets](https://www.npmjs.com/package/@observablehq/sample-datasets) package.


## [ggplot2-style axes](https://observablehq.com/@observablehq/plot-ggplot2-style-axes)

```svelte live
<script>
import { Plot, Frame, Line, GridX, GridY } from 'svelteplot';
import { page } from '$app/state';

let { aapl } = $derived(page.data.data);
</script>

<Plot inset={10} >
<Frame fill="#eaeaea" />
<GridY stroke={"white"} strokeOpacity={1} />
<GridX stroke="white" strokeOpacity={1} />
<Line data={aapl} x="Date" y="Close" stroke="black" />
</Plot>
```


## [Datawrapper-style date axis](https://observablehq.com/@observablehq/plot-datawrapper-style-date-axis)

```svelte live
<script>
import { Plot, AxisX, Line, GridX, RuleY } from 'svelteplot';
import { page } from '$app/state';

let { aapl } = $derived(page.data.data);
</script>

<Plot >
<RuleY data={[0]} />
<AxisX ticks="3 months" />
<GridX />
<Line data={aapl} x="Date" y="Close" />
</Plot>

```

## [New York Times-style axes](https://observablehq.com/@observablehq/plot-nyt-style-axes)

```svelte live
<script>
import { Plot, AxisX, AxisY, Line, GridY, RuleY } from 'svelteplot';
import { page } from '$app/state';

let { aapl } = $derived(page.data.data);
</script>

<Plot round=true marginLeft={0} x={{ label: null, insetLeft: 36}} >
<GridY strokeDasharray="0.75,2" strokeOpacity={1} />
<AxisY
tickSize={0}
dx={38}
dy={-6}
lineAnchor="bottom"
/>
<RuleY data={[0]} />
<Line data={aapl} x="Date" y="Close" markerEnd="dot" />
</Plot>


```


## [Data based axis](https://observablehq.com/@observablehq/plot-data-based-axis)

> :warning: This isn't rendering correctly - the `x` channel isn't affecting the positioned where the y-axis lines end (and labels are positioned).
> See [Issue #76](https://github.com/svelteplot/svelteplot/issues/76)

```svelte live
<script>
import { Plot, AxisX, AxisY, Line, GridY, RuleY } from 'svelteplot';
import { page } from '$app/state';

let { aapl } = $derived(page.data.data);
</script>

<Plot marginRight={0} >
<RuleY data={[0]} />
<Line data={aapl} x="Date" y="Close" />
<GridY
x={y => aapl.find(d => d.Close >= y)?.Date}
insetLeft={-6}
/>
<AxisY
x={y => aapl.find(d => d.Close >= y)?.Date}
insetLeft={-6}
textStroke="var(--vp-c-bg)"
/>
</Plot>

```


## [Major and minor axis ticks](https://observablehq.com/@observablehq/plot-major-and-minor-axis-ticks)

```svelte live
<script>
import { Plot, AxisX, AxisY, Line, GridY, RuleY } from 'svelteplot';
import { page } from '$app/state';

let { aapl } = $derived(page.data.data);
</script>

<Plot marginRight={0} >
<Line data={aapl} x="Date" y="Close" />

<AxisX ticks="month" text={null} tickSize={3} />
<AxisX />

<AxisY ticks={50} tickSize={3} text={null} />
<AxisY />
</Plot>
```
8 changes: 8 additions & 0 deletionssrc/routes/examples/axes/+page.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
import { loadDatasets } from '$lib/helpers/data.js';
import type { PageLoad } from './$types.js';

export const load: PageLoad = async ({ fetch }) => {
return {
data: await loadDatasets(['aapl', 'penguins', 'olympians'], fetch)
};
};
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp