Skip to content

Adds Grouping data (with hexbin, histogram) in Charts #560

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 5 commits into from
Jan 18, 2024
Merged
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
29 changes: 29 additions & 0 deletions docs/charts/grouping-data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Grouping data

[Observable Plot](https://observablehq.com/plot/) provides a number of [transforms](https://observablehq.com/plot/transforms/) that help you perform common data transformations. The [group](https://observablehq.com/plot/transforms/group) and [bin](https://observablehq.com/plot/transforms/bin) transforms (for categorical and quantitative dimensions, respectively) group data into discrete bins. A reducer (_e.g._ sum, count, or mean) can then be applied to visualize summary values by bin.

## Hexbin chart

Copy the code snippet below, paste into a JavaScript code block, then substitute your own data to create a hexbin chart using the [dot mark](https://observablehq.com/plot/marks/dot) and the [hexbin transform](https://observablehq.com/plot/transforms/hexbin).

```js echo
Plot.plot({
color: {scheme: "ylgnbu"},
marks: [
Plot.dot(olympians, Plot.hexbin({fill: "sum"}, {x: "weight", y: "height"}))
]
})
```

## Histogram

Copy the code snippet below, paste into a JavaScript code block, then substitute your own data to create a histogram using the [rect mark](https://observablehq.com/plot/marks/rect) and the [bin transform](https://observablehq.com/plot/transforms/bin).

```js echo
Plot.plot({
marks: [
Plot.rectY(olympians, Plot.binX({y: "count"}, {x: "weight"})),
Plot.ruleY([0])
]
})
```
15 changes: 0 additions & 15 deletions docs/charts/hexbin.md

This file was deleted.

12 changes: 0 additions & 12 deletions docs/charts/histogram.md

This file was deleted.

2 changes: 1 addition & 1 deletion observablehq.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export default {
{name: "Cell", path: "/charts/cell"},
{name: "Dot", path: "/charts/dot"},
{name: "Facets", path: "/charts/facets"},
{name: "Hexbin", path: "/charts/hexbin"},
{name: "Line", path: "/charts/line"},
{name: "Tick", path: "/charts/tick"},
{name: "Grouping data", path: "/charts/grouping-data"}
]
},
{
Expand Down