Comments (5)
poke
from cedar.
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.
from cedar.
PR for this is in #70
from cedar.
LGTM http://esridc.github.io/cedar/examples/time.html. Closing.
from cedar.
Related Issues (20)
- Add to doc - examples of changing data formats HOT 1
- Please show examples using ArcGIS API for JavaScript version 4.x HOT 3
- Capability to Convert Between Units? HOT 2
- deploy v1 docs
- domains are not decoded for datasets that don't query features (i.e. use `data`)
- fetching chart JSON from "CDN" returns 404 for v0.x HOT 8
- give @jgravois the keys to publish arcgis-cedar on npm HOT 1
- definition should provide a way to specify or override default axis labels
- how to set up cedar properly to chart object arrays? HOT 2
- Cedar not working - TypeError: keys.reduce is not a function HOT 4
- add repository.directory to packakge.json
- Sparkline Support
- Chart not rendering data correctly HOT 2
- change color of data series
- Cedar with React HOT 3
- number format issue HOT 5
- export button HOT 1
- add function that converts the chart data/series to a feature set HOT 1
- Allow passing request options to query HOT 1
- UMD bundles include arcgis-rest-js dependencies HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cedar.