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

Failed to render when string is passed to geomap data #756

Closed
matuzalemsteles opened this issue Mar 19, 2018 · 4 comments
Closed

Failed to render when string is passed to geomap data #756

matuzalemsteles opened this issue Mar 19, 2018 · 4 comments

Comments

@matuzalemsteles
Copy link
Member

Hey @julien, it seems to fail when I try to pass a string in the data, it manages to do the Fetch but in DataComponent._resolveData it expects it to come inside a data and arrives {"type":"FeatureCollection","features"....

return fetch(data, {cors: 'cors'})
	.then(res => res.json())
	.then(res => res.data);

https://github.com/liferay/clay/blob/master/packages/clay-charts/src/DataComponent.js#L38

He ends up giving an error soon after:

const features = mapData.features;

https://github.com/liferay/clay/blob/master/packages/clay-charts/src/Geomap.js#L150

It works fine when I change .then(res => res.data); for then(res => res);, but I do not know if it is expected.

I'm using data from world-low-res.geo.json

@matuzalemsteles matuzalemsteles added the type: bug Issues reporting that Component is not doing what should be done label Mar 19, 2018
@julien
Copy link
Contributor

julien commented Mar 19, 2018

Hey @matuzalemsteles this is not a bug, it's a feature ;)

Jokes aside, the reason for this is that DataComponent is used by ChartBase and Geomap, and ChartBase expects the data to be in a data property.

If you update you geojson file to have a data field it will load properly, I had to fix this in portal too last week.

Tell me if you need any help.

@matuzalemsteles matuzalemsteles added type: question and removed type: bug Issues reporting that Component is not doing what should be done labels Mar 19, 2018
@matuzalemsteles
Copy link
Member Author

Thanks for the clarifications @julien, it looks better now.

I'll just update this to be included in data so can work properly. I'm just looking at the geomap being rendered on clayui.com.

@julien
Copy link
Contributor

julien commented Mar 19, 2018

Ok thanks @matuzalemsteles

@matuzalemsteles
Copy link
Member Author

Closing this, since the problem has been solved.

matuzalemsteles added a commit to matuzalemsteles/clay that referenced this issue Mar 19, 2018
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

2 participants