plot icon indicating copy to clipboard operation
plot copied to clipboard

arc mark and pie transform

Open Fil opened this issue 4 years ago • 5 comments

ref. #80

Todo:

  • [ ] "grammar of graphics": how to make this work naturally with the other transforms (stackX, groupX) 🌶
  • [x] pie mark
    • [ ] pie API (group by "x", etc.)
  • [x] labels
    • [ ] white ghosts
  • [ ] rounded corners, etc.
  • [ ] unit tests
    • [x] arcs
    • [ ] pies

test notebook https://observablehq.com/d/49758b3252c58f13

Capture d’écran 2020-12-31 à 17 41 55

Fil avatar Dec 31 '20 16:12 Fil

transform: d3.pie()

Awesome! 👍

mbostock avatar Dec 31 '20 18:12 mbostock

Two conceptual difficulties:

  • there's no real reason to make "x" and "y" mandatory, but if I don't define them by default to constant(0), Plot complains (if mandatory, that they are missing, if optional, that x has no bandwidth).
  • should innerRadius and outerRadius be based on scales? And if so how can we adjust them so that the pie is always visible? For now I'm trying to express these in terms of "% of the maximum that fits" (ie 100 = fully visible disk in the local canvas).

Fil avatar Jan 01 '21 16:01 Fil

Pie mark! Capture d’écran 2021-01-01 à 18 12 46

Fil avatar Jan 01 '21 17:01 Fil

mixing pies and dots untitled - 2021-01-01T183329 895

Fil avatar Jan 01 '21 17:01 Fil

Just wanted to thank @Fil for the work on this mark, and share some small updates I made for a project where I needed validate election results:

chrome_X3Iluhc3QP

I found it useful to plot little pie charts on a county/race graph to help spot patterns in the errors (which were often related to one of the axises). I have a demo up here, and the specific changes I made are here.

I'm not super familiar with the system yet (I was getting errors somewhere in the facet init), so I had to move the d3.pie() transform outside of arc to something like this:

data_in.forEach(d => {
    const completed = d.counted / d.official
    const pie = d3.pie()([completed, 1 - completed])
    data_out.push({
      ...pie[0],
      ...d,
    })
  }) 

I'd be happy to submit any changes, but I'm sure my code is full of ES6 errors - it's been a while since I've done this sort of development, and am trying to relearn some things!

jackhumbert avatar Oct 07 '21 15:10 jackhumbert