Skip to content

Commit

Permalink
change from padding: 'Inifinity' to padding: null
Browse files Browse the repository at this point in the history
  • Loading branch information
chanwutk authored and jheer committed Sep 21, 2021
1 parent a65ebf8 commit b5c1db5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions packages/vega-label/src/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ const Anchors = [
* The available options are 'top-left', 'left', 'bottom-left', 'top',
* 'bottom', 'top-right', 'right', 'bottom-right', 'middle'.
* @param {Array<number>} [params.offset] - Label offsets (in pixels) from the base mark bounding box.
* This parameter is parallel to the list of anchor points.
* @param {number | 'Infinity'} [params.padding=0] - The amount (in pixels) that a label may exceed the layout size.
* This parameter is parallel to the list of anchor points.
* @param {number | null} [params.padding=0] - The amount (in pixels) that a label may exceed the layout size.
* If this parameter is null, a label may exceed the layout size without any boundary.
* @param {string} [params.lineAnchor='end'] - For group line mark labels only, indicates the anchor
* position for labels. One of 'start' or 'end'.
* @param {string} [params.markIndex=0] - For group mark labels only, an index indicating
Expand All @@ -59,7 +60,7 @@ Label.Definition = {
{ name: 'sort', type: 'compare' },
{ name: 'anchor', type: 'string', array: true, default: Anchors },
{ name: 'offset', type: 'number', array: true, default: [1] },
{ name: 'padding', type: 'number', default: 0 },
{ name: 'padding', type: 'number', default: 0, null: true },
{ name: 'lineAnchor', type: 'string', values: ['start', 'end'], default: 'end' },
{ name: 'markIndex', type: 'number', default: 0 },
{ name: 'avoidBaseMark', type: 'boolean', default: true },
Expand Down Expand Up @@ -95,7 +96,7 @@ inherits(Label, Transform, {
_.avoidBaseMark !== false,
_.lineAnchor || 'end',
_.markIndex || 0,
_.padding || 0,
_.padding === undefined ? 0 : _.padding,
_.method || 'naive'
).forEach(l => {
// write layout results to data stream
Expand Down
2 changes: 1 addition & 1 deletion packages/vega-label/src/LabelLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function(texts, size, compare, offset, anchor,
grouptype = marktype === 'group' && texts[0].datum.items[markIndex].marktype,
isGroupArea = grouptype === 'area',
boundary = markBoundary(marktype, grouptype, lineAnchor, markIndex),
infPadding = padding === 'Infinity' || padding === Infinity,
infPadding = padding === null || padding === Infinity,
$ = scaler(size[0], size[1], infPadding ? 0 : padding),
isNaiveGroupArea = isGroupArea && method === 'naive';

Expand Down
4 changes: 2 additions & 2 deletions packages/vega-label/test/label-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ tape('Label performs label layout over input points with infinity padding', t =>
t.equal(out[0].opacity, 0);

df.update(an, 'left')
.update(pd, 'Infinity')
.update(pd, null)
.pulse(c0, vega.changeset().remove(util.truthy).insert(data()))
.run();
out = c0.value;
Expand All @@ -318,7 +318,7 @@ tape('Label performs label layout over input points with infinity padding', t =>
t.equal(out[0].opacity, 1);

df.update(an, 'right')
.update(pd, 'Infinity')
.update(pd, null)
.pulse(c0, vega.changeset().remove(util.truthy).insert(data()))
.run();
out = c0.value;
Expand Down
2 changes: 1 addition & 1 deletion packages/vega-typings/types/spec/transform.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ export interface LabelTransform {
sort?: Compare;
offset?: number[] | number | SignalRef;
anchor?: LabelAnchor[] | LabelAnchor | SignalRef;
padding?: number | 'Infinity' | SignalRef;
padding?: number | null | SignalRef;
markIndex?: number;
lineAnchor?: LineLabelAnchor | SignalRef;
avoidBaseMark?: boolean | SignalRef;
Expand Down

0 comments on commit b5c1db5

Please sign in to comment.