Skip to content

Adjust local time offset help improve display short time periods (hours) in gl3d plots #3721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/plots/cartesian/set_convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ module.exports = function setConvert(ax, fullLayout) {
// same logic as in Lib.ms2DateTime
var msecTenths = Math.floor(Lib.mod(v + 0.05, 1) * 10);
var msRounded = Math.round(v - msecTenths / 10);
ms = dateTime2ms(new Date(msRounded)) + msecTenths / 10;

var now = (new Date(msRounded)).getTime();
ms = now + msecTenths / 10;
}
else return BADNUM;
}
Expand Down
Binary file added test/image/baselines/gl2d_time-offset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/image/baselines/gl3d_time-offset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions test/image/mocks/gl2d_time-offset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"data": [
{
"type": "scattergl",
"x": ["2020-01-01 01:00:00", "2020-01-01 13:00:00"],
"y": ["2020-01-01 01:00:00", "2020-01-01 02:00:00"]
}
],
"layout": {
"title": "Day time period",
"width": 800,
"height": 600,
"xaxis": { "nticks": 12, "type": "date" },
"yaxis": { "nticks": 12, "type": "date" }
}
}
25 changes: 25 additions & 0 deletions test/image/mocks/gl3d_time-offset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"data": [
{
"type": "scatter3d",
"x": ["2020-01-01 01:00:00", "2020-01-01 13:00:00"],
"y": ["2020-01-01 01:00:00", "2020-01-01 02:00:00"],
"z": ["2020-01-01 01:00:00", "2020-01-01 01:30:00"]
}
],
"layout": {
"title": "Day time period",
"width": 800,
"height": 600,
"scene": {
"xaxis": { "nticks": 12, "type": "date" },
"yaxis": { "nticks": 12, "type": "date" },
"zaxis": { "nticks": 12, "type": "date" },
"camera": {
"eye": { "x": -2, "y": 0.5, "z": 1 },
"center": { "x": 0, "y": 0, "z": 0 },
"up": { "x": 0, "y": 0, "z": 1 }
}
}
}
}
10 changes: 6 additions & 4 deletions test/jasmine/tests/axes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ var failTest = require('../assets/fail_test');
var selectButton = require('../assets/modebar_button');
var supplyDefaults = require('../assets/supply_defaults');

var timeZoneMs = 60000 * (60 + new Date().getTimezoneOffset()); // TODO: find a good way to set CI clock.

describe('Test axes', function() {
'use strict';

Expand Down Expand Up @@ -2641,10 +2643,10 @@ describe('Test axes', function() {
tickmode: 'array',
tickvals: [
'2012-01-01',
new Date(2012, 2, 1).getTime(),
(new Date(2012, 2, 1).getTime()) - timeZoneMs,
'2012-08-01 00:00:00',
'2012-10-01 12:00:00',
new Date(2013, 0, 1, 0, 0, 1).getTime(),
(new Date(2013, 0, 1, 0, 0, 1).getTime()) - timeZoneMs,
'2010-01-01', '2014-01-01' // off the axis
],
// only the first two have text
Expand Down Expand Up @@ -3008,7 +3010,7 @@ describe('Test axes', function() {
});

it('- date case', function() {
var msLocal = new Date(2000, 0, 1).getTime();
var msLocal = (new Date(2000, 0, 1).getTime()) - timeZoneMs;
var msUTC = 946684800000;
var out = _makeCalcdata({
x: ['2000-01-01', NaN, null, msLocal],
Expand Down Expand Up @@ -3101,7 +3103,7 @@ describe('Test axes', function() {

it('- on a date axis', function() {
var dates = [[2000, 0, 1], [2001, 0, 1], [2002, 0, 1]]
.map(function(d) { return new Date(d[0], d[1], d[2]).getTime(); });
.map(function(d) { return (new Date(d[0], d[1], d[2]).getTime()) - timeZoneMs; });

// We could make this work down the road (in v2),
// when address our timezone problems.
Expand Down