d3 / d3-shape

Graphical primitives for visualization, such as lines and areas.
https://d3js.org/d3-shape
ISC License
2.48k stars 310 forks source link

Validate path coordinates? #112

Closed handerpeder closed 6 years ago

handerpeder commented 6 years ago

This may be off topic put took me a while to track down so I wanted to see if there was interest in adding a check.

I started getting reports that a line chart would show up blank. Initial investigation revealed that the data was indeed loaded correctly and the focus circle showed up on mouseover. Turned out that the endpoint I was consuming had started spewing out very big values like 2.82730418753478e+27. It seems that a svg path will not render if one of the coordinates is really large. Example:

<html>
<head>
  <style>
   path {
       stroke: steelblue;
       fill: none;
   }
  </style>
  <body>
    <svg width="800" height="400">
      <path d="M100,100L200,2000,100"></path>
    </svg>
    <svg width="800" height="400">
      <path d="M100,100L200,9000000000L300,100"></path>
    </svg>
  </body>
</html>

Only the first path is drawn, no warning is given in the second case that anything is wrong. This seems to be implementation specific since the issue will trigger for different values in chrome and firefox.

Is there any interest in having a check for this?

mbostock commented 6 years ago

Thanks for the suggestion, but I’d prefer path validation live elsewhere rather than baking it into this module.