Skip to content

Commit

Permalink
Fixed facets with UTC time (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderby authored Jan 13, 2017
1 parent dd9f930 commit b0f0b41
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
7 changes: 4 additions & 3 deletions src/algebra.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ var FramesAlgebra = {
[]);
},

cross_period(dataFn, dimX, dimY, xPeriod, yPeriod) {
cross_period(dataFn, dimX, dimY, xPeriod, yPeriod, guide) {
var data = dataFn();
var utc = (guide ? guide.utcTime : false);

var domainX = utils.unique(data.map(x => x[dimX]), unify);
var domainY = utils.unique(data.map(x => x[dimY]), unify);
Expand All @@ -46,11 +47,11 @@ var FramesAlgebra = {
var domY = domainY.length === 0 ? [null] : domainY;

if (xPeriod) {
domX = UnitDomainPeriodGenerator.generate(Math.min(...domainX), Math.max(...domainX), xPeriod);
domX = UnitDomainPeriodGenerator.generate(Math.min(...domainX), Math.max(...domainX), xPeriod, {utc});
}

if (yPeriod) {
domY = UnitDomainPeriodGenerator.generate(Math.min(...domainY), Math.max(...domainY), yPeriod);
domY = UnitDomainPeriodGenerator.generate(Math.min(...domainY), Math.max(...domainY), yPeriod, {utc});
}

return domY.reduce(
Expand Down
6 changes: 3 additions & 3 deletions src/charts/tau.gpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export class GPL extends Emitter {

} else {

var expr = this._parseExpression(root.expression, parentPipe);
var expr = this._parseExpression(root.expression, parentPipe, root.guide);

root.transformation = root.transformation || [];

Expand Down Expand Up @@ -253,7 +253,7 @@ export class GPL extends Emitter {
return new DataFrame(frame, this.sources[frame.source].data, this.transformations);
}

_parseExpression(expr, parentPipe) {
_parseExpression(expr, parentPipe, guide) {

var funcName = expr.operator || 'none';
var srcAlias = expr.source;
Expand All @@ -278,7 +278,7 @@ export class GPL extends Emitter {
inherit: bInherit,
func: func,
args: funcArgs,
exec: () => func(dataFn, ...(funcArgs || []))
exec: () => func(dataFn, ...(funcArgs || []), guide)
};
}
}
3 changes: 2 additions & 1 deletion src/spec-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export class SpecConverter {
childUnit.guide = utils.defaults(
(childUnit.guide || {}),
{
animationSpeed: settings.animationSpeed || 0
animationSpeed: settings.animationSpeed || 0,
utcTime: settings.utcTime || false
}
);

Expand Down
14 changes: 10 additions & 4 deletions test/spec-converter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ define(function (require) {
"namespace": "chart",
"guide": {
"animationSpeed": 0,
"utcTime": false,
"x": {},
"y": {}
},
Expand All @@ -144,13 +145,15 @@ define(function (require) {
],
"namespace": "chart",
"guide": {
"animationSpeed": 0
"animationSpeed": 0,
"utcTime": false
}
}
],
"namespace": "chart",
"guide": {
"animationSpeed": 0
"animationSpeed": 0,
"utcTime": false
}
}
};
Expand Down Expand Up @@ -288,7 +291,8 @@ define(function (require) {
"guide": {
"x": {"tickPeriod": "week"},
"y": {"tickLabel": "name"},
"animationSpeed": 0
"animationSpeed": 0,
"utcTime": false
},
"expression": {
"inherit": false,
Expand Down Expand Up @@ -319,6 +323,7 @@ define(function (require) {
"namespace": "chart",
"guide": {
"animationSpeed": 0,
"utcTime": false,
"x": {},
"y": {}
},
Expand All @@ -328,7 +333,8 @@ define(function (require) {
],
"namespace": "chart",
"guide": {
"animationSpeed": 0
"animationSpeed": 0,
"utcTime": false
}
}
],
Expand Down

0 comments on commit b0f0b41

Please sign in to comment.