Skip to content

Add example plot to filter transform page #128

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
34 changes: 34 additions & 0 deletions src/routes/transforms/filter/+page.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,37 @@ title: Filter transform
The **filter transform** filters a mark’s index to show a subset of the data. For example, below the **filter** option controls which text labels are displayed in a dense scatterplot.

Since the filter transform only affects the mark’s index and not the channel values, it does not affect the default scale domains. Below, the x scale contains every English letter, even though the only the bars for the vowels are shown.

```svelte live
<script lang="ts">
import { Plot, BarY, filter } from '$lib/index'
import { page } from '$app/state';
const { alphabet } = $derived(page.data.data);
import { getContext } from 'svelte';

const useCanvas = getContext('useCanvas');
</script>

<Plot>
<BarY
data={alphabet}
canvas={$useCanvas}
filter={(d) => /[aeiouy]/i.test(d.letter)}
x="letter"
y="frequency" />
</Plot>
```

```svelte
<Plot>
<BarY
data={alphabet}
filter={(d) => /[aeiouy]/i.test(d.letter)}
x="letter"
y="frequency" />
</Plot>
```

[fork](https://svelte.dev/playground/50337f4963264dcb9d4b8cf7c80702b2?version=latest)

TODO(@gka): Fork repl and replace link
7 changes: 5 additions & 2 deletions src/routes/transforms/filter/+page.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { loadDatasets } from 'svelteplot/helpers/data.js';
import type { PageLoad } from './$types.js';

export const load: PageLoad = () => {
return { datasets: ['aapl'] };
export const load: PageLoad = async ({ fetch }) => {
return {
data: await loadDatasets(['alphabet'], fetch)
};
};
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