Git Product home page Git Product logo

Comments (5)

ajturner avatar ajturner commented on August 25, 2024

poke

from cedar.

dbouwman avatar dbouwman commented on August 25, 2024

So - the problem is that in the time.json, we were using the data[0].url property to append in an orderByField into the query.

The #31 PR changed things so that the data is always fetched by Cedar and always passed to Vega as an array. Thus, this url hack to apply a sort can't work.

Since sorting is a "first class" problem, we should have a consistent means to address it.

Simplest Option

Allow the developer to specify a sort and attach that to the mappings. This string would be formatted exactly how the REST api expects ordreByFields to be, and would simply be merged into the query string.

  var dataset = {
    "url":"http://services.arcgis.com/bkrWlSKcjUDFDtgw/arcgis/rest/services/It's_a_Tornado_Map/FeatureServer/0",
    "mappings":{
      "time": {"field":"Date"},
      "value": {"field":"Injuries"},
      "sort":"Date DESC"
    }
  };
  chart.dataset = dataset;
  //or...
  chart.dataset.mappings.sort = "Date ASC";

This is nice because the sort could be applied to any field in the service.

Structured Option

Add a optional sort property to the mappings hash. It could have values of "ASC" or "DESC" which are the values associated with orderByFields param in the REST API

var dataset = {
    "url":"http://services.arcgis.com/bkrWlSKcjUDFDtgw/arcgis/rest/services/It's_a_Tornado_Map/FeatureServer/0",
    "mappings":{
      "time": {"field":"Date", "sort":"ASC"},
      "value": {"field":"Injuries"}
    }
  };

The limitation with that is that you could only sort by one of the mapped fields.

Conclusion

I built out support for both, but I feel that the first is a better option. This is because with sort, the order in which the sort fields are put into the orderByFields string impacts the output. Putting more than one sort into the mappings, will result in non-deterministic (or at least non-obvious) ordering of the orderByFields parameter. Explicitly setting the mappings.sort= 'FieldA ASC, FieldB DESC' affords complete control with low "surprise" factor. PRing in a moment

from cedar.

ajturner avatar ajturner commented on August 25, 2024

from cedar.

dbouwman avatar dbouwman commented on August 25, 2024

PR for this is in #70

from cedar.

benheb avatar benheb commented on August 25, 2024

LGTM http://esridc.github.io/cedar/examples/time.html. Closing.

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.