Giter Site home page Giter Site logo

Comments (9)

rochoa avatar rochoa commented on August 16, 2024 1

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.

Jesus89 avatar Jesus89 commented on August 16, 2024 1

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.

davidmanzanares avatar davidmanzanares commented on August 16, 2024

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.

davidmanzanares avatar davidmanzanares commented on August 16, 2024

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.

davidmanzanares avatar davidmanzanares commented on August 16, 2024
  • 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.

davidmanzanares avatar davidmanzanares commented on August 16, 2024

@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.

rochoa avatar rochoa commented on August 16, 2024

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.

IagoLast avatar IagoLast commented on August 16, 2024

Moment.js is quite heavy, I think date constructor will do the job.

from carto-vl.

davidmanzanares avatar davidmanzanares commented on August 16, 2024

Implemented with Date constructor

from carto-vl.

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.