Skip to content

Commit

Permalink
fix: d3v6 convert d3.nest to d3.groups
Browse files Browse the repository at this point in the history
  • Loading branch information
cprice-scottlogic authored and chrisprice committed Sep 23, 2020
1 parent 3776d80 commit 2e9025f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 23 deletions.
10 changes: 4 additions & 6 deletions examples/boxplot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ d3.csv('github-repo-data.csv', d => ({
};

const languageQuartiles = d3
.nest()
.key(d => d.language)
.entries(githubData)
.map(languageGroup => ({
language: languageGroup.key,
quartile: quartile(languageGroup.values.map(d => d.forksPerStar))
.groups(githubData, d => d.language)
.map(([language, values]) => ({
language,
quartile: quartile(values.map(d => d.forksPerStar))
}))
.sort((a, b) => a.quartile.median - b.quartile.median);

Expand Down
2 changes: 1 addition & 1 deletion examples/chart-zoom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const area = fc
.size(4);

// create a d3-zoom that handles the mouse / touch interactions
const zoom = d3.zoom().on('zoom', (event) => {
const zoom = d3.zoom().on('zoom', event => {
// update the scale used by the chart to use the updated domain
x.domain(event.transform.rescaleX(x2).domain());
y.domain(event.transform.rescaleY(y2).domain());
Expand Down
5 changes: 2 additions & 3 deletions examples/interactive-small-multiples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ d3.tsv('data.tsv', r => ({
year: Number(r.year)
})).then(data => {
const nested = d3
.nest()
.key(k => k.category)
.entries(data);
.groups(data, k => k.category)
.map(([key, values]) => ({ key, values }));

nested.forEach(g => (g.trackball = []));

Expand Down
12 changes: 5 additions & 7 deletions examples/label-layout-chart/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
d3.csv('repos-users-dump.csv').then(githubData => {
// count the organisations / users for each language
const scatter = d3
.nest()
.key(d => d.language)
.entries(githubData)
.map(lang => ({
language: lang.key,
orgs: lang.values.filter(d => d.type === 'Organization').length,
users: lang.values.filter(d => d.type === 'User').length
.groups(githubData, d => d.language)
.map(([key, values]) => ({
language: key,
orgs: values.filter(d => d.type === 'Organization').length,
users: values.filter(d => d.type === 'User').length
}))
.filter(d => d.language);

Expand Down
5 changes: 2 additions & 3 deletions examples/marathon-pace/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ d3.text('splits.csv').then(text => {

// group into buckets
let grouped = d3
.nest()
.key(bucketByHour)
.entries(splits)
.groups(splits, bucketByHour)
.map(([key, values]) => ({ key, values }))
.sort((a, b) => d3.ascending(+a.key, +b.key));

grouped.forEach(g => {
Expand Down
5 changes: 2 additions & 3 deletions examples/small-multiples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ const sales = [

// group by month, giving our per-month small multiples
const groupedByMonth = d3
.nest()
.key(d => d.Month)
.entries(sales);
.groups(sales, d => d.Month)
.map(([key, values]) => ({ key, values }));

// the various series components
const area = fc
Expand Down

0 comments on commit 2e9025f

Please sign in to comment.