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

typeerror - calcExtents must be an Array #53

Closed
mraghuram opened this issue Dec 12, 2021 · 10 comments
Closed

typeerror - calcExtents must be an Array #53

mraghuram opened this issue Dec 12, 2021 · 10 comments

Comments

@mraghuram
Copy link

Hi,

I keep getting this error message that says 'TypeError: The first argument of calcExtents() must be an array.'

However my data I am passing passes the Array.isArray test and is an array of objects

Is there something I am missing?

Murali

@mraghuram mraghuram changed the title calcExtents must be an Array typeerror - calcExtents must be an Array Dec 12, 2021
@mhkeller
Copy link
Owner

mhkeller commented Dec 12, 2021 via email

@mhkeller
Copy link
Owner

@mraghuram please let me know. I'll close this issue if you've moved on.

@mraghuram
Copy link
Author

hi @mhkeller, sorry I am trying to figure out how to share the information. The data i am using is something I can share on a repl.

I used d3 extent as a work around for now.

@mhkeller
Copy link
Owner

Okay, let me know if there's a way I can take a look somehow. I'll close this for now and feel free to re-open when you are able to share.

@mhkeller
Copy link
Owner

@mraghuram Here's a link to the REPL where you can log in with GitHub and create a shareable link: https://svelte.dev/repl/hello-world?version=3.44.3

@tututwo
Copy link

tututwo commented Dec 19, 2021

hi @mhkeller, sorry I am trying to figure out how to share the information. The data i am using is something I can share on a repl.

I used d3 extent as a work around for now.

Hi @mraghuram, I ran into the same problem just yesterday. You can replicate the same issue by deleting {flatData} in this demo map.
https://layercake.graphics/example/MapSvg

Yesterday I passed in zDomain, zRange and z to component, but I cant use zGet or zScale in the descendent component. I guess adding {flatData} lets LayerCake's z accessor know extents of the data?(But how? sorry...more question here...)

@mhkeller
Copy link
Owner

@tututwo these are two different issues. The map example needs flatData because the value for data is a GeoJSON object, not an array, which the calcExtents function requires. In order to generate scales, Layer Cake needs an array of objects and accessor functions to know which field to use as each scale's domain.

@mraghuram's issue was different. He said he was passing in an array to the data prop and still seeing the error. Hope that helps to clarify things. I wonder if renaming flatData to something like dataForExtents would be more helpful.

@tututwo
Copy link

tututwo commented Dec 19, 2021

Thank you for your explanation! It's clear for me now!

And yes, dataForExtents is more intuitive for me, personally.

@mraghuram
Copy link
Author

@mhkeller sorry about the delay.. Unfortunately, I couldn't share the data. But thanks for closing the issue

@mhkeller
Copy link
Owner

Okay. Try calling Array.from around your data to make sure that it is actually an array.

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

No branches or pull requests

3 participants