datopian / city-indicators

A dashboard for city indicators starting with London
https://london.datahub.io/
9 stars 4 forks source link

[EPIC] Refactor #10

Closed anuveyatsu closed 5 years ago

anuveyatsu commented 5 years ago

We have a beautiful, clean dashboard system that is reusable and clean and with nice sublibraries which are well document :smile:

Tasks

Bonus

Factor out code to a separate repo

Analysis

Mermaid graph:

graph LR

viz --> demo
import --> demo
core --> demo

What do we want?

Algorithm:

  1. [Dashboard set up (either in html of config) - layout + widgets + their data]
  2. Widget [Graph with controls] React div with svg etc within it (imagine it as plotly setup). What does the react div need?
  3. [Compiled] Data, view spec, metadata e.g. title, source etc [transform? really part of the view spec]

    • might consider a precursor object which is raw data (raw data pointer), transform, view => compiled data
      
      <Widget
      [compiled]data
      viewspec
      metadata

    = [compiled] data package view ...
    [noncompiled] data resource = one issue atm is how do we deal with mulitple data packages

    
    
    * Central "DB" => computing compiled data for each widget

What do we need

Graph rendering library

FrictionlessWidget(compiled data package view)
  newspec = renderjs.convertViewSpec(...)
  if this.view.spec.type = plotly {
      new PlotlyChart(newspec, layout etc)
  }

Overall app

var config = {
  widgets: [
    {
      elementId / data-id: ...
      view: {
        metadata:
        resources: rule for creating compiled list of resources. [ { datasetId: ..., resourceId: ..., transform: ...} ]
        specType: 
        viewspec: 
      }
    },
    {

    },
  ]
  datasets: [
    list of data package urls ...
  ]
}

function compileResource(datasetId, resourceId, transform, datasets)

var dash = new Dashboard(config)

Widget
  view
  data [= compiled data]
  metadata
anuveyatsu commented 5 years ago

FIXED - see it live https://london.datahub.io/

rufuspollock commented 5 years ago

@anuveyatsu :clap: :clap: can you provide a bit more detail about e.g. where the new repos are, which README i should look at to understand how it works etc etc :smile:

anuveyatsu commented 5 years ago

@rufuspollock there is a short README in this repo which can help if you want to add a new widget. I think it should give you a sense about how it works but I'll open an issue for adding more information about it :+1: