Skip to content
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

Adding quarter to timeUnit for #947 #1305

Merged
merged 31 commits into from
Jul 1, 2016
Merged

Adding quarter to timeUnit for #947 #1305

merged 31 commits into from
Jul 1, 2016

Conversation

bobocandys
Copy link
Contributor

@bobocandys bobocandys commented Apr 19, 2016

Make axis compatible with quarter as timeUnit.

@domoritz
Copy link
Member

Looks like you are on the right track but there is still a lot missing. I suggest that you think of a few examples, write tests for those and see that you support them. For instance, the time unit can be year, year-quarter, year-quarter-month.

@@ -114,7 +117,10 @@ export function formatMixins(model: Model, channel: Channel, format: string) {
def.format = model.config().numberFormat;
break;
case TEMPORAL:
def.format = timeFormat(model, channel) || model.config().timeFormat;
if ((!fieldDef.timeUnit) || (fieldDef.timeUnit &&
fieldDef.timeUnit.toString().indexOf('quarter') === -1)) {
Copy link
Member

@domoritz domoritz Apr 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write a util function for this? Something like hasTimeUnit(string, timeUnit).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the second argument should be a timeUnit so you will need to convert it to a string. Let me know if you can't find out how to convert from a ts enum value to a string.

@kanitw kanitw changed the title [WIP] Adding quarter to timeUnit for #947 Adding quarter to timeUnit for #947 Apr 29, 2016
@@ -103,7 +103,9 @@ export function formatMixins(model: Model, channel: Channel, format: string) {
let def: any = {};

if (fieldDef.type === TEMPORAL) {
def.formatType = 'time';
if ((!fieldDef.timeUnit) || !containsTimeUnit(fieldDef.timeUnit, TimeUnit.QUARTER)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you comment why if there is no timeUnit or if the timeUnit is quarter we don't assign formatType here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess for quarter, we use format as a part of template?

@domoritz
Copy link
Member

LGTM. @bobocandys can you merge master into this so I can do a final review and merge?

@kanitw
Copy link
Member

kanitw commented May 18, 2016

Test still failing

bobocandys and others added 4 commits May 19, 2016 15:13
Make sure text works for axis, label, legend and mark.
Use templates everywhere instead of format and formatType or template.
@domoritz
Copy link
Member

domoritz commented May 22, 2016

Only need to adapt to latest datalib changes. Then we're ready to go.

Problem is that we also need to wait for a vega release that includes latest datalib changes. Note that the latest dl change is not yet in a release.

@kanitw
Copy link
Member

kanitw commented May 22, 2016

@arvind Do you plan to release a Vega patch sometimes soon? (Two PR are blocked by the next Vega release.)

@arvind
Copy link
Member

arvind commented May 22, 2016

There have been some features that have landed into Vega master, so I'm hesitant to cut a patch release. My goal is to release a minor version once Emily's themeing work has landed which should hopefully be within the week or two. If a patch release is urgent, I can create one by rolling back on master.

@domoritz domoritz added the Blocked 🕐 For issues that are blocked by other issues label May 22, 2016
@domoritz
Copy link
Member

@bobocandys Let's wait for the vega release. Until then the test should fail in this pr.

@kanitw
Copy link
Member

kanitw commented May 22, 2016

Why is the test passing now?

@domoritz
Copy link
Member

I'm not sure. I thought the tests should be failing because we use an unreleased feature (quarter filters in expressions) but we can detect the error only if we parse a spec with vega (expecting Error: Unrecognized template filter: quarter). @bobocandys I was expecting line_quarter.json to cause test failures but tests pass. Can you look into why?

@domoritz
Copy link
Member

This should not be blocked any more.

@domoritz domoritz removed the Blocked 🕐 For issues that are blocked by other issues label Jun 22, 2016
const format = model.config().mark.format;
extend(p, formatMixins(model, TEXT, format));
} else if (TEMPORAL === model.fieldDef(TEXT).type) {
p.text = {
// need to replace datum.data -> datum.FIELD_NAME
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@domoritz this regexp looks complicated, not sure if we really need it.

@domoritz domoritz merged commit e6d4f64 into master Jul 1, 2016
@domoritz domoritz deleted the ylin/addTimeUnit branch July 1, 2016 19:13
if (out.length > 0) {
// clean up quarter formatting remainders
const template = '{{' + field + ' | time:\'' + out.join(' ') + '\'}}';
return template.replace(new RegExp('{{' + field + ' \\| time:\'\'}}', 'g'), '');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@domoritz another regexp that I don't understsand ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants