Giter Site home page Giter Site logo

Change timeline timezone about vis HOT 24 CLOSED

almende avatar almende commented on July 26, 2024
Change timeline timezone

from vis.

Comments (24)

josdejong avatar josdejong commented on July 26, 2024

That is not on the planning. The Timeline internally already uses moment.js here and there, so it may be relatively easy to implement moment-timezone.js.

from vis.

losttheplot avatar losttheplot commented on July 26, 2024

If anyone has successfully implemented this suggestion, please could they post the basic steps necessary, to help get me started - thanks :)

from vis.

ftringali avatar ftringali commented on July 26, 2024

For 3.7.1 version, changing the line (row 25600)
c._isUTC = false;
to
c._isUTC = true;
did the trick.

Using the minified version, search for o._isUTC=!1 and change it to o._isUTC=!0

Hope this helps

from vis.

josdejong avatar josdejong commented on July 26, 2024

That looks like a dangerous trick...

from vis.

ftringali avatar ftringali commented on July 26, 2024

Why?

However, dealing just with UTC dates created via epoch I see no side effect.

from vis.

josdejong avatar josdejong commented on July 26, 2024

It's generally a bad idea to change internal, private variables of an external library, there can easily be overlooked side effects. You will eventually shoot your self in the foot with these kind of hacks.

  • With every update of the library, you need to be careful fixing this manually changed thing again (hopefully, the trick still can be applied in newer versions of the library having changed internals).
  • Probably, after a couple of months you forgot about this manual change in the code, and after updating to a newer version of the library things break. Furthermore,
  • Your colleagues probably don't know about this hook at all and assume the moment.js library works as described in the docs of the library, which isn't the case anymore. That can give weird, hard to track down situations.
  • If your application happens to use multiple modules all relying on moment.js, these modules may act unexpectedly as they assume the default behavior as documented by moment.js itself.

Did you have a look at moment.utc()? Docs: http://momentjs.com/docs/#/parsing/utc/

from vis.

ftringali avatar ftringali commented on July 26, 2024

Yep, I agree (strongly). But I need a "quick and dirty" solution and the timeline uses moment() in too many places to propose a change on your side.

Is there a way to vote for desired enhancements?

from vis.

josdejong avatar josdejong commented on July 26, 2024

This issues section is both for issues and feature requests.

But again, isn't moment.utc() doing exactly what you need?

from vis.

gonzafirewall avatar gonzafirewall commented on July 26, 2024

I have the same problem i need that the timeline show me the time in the timezone that i configure, example. I am in Argentina (-3) y pass to setCursorTime the utc time and need that the timeline show me the date in timezone La_Paz that is (-4), Now if i pass a moment object or a Date object i see that the timeline convert to my locale.

from vis.

ftringali avatar ftringali commented on July 26, 2024

@jos
yes, it does... but the setting of moment.utc objects as items has no effect on the timeline labels.

Please, let us know

from vis.

josdejong avatar josdejong commented on July 26, 2024

Good point. Maybe as a solution the Timeline should allow to give your own moment constructor via the options, so that you can return moment.utc(...) or some custom time zone instead of local time.

from vis.

lee-nk avatar lee-nk commented on July 26, 2024

Hi. Just wanted to add my vote to this feature request. We are using the Timeline in a web app that is used by people in multiple time zones, and it is very important to us to be able to all use UTC time. For now we are just adding 12 hours to items in the timeline to get the correct times. Thanks :)

from vis.

fdelapena avatar fdelapena commented on July 26, 2024

+1 for this, having a large amount of data and manipulating array timestamps from server or client side is not fast.

from vis.

jonhel avatar jonhel commented on July 26, 2024

+1

from vis.

AdamNowaczyk avatar AdamNowaczyk commented on July 26, 2024

This is something we need as well. We need to show graphs in the server timezone, not user timezone. We use Graph2D and we pass dates in ISO 8601 format. Any suggestions on how to 'force' vis js to that timezone?

Thanks,
Adam

from vis.

arixol avatar arixol commented on July 26, 2024

Our application also needs this fix. A simple setTimezoneUTC=true option would suffice for us.

We pass dates using UTC time and the Timeline rearranges them based on local time, so our points are inaccurate.

For example, if I add the date 2015-06-08T15:30:49.000Z to the Timeline and the user is in New York, it will show up in the Timeline as 11:30:49 EDT, which doesn't make sense and confuses the user. When I apply ftringali's hack of setting o._isUTC=!0 in vis.min.js, the point shows up where it should at 15:30:49 UTC.

Are there any plans to make this a setting?

Thanks.

from vis.

Heinzelemente avatar Heinzelemente commented on July 26, 2024

The same for our projects. Please add this soon +1:

from vis.

josdejong avatar josdejong commented on July 26, 2024

I've implemented support for time zones by means of a configuration option moment. This is by default is date constructor of moment.js, but can be overloaded which allows applying a custom time zone:

// display in UTC
var options = {
  moment: function(date) {
    return vis.moment(date).utc();
  }
};

// display in UTC +08:00
var options = {
  moment: function(date) {
    return vis.moment(date).utcOffset('+08:00');
  }
};

See this example: https://github.com/almende/vis/blob/develop/examples/timeline/other/timezone.html

I would love to get some feedback on whether the current implementation works correctly and addresses these issues. You can checkout or download the develop branch to give it a try.

from vis.

Atala avatar Atala commented on July 26, 2024

Just when I needed it. Thanks!

Seems to work fine for me with basic UTC usage.

from vis.

BuschnicK avatar BuschnicK commented on July 26, 2024

Is it possible to change the time zone dynamically after the timeline has already been constructed? I've tried modifying the options member, but that didn't seem to have any effect:
timeline.options.moment = function(date) {
return vis.moment(date).utc();
}

I'm working on a tool that displays data from around the globe and I'd like to be able to switch between local time zone and UTC time zone.

from vis.

josdejong avatar josdejong commented on July 26, 2024

You can update the options at any moment via Timeline.setOptions(options), so I guess you could provide a new moment instance with different time zone.

from vis.

BuschnicK avatar BuschnicK commented on July 26, 2024

That's what I tried, but it doesn't update the timeline.
On Apr 5, 2016 10:08, Jos de Jong [email protected] wrote:You can update the options at any moment via Timeline.setOptions(options), so I guess you could provide a new moment instance with different time zone.

—You are receiving this because you commented.Reply to this email directly or view it on GitHub

from vis.

daniel-pfeiffer avatar daniel-pfeiffer commented on July 26, 2024

I just figured that also utc is itself a constructor, so you can simplify the 1st above example to:

// display in UTC
var options = {
  moment: vis.moment.utc
};

With 2 less function calls this is also more efficient.

from vis.

AbdulAdnanBaig avatar AbdulAdnanBaig commented on July 26, 2024

I've been facing a common issue for a few days now, The scenario goes as follows.

  1. I receive the timezone of a user on Login and pass that param to the timeline.
  2. Now when i change the system timezone to a different zone, the chart still holds the timezone of the user which i provide and does not overwrite it with the system time zone (As Expected).
  3. But if i neglect the system timezone, and manually set a time and date, the chart immediately picks up that manually changed wrong data and overwrites my the user timezone.

Help me find a solution where under any circumstance, there cannot be any overwriting of timezone. The source can only be one.

from vis.

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.