Comments (9)
Literal timestamps should follow ISO 8601, as it would be easier to support time zones and adjusting that to the client configuration.
from carto-vl.
I replaced moment.js
by little maths with Date some time ago, saving half size of the Carto.js bundle: CartoDB/carto.js#1981
from carto-vl.
After talking with @rochoa and discarding the named parameters example because adding it would difficult the consistency between JS API and String API. We came to the following examples:
s.torque(s.prop('d'), 10);
s.torque(s.prop('d'), 10, s.fade(0.1, 0.6), s.dateRange('15/01/1917', '1/01/1922'));
s.torque(s.prop('d'), 10, s.default, s.dateRange('15/01/1917', '1/01/1922'));
EDIT: Not applicable anymore:
This would require:
- [ ] Adding `torque(property, durationInSeconds=10, fade=s.default, range=s.default)` which is similar to the already implemented `near()`, but it has better semantics and is more controllable (see `fade()`).
- [ ] Adding `s.DEFAULT` as a symbolic constant for default parameters, it would be accessed with just `default` in the string API.
- [ ] Adding `fade(arg1, arg2=s.default)`, which will have the following semantics: with one parameter, it will set fadeIn and fadeOut to that parameter, when called with two parameters, fadeIn and fadeOut will be assigned to them respectively.
- [ ] Adding `dateRange(from, to)`, which will parse `from` and `to` to get date timestamps.
- [ ] Adding `globalDateRange(property)` which will be used by `torque()` when range is set to default.
Related to: #130
from carto-vl.
After talking, again, with @rochoa, we came to the conclusion that the dateRange should be part of the first argument, which is similar to ramp(linear...
.
Examples:
Default min/max:
filter: torque($day, 40, fade(0.1, 0.3))`
Explicit min/max:
filter: torque(linear($day, '15/01/1917', '1/01/1922'), 40, fade(0.1, 0.3))`
from carto-vl.
- Add
torque()
- Add
fade()
- Get default min/max timestamps
- Add support for literal timestamps: '15/01/1917'
- Add support for ´linear´ with timestamps
from carto-vl.
@rochoa I guess this https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse is not good enough, from their docs:
Note: parsing of date strings with the Date constructor (and Date.parse, they are equivalent) is strongly discouraged due to browser differences and inconsistencies. Support for RFC 2822 format strings is by convention only. Support for ISO 8601 formats differs in that date-only strings (e.g. "1970-01-01") are treated as UTC, not local.
Do you recommend some library?
from carto-vl.
My recommendation is Moment.js, but for the time being, we can rely on the constructor and assume it will work in modern browsers (the browsers we support in the library). See:
> new Date('2018-03-06T17:00:00.000Z')
< 'Tue Mar 06 2018 18:00:00 GMT+0100 (CET)'
from carto-vl.
Moment.js is quite heavy, I think date constructor will do the job.
from carto-vl.
Implemented with Date constructor
from carto-vl.
Related Issues (20)
- Cannot blend animation.duration if it's a variable
- Allow animation controls for any animated property
- Allow to assign a new expression to a new viz variable when the layer has been loaded HOT 2
- MVTs with bottom-left corner as the origin of coordinates HOT 1
- GeoJSON source issues with viz updates HOT 2
- some carto expression not working in geojson HOT 2
- CVL 1.4.1 regression :: filtering with list does not work anymore HOT 1
- [WebGL]: An error occurred compiling the shaders: ERROR: Expression too complex. HOT 1
- 'Time' function inside the Viz filter seems broken
- Mobile maps are not able to load the data HOT 17
- Lower minimum MAX_VERTEX_TEXTURE_IMAGE_UNITS requirement HOT 1
- Update MAX_VERTEX_TEXTURE_IMAGE_UNITS parameter at browser support doc HOT 1
- Windshaft-carto-vl docker image is broken HOT 5
- Issue with numeric buckets when defined in descending order
- Blog map issue HOT 1
- Viewport numeric computation are somehow wrong when zoom is < 2
- Typescript support HOT 2
- this._source.requiresNewMetadata is not a function on blendToViz with an MVT Layer HOT 1
- Styling point width by variables renders incorrectly on mobile devices
- How to use clusterCount expression on GeoJson Data?
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 carto-vl.