Skip to content
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
60 changes: 60 additions & 0 deletions sites/docs/pages/components/charts/small-multiple/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: Small Multiple
description: Display a series of similar graphs or charts using the same scale and axes
sidebar_position: 96
---

Use a small multiple to display a series of similar graphs or charts using the same scale and axes.
A small multiple can be created by using the grid, loop and query functions option in combination with a unique list of horizontal and vertical axes.

1. Define unique lists for axes
2. Define grid
3. Define loops for horizontal and/or veritical grid
4. Filter chart value with query function


# Example


```sql categories
select distinct category as name from needful_things.orders
```

```sql orders_by_category
select category, order_month as month, sum(sales) as sales_usd0k, count(1) as orders from needful_things.orders
group by all
```

<DocTab>

<Grid cols=3 gapSize=lg>
{#each categories as category}

<LineChart
data={orders_by_category.where(`category = '${category.name}'`)}
x=month
y=sales_usd0k
yAxisTitle="Sales per Month"
title="Monthly Sales"
subtitle="{category.name}"
/>
{/each}
</Grid>

```markdown
<Grid cols=3 gapSize=lg>
{#each categories as category}

<LineChart
data={orders_by_category.where(`category = '${category.name}'`)}
x=month
y=sales_usd0k
yAxisTitle="Sales per Month"
title="Monthly Sales"
subtitle="{category.name}"
/>
{/each}
</Grid>
```
</DocTab>

19 changes: 18 additions & 1 deletion sites/docs/pages/core-concepts/filters/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,21 @@ group by 1
x=month
y=sales_usd
/>
````
````

## Filtering a query with a search parameter in URL

Every search parameter defined in the URL can be accessed and used as filter by using `{$page.url.searchParams.get('myParam')}`

The search parameter should be defined as `.../pagename/?myParam=...`
```
<Dropdown data=filteroptions name=dropdownfilter value=name defaultValue='{$page.url.searchParams.get('myParam')}'/>
```

<Alert status=info>

URL parameters can be useful to share a specific page or present a view with predefined filters.

</Alert>