Code Monkey home page Code Monkey logo

Comments (9)

ajturner avatar ajturner commented on May 28, 2024

Thanks - this is a good step to iron out. I'm tempted to suggest we put this forth on the Vega mailing list / repo. It would be valuable to get broader community input as it could be useful to them or give feedback on what to be aware of issues.

I think it's ok to be nesting the vega template in a separate object - though it also feels weird. We are breaking the spec by using the {variable} so it's not valid until it's merged. We should still support Vega format directly. If someone authors a chart in R they should be able to load it via URL or inline JSON. I believe var cedar = new Cedar({chartDefinition: chartDefintionObjOrUrl}) supports that.

An internal format is fine for whatever works. But for the developer API, one litmus test of usability I like to use is, can I write it by hand without looking at the docs or a JSON formatter?

Nitpicking:

  • use dataset instead of dataSource to align with opendata api discussions
  • don't duplicate words (e.g. chart* within the chart construtor - we already know it's a chart-something)
  • generally avoid multiWordNames.
{
  "inputs":[... array of inputs...],
  "template":{ ... template of a vega spec ...}
}

becomes:

{ 
 "dataset": {
   "url": "...url to service...",
   "query": {... json hash of query params ...}
   "data": [...optional array of features...]
  },
  "specification": {
    "inputs":[... array of inputs...],
    "template":{ ... template of a vega spec ...}
  }
}

from cedar.

dbouwman avatar dbouwman commented on May 28, 2024

Great feedback! As they say - naming things is one of "the hard problems" :)

As for vega spec's authored elsewhere - since they lack the "inputs" hash and the {variable} templates, all we can do is display the chart. We would likely also need defensive code to block attempts to manipulate the chart - i.e. the query etc.

Finally - in the example code I showed some chaining -after some digging, while we can build some aspects of the api to be chainable (likely setters), getters (by their nature) can't chain. Also - if we use real javascript properties, then we can't chain properties at all because the setters are not functions.

More chaining info from d3 http://alignedleft.com/tutorials/d3/chaining-methods

Anyhow - that's something I'll explore and we can discuss with some consumers of the api... chaining is elegant, but I don't think we want elegance at the cost of confusion.

from cedar.

ajturner avatar ajturner commented on May 28, 2024

Indeed standard Vega would not be templates, but hard-coded but still 'embeddable' in a webmap, or alone via Cedar. Perhaps still as a Portal Item

from cedar.

dbouwman avatar dbouwman commented on May 28, 2024

Agreed - I'm starting the refactor to this json now.

from cedar.

dbouwman avatar dbouwman commented on May 28, 2024

just for the record - this is the structure I'm using... I'm putting the mappings into the dataset node as it's tightly bound to the... dataset

{ 
 "dataset": {
   "url": "...url to service...",
   "query": {... json hash of query params ...}
   "data": [...optional array of features...],
   "mappings":{...mappings hash..}
  },
  "specification": {
    "inputs":[... array of inputs...],
    "template":{ ... template of a vega spec ...}
  }
}
``

from cedar.

ajturner avatar ajturner commented on May 28, 2024

Sounds good for now, though I could see benefit keeping them separate since the mappings is the join and the data are independent of the chart template. So the data could be reused or defined in operation layers that applies to different chart specifications.

Keep joined for now and we can pull apart if based on future benefit.

from cedar.

dbouwman avatar dbouwman commented on May 28, 2024

Update: have it working, but in the process, made the Cedar super messy - will clean up, get the other examples working and PR over the weekend.

I also picked up a temporary dependency on underscore - for object cloning and augmentation - will likely remove this and cook in a custom build of lodash to have just the helpers we need.

from cedar.

ajturner avatar ajturner commented on May 28, 2024

made the Cedar super messy

sappy

picked up a temporary dependency on underscore

I was wondering if this was going to happen. I like moving to the built-in and later removed of lodash when possible.

Looking forward to working with it once you get this JSON in place.

from cedar.

dbouwman avatar dbouwman commented on May 28, 2024

Closing as the main PR for this was merged

from cedar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.