Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

d3-shape should return a good error when d3-path is not present #49

Closed
llimllib opened this issue Dec 29, 2015 · 3 comments
Closed

d3-shape should return a good error when d3-path is not present #49

llimllib opened this issue Dec 29, 2015 · 3 comments

Comments

@llimllib
Copy link

Steps:

  1. Load up d3-shape in a webpage to test it
  2. Try something from the tests
  3. See an unuseful error message:
d3_shape.line().curve(d3_shape.basisOpen)([[0,0], [0,10]])
d3-shape.v0.2.js:1024 Uncaught TypeError: Cannot read property 'path' of undefined(…)

(It would also be awesome if there were bl.ocks samples for the images provided in the documentation, it seems quite hard to figure out how to generate them at the moment?)

@mbostock
Copy link
Member

I agree that the documentation should be improved by adding (links to) more code examples.

Part of the issue is that D3 4.0 is not yet ready for release, and most of the existing “real-world” examples depend on other D3 features (such as selections and axes) that are not yet available in standalone modules. So some of the examples use the 3.x API which is similar but not identical.

I should create new, smaller examples that are better at demonstrating how to use d3-shape. They’d be less useful as visualizations without being able to use other D3 functionality, but they’d be better at demonstrating the d3-shape API.

FWIW, the curve viewer (currently a secret gist) is here:

http://bl.ocks.org/mbostock/4677815766e8404bee65

I’m not in favor of defending the code against missing dependencies. The correct usage is documented in the README, and this should be less of a problem in the future when there are more examples. In general, it just hurts my brain too much to try to anticipate all the ways the code can be misused and try to protect against it. I know this is a common case and so perhaps an exception could be made, but it’s not like the error is that obscure: the stack trace points you right to the line where d3_path is undefined, and that should be enough to go on.

So, I’m going to close this issue, but I’ll open a new one to cover the request for more self-contained examples.

@llimllib
Copy link
Author

Thanks for reading it and coming up with the useful bit from it; I appreciate it.

I also modified your old spline viewer so I could play with these curves: http://bl.ocks.org/llimllib/115a23b78d1fae253bb8/bb4dba43022ebb920bcba4cc7cac1c36707e020d

@mbostock
Copy link
Member

Nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants