✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Chart fails when data contains large ratios?

Hi,

First post!

We are drawing a simple pie chart using the d3 scientific package. It looks a lot like this codepen:

To demonstrate the problem we see:

  1. Change the chart data from [19, 26, 55] to [1, 1, 100000000]. (That is 100 million.) The chart vanishes, presumably, because it has failed.
  2. Now change the first 1 to a 9. Chart appears. So it is not simple magnitude that causes the fault.

My theory is that very tiny ratios eventually become indistinguishable from zero and some kind of divide-by-zero error takes place. (Note that you can replace those standalone 1s with 0s and the chart renders… special case handling, I suppose.)

Anyway, has anyone else seen this? Is this expected behavior? Can we detect programmatically that it has happened? Or is it my job to stop the user whenever s/he tries to chart a big number (whatever “big” might mean)?

Thanks for any guidance.

Jeff