8000 apply UTC time only to bar length for now · plotly/plotly.js@6155965 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6155965

Browse files
committed
apply UTC time only to bar length for now
1 parent 2087766 commit 6155965

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/plots/cartesian/set_convert.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ module.exports = function setConvert(ax, fullLayout) {
9090
* - inserts a dummy arg so calendar is the 3rd arg (see notes below).
9191
* - defaults to ax.calendar
9292
*/
93-
function dt2ms(v, _, calendar) {
93+
function dt2ms(v, _, calendar, msUTC) {
9494
// NOTE: Changed this behavior: previously we took any numeric value
9595
// to be a ms, even if it was a string that could be a bare year.
9696
// Now we convert it as a date if at all possible, and only try
@@ -106,7 +106,12 @@ module.exports = function setConvert(ax, fullLayout) {
106106

107107
var d = new Date(msRounded);
108108
ms = dateTime2ms(d) + msecTenths / 10;
109-
ms += d.getTimezoneOffset() * ONEMIN;
109+
if(msUTC) {
110+
// For now it is only used
111+
// to fix bar length in milliseconds.
112+
// It could be applied in other places in v2
113+
ms += d.getTimezoneOffset() * ONEMIN;
114+
}
110115
} else return BADNUM;
111116
}
112117
return ms;
@@ -794,7 +799,7 @@ module.exports = function setConvert(ax, fullLayout) {
794799
// the first letter of ax._id?)
795800
// in case the expected data isn't there, make a list of
796801
// integers based on the opposite data
797-
ax.makeCalcdata = function(trace, axLetter) {
802+
ax.makeCalcdata = function(trace, axLetter, msUTC) {
798803
var arrayIn, arrayOut, i, len;
799804

800805
var axType = ax.type;
@@ -818,10 +823,10 @@ module.exports = function setConvert(ax, fullLayout) {
818823

819824
arrayOut = new Array(len);
820825
for(i = 0; i < len; i++) {
821-
arrayOut[i] = ax.d2c(arrayIn[i], 0, cal);
826+
arrayOut[i] = ax.d2c(arrayIn[i], 0, cal, msUTC);
822827
}
823828
} else {
824-
var v0 = ((axLetter + '0') in trace) ? ax.d2c(trace[axLetter + '0'], 0, cal) : 0;
829+
var v0 = ((axLetter + '0') in trace) ? ax.d2c(trace[axLetter + '0'], 0, cal, false) : 0;
825830
var dv = (trace['d' + axLetter]) ? Number(trace['d' + axLetter]) : 1;
826831

827832
// the opposing data, for size if we have x and dx etc

src/traces/bar/calc.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ module.exports = function calc(gd, trace) {
1919
var ya = Axes.getFromId(gd, trace.yaxis || 'y');
2020
var size, pos;
2121

22+
var msUTC = !!(trace.base || trace.base === 0);
23+
2224
if(trace.orientation === 'h') {
23-
size = xa.makeCalcdata(trace, 'x');
24-
pos = ya.makeCalcdata(trace, 'y');
25+
size = xa.makeCalcdata(trace, 'x', msUTC);
26+
pos = ya.makeCalcdata(trace, 'y', msUTC);
2527
} else {
26-
size = ya.makeCalcdata(trace, 'y');
27-
pos = xa.makeCalcdata(trace, 'x');
28+
size = ya.makeCalcdata(trace, 'y', msUTC);
29+
pos = xa.makeCalcdata(trace, 'x', msUTC);
2830
}
2931

3032
// create the "calculated data" to plot

0 commit comments

Comments
 (0)
0