datopian / portal.js.bak

🌀 The JS data presentation framework. For a single dataset to a full catalog.
https://portal-78qurbwf9-datopian1.vercel.app/
MIT License
22 stars 2 forks source link

Add Frictionless views in dataset page #72

Closed risenW closed 3 years ago

risenW commented 3 years ago

Views on the Frictionless object are rendered on the page ...

Acceptance

Screen Shot 2021-03-01 at 1 08 05 PM

Tasks

Analysis

How it works

Frictionless Data View (https://specs.frictionlessdata.io/views/) in a Data Package. E.g. this is a simple one:

{
  "id": "Graph",
  "type": "Graph",
  "state": {
    "graphType": "lines",
    "group": "Date",
    "series": [ "VIXClose" ]
  }
}

Convert the view to spec for the charting library.

graph LR

view --> compiled[Compiled View]
compiled --datapackage-render-js--> plotly[Plotly Spec]
compiled --> vega[Vega Spec]

Algorithm for inlining the data ... - see https://github.com/datopian/frontend-showcase-js/blob/d8918ef6172d394e4bacff4fb8acbd4102fa0ebf/src/index.jsx#L67-L85

How it starts

{
  "id": "Graph",
  "type": "Graph",
  "state": {
    "graphType": "lines",
    "group": "Date",
    "series": [ "VIXClose" ]
  }
}

Then becomes

{
  // where the data comes from ...
  "resources": [0],
  "id": "Graph",
  "type": "Graph",
  "state": {
    "graphType": "lines",
    "group": "Date",
    "series": [ "VIXClose" ]
  }
}

Then becomes ...

{
  // where the data comes from ...
  "resources": [
    {
      name: ...
      _values: ...
    }
  ],
  "id": "Graph",
  "type": "Graph",
  "state": {
    "graphType": "lines",
    "group": "Date",
    "series": [ "VIXClose" ]
  }
}

https://github.com/datopian/datapackage-views-js/blob/bb08d2032e/__fixtures__/chart.fixtures.js

What do i want in a library ...

Given a Frictionless Dataset with a Frictionless View like ...

{
  "id": "Graph",
  "type": "Graph",
  "state": {
    "graphType": "lines",
    "group": "Date",
    "series": [ "VIXClose" ]
  }
}

Use the library like this

dpview = ...

out = dpview(...)

PlotlyView