Skip to content

Sort and filter bar chart #1027

Answered by Fil
dgwyer asked this question in Q&A
Discussion options

You must be logged in to vote

For question 1, you could use the domain from scale fx in the group bar chart to define the scale x of the stacked bar chart? Like so;

x: {
  type: "band",
  tickFormat: d => d.toLocaleString("en", {month: "narrow"}),
  label: null,
  domain: d3.groupSort(crimea, v => d3.sum(v, d => -d.deaths), d => d.date).slice(0, 6),
}

For question 2, if you want the first six (different!) dates in input order, you could do:
domain: [...new d3.InternSet(crimea.map(d => d.date))].slice(0, 6) ?

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by dgwyer
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants