-
Notifications
You must be signed in to change notification settings - Fork 607
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
Do not ignore x2's title #3766
Do not ignore x2's title #3766
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,6 +130,24 @@ describe('Axis', function() { | |
} | ||
}); | ||
|
||
it('should store the fieldDef title value if title = null, "", or false', function () { | ||
for (const val of [null, '', false]) { | ||
const model = parseUnitModelWithScale({ | ||
mark: "point", | ||
encoding: { | ||
x: { | ||
field: "a", | ||
type: "quantitative", | ||
title: val as any // Need to cast as false is not valid, but we want to fall back gracefully | ||
} | ||
} | ||
}); | ||
const axisComponent = parseUnitAxis(model); | ||
assert.equal(axisComponent['x'].length, 1); | ||
assert.equal(axisComponent['x'][0].explicit.title, val as any); | ||
} | ||
}); | ||
|
||
it('should store fieldDef.title as explicit', function () { | ||
const model = parseUnitModelWithScale({ | ||
mark: "point", | ||
|
@@ -146,6 +164,47 @@ describe('Axis', function() { | |
assert.equal(axisComponent['x'][0].explicit.title, 'foo'); | ||
}); | ||
|
||
it('should merge title of fieldDef and fieldDef2', function () { | ||
const model = parseUnitModelWithScale({ | ||
mark: "bar", | ||
encoding: { | ||
x: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add a test where only x and only x2 have a title defined. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That doesn't work for other reasons, and I'm not gonna fix it in this PR. Feel free to file another issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay |
||
field: "a", | ||
type: "quantitative", | ||
title: 'foo' | ||
}, | ||
x2: { | ||
field: "b", | ||
type: "quantitative", | ||
title: 'bar' | ||
} | ||
} | ||
}); | ||
const axisComponent = parseUnitAxis(model); | ||
assert.equal(axisComponent['x'].length, 1); | ||
assert.equal(axisComponent['x'][0].explicit.title, 'foo, bar'); | ||
}); | ||
|
||
it('should use title of fieldDef2', function () { | ||
const model = parseUnitModelWithScale({ | ||
mark: "bar", | ||
encoding: { | ||
x: { | ||
field: "a", | ||
type: "quantitative" | ||
}, | ||
x2: { | ||
field: "b", | ||
type: "quantitative", | ||
title: 'bar' | ||
} | ||
} | ||
}); | ||
const axisComponent = parseUnitAxis(model); | ||
assert.equal(axisComponent['x'].length, 1); | ||
assert.equal(axisComponent['x'][0].explicit.title, 'bar'); | ||
}); | ||
|
||
it('should store both x and x2 for ranged mark', function () { | ||
const model = parseUnitModelWithScale({ | ||
mark: "rule", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use an arrow function here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You gonna call another clean all service later anyway, so I'll ignore this :p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay