frictionlessdata / datapackage-js

A JavaScript library for working with Data Package.
http://frictionlessdata.io/
MIT License
43 stars 15 forks source link

React Component for a data resource #65

Closed rgbkrk closed 6 years ago

rgbkrk commented 7 years ago

Has anyone made a React Component that accepts dataresource json?

pwalsh commented 7 years ago

@rufuspollock are the react components in https://github.com/frictionlessdata/dpr-js clean/extractable for standalone use?

rufuspollock commented 7 years ago

@rgbkrk great question 😄

@rgbkrk @pwalsh I'm actually working on that 😄 - the current code is pretty close but would probably need a bit of tweaking. The relevant component is this container:

https://github.com/frictionlessdata/dpr-js/blob/gh-pages/src/containers/DataPackageView.jsx

Basically you pass it a Data Package (not a resource but that is trivial to change) and it then renders tables for each resource in the Data Package plus the views. You can see the kind of output (in progress and not yet launched) here: https://staging.datapackaged.com/core/finance-vix

@rgbkrk what is your exact use case? That would help in providing guidance.

rgbkrk commented 7 years ago

Within the Jupyter ecosystem, we'd like to be able to allow libraries to provide application/vnd.dataresource+json. Pandas recently merged a PR to provide a default representation of a DataFrame as a data resource json when an optional flag is set: https://github.com/pandas-dev/pandas/pull/14904

The way that the nteract notebook works (same protocol as Jupyter) is that it takes a payload like:

{
  "text/html": "...some HTML",
  "application/vnd.dataresource+json": { "schema": {}, "data": [] }
}

picks the "richest" of the media types and passes the data into a React component to render it. As an example, here's me working with baseball data in pandas:

screen shot 2017-03-04 at 11 05 58 am

That's the text/html version provided by pandas, which could instead be a rendered version of the data resource, which is now part of the payload for dataframe representation:

screen shot 2017-03-04 at 11 11 36 am

rufuspollock commented 7 years ago

@rgbkrk great, much clearer now on the use case. Would it be possible to arrange a short chat or call to talk further with myself or @pwalsh? Easiest way is to ping me us on gitter via the FrictionlessData channel https://gitter.im/frictionlessdata/chat

rgbkrk commented 7 years ago

Sure, I'm happy to have a chat/call. We've also done some preliminary work to explore the space here: https://github.com/nteract/nteract/pull/1534

rufuspollock commented 7 years ago

@rgbkrk great! Can you PM me on gitter -- i'm rufuspollock. Alternatively, let me know how to ping you.

pwalsh commented 6 years ago

@rgbkrk how did things develop here?

rgbkrk commented 6 years ago

We brought it in and the data resource spec has been part of the nteract release line since August. Feel free to try it out!

The community has also been picking it up as the table schema support that pandas introduced is now used by qgrid to create dynamic tables that rely on table schema.

pwalsh commented 6 years ago

@rgbkrk that is amazing! I'll close this issue then.

I'll talk to @callmealien and @jobarratt here at OKI about a short write up on this work - is it ok if they reach out to you?