Skip to content

Commit 1b197cc

Browse files
allisonhorstAllison HorstFil
authored
Adds Grouping data (with hexbin, histogram) in Charts (#560)
* add Grouping data section with hexbin, histogram * adds Grouping data page to sidebar in Charts * minor fixes and update hexbin chart to use dot mark * Apply suggestions from code review Co-authored-by: Philippe Rivière <[email protected]> --------- Co-authored-by: Allison Horst <[email protected]> Co-authored-by: Philippe Rivière <[email protected]>
1 parent 26423f1 commit 1b197cc

File tree

4 files changed

+30
-28
lines changed

4 files changed

+30
-28
lines changed

docs/charts/grouping-data.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Grouping data
2+
3+
[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.
4+
5+
## Hexbin chart
6+
7+
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).
8+
9+
```js echo
10+
Plot.plot({
11+
color: {scheme: "ylgnbu"},
12+
marks: [
13+
Plot.dot(olympians, Plot.hexbin({fill: "sum"}, {x: "weight", y: "height"}))
14+
]
15+
})
16+
```
17+
18+
## Histogram
19+
20+
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).
21+
22+
```js echo
23+
Plot.plot({
24+
marks: [
25+
Plot.rectY(olympians, Plot.binX({y: "count"}, {x: "weight"})),
26+
Plot.ruleY([0])
27+
]
28+
})
29+
```

docs/charts/hexbin.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/charts/histogram.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

observablehq.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ export default {
4343
{name: "Cell", path: "/charts/cell"},
4444
{name: "Dot", path: "/charts/dot"},
4545
{name: "Facets", path: "/charts/facets"},
46-
{name: "Hexbin", path: "/charts/hexbin"},
4746
{name: "Line", path: "/charts/line"},
4847
{name: "Tick", path: "/charts/tick"},
48+
{name: "Grouping data", path: "/charts/grouping-data"}
4949
]
5050
},
5151
{

0 commit comments

Comments
 (0)