Skip to content

Commit 76bdf54

Browse files
committed
Merge branch 'master' into djbarnwal-db/legendInteractive
2 parents d002977 + 50429d3 commit 76bdf54

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+178
-172
lines changed

site/Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ GEM
206206
jekyll-seo-tag (~> 2.1)
207207
minitest (5.12.2)
208208
multipart-post (2.1.1)
209-
nokogiri (1.10.4)
209+
nokogiri (1.10.5)
210210
mini_portile2 (~> 2.4.0)
211211
octokit (4.14.0)
212212
sawyer (~> 0.8.0, >= 0.5.3)

src/channeldef.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ export function vgField(
588588
const {bin, aggregate, timeUnit} = fieldDef;
589589
if (isBinning(bin)) {
590590
fn = binToString(bin);
591-
suffix = (opt.binSuffix || '') + (opt.suffix || '');
591+
suffix = (opt.binSuffix ?? '') + (opt.suffix ?? '');
592592
} else if (aggregate) {
593593
if (isArgmaxDef(aggregate)) {
594594
argAccessor = `.${field}`;
@@ -601,7 +601,7 @@ export function vgField(
601601
}
602602
} else if (timeUnit) {
603603
fn = String(timeUnit);
604-
suffix = ((!contains(['range', 'mid'], opt.binSuffix) && opt.binSuffix) || '') + (opt.suffix || '');
604+
suffix = ((!contains(['range', 'mid'], opt.binSuffix) && opt.binSuffix) || '') + (opt.suffix ?? '');
605605
}
606606
}
607607
}
@@ -717,14 +717,14 @@ export function title(
717717
config: Config,
718718
{allowDisabling, includeDefault = true}: {allowDisabling: boolean; includeDefault?: boolean}
719719
) {
720-
const guide = getGuide(fieldDef) || {};
720+
const guide = getGuide(fieldDef) ?? {};
721721
const guideTitle = guide.title;
722722
const def = includeDefault ? defaultTitle(fieldDef, config) : undefined;
723723

724724
if (allowDisabling) {
725725
return getFirstDefined(guideTitle, fieldDef.title, def);
726726
} else {
727-
return guideTitle || fieldDef.title || def;
727+
return guideTitle ?? fieldDef.title ?? def;
728728
}
729729
}
730730

@@ -747,7 +747,7 @@ export function format(fieldDef: TypedFieldDef<string>) {
747747
if (isTextFieldDef(fieldDef) && fieldDef.format) {
748748
return fieldDef.format;
749749
} else {
750-
const guide = getGuide(fieldDef) || {};
750+
const guide = getGuide(fieldDef) ?? {};
751751
return guide.format;
752752
}
753753
}

src/compile/axis/assemble.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ function setAxisEncode(
2727
vgProp: VgEncodeChannel,
2828
vgRef: VgValueRef | readonly VgValueRef[]
2929
) {
30-
axis.encode = axis.encode || {};
31-
axis.encode[part] = axis.encode[part] || {};
32-
axis.encode[part].update = axis.encode[part].update || {};
30+
axis.encode = axis.encode ?? {};
31+
axis.encode[part] = axis.encode[part] ?? {};
32+
axis.encode[part].update = axis.encode[part].update ?? {};
3333
// TODO: remove as any after https://github.com/prisma/nexus-prisma/issues/291
3434
(axis.encode[part].update[vgProp] as any) = vgRef;
3535
}

src/compile/axis/encode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {UnitModel} from '../unit';
77

88
export function labels(model: UnitModel, channel: PositionScaleChannel, specifiedLabelsSpec: any) {
99
const fieldDef =
10-
model.fieldDef(channel) ||
10+
model.fieldDef(channel) ??
1111
(channel === 'x' ? model.fieldDef('x2') : channel === 'y' ? model.fieldDef('y2') : undefined);
1212
const axis = model.axis(channel);
1313
const config = model.config;

src/compile/axis/parse.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export function parseLayerAxes(model: LayerModel) {
6969

7070
if (resolve.axis[channel] === 'independent') {
7171
// If axes are independent, concat the axisComponent array.
72-
axes[channel] = (axes[channel] || []).concat(child.component.axes[channel]);
72+
axes[channel] = (axes[channel] ?? []).concat(child.component.axes[channel]);
7373

7474
// Automatically adjust orient
7575
for (const axisComponent of child.component.axes[channel]) {
@@ -250,14 +250,14 @@ function parseAxis(channel: PositionScaleChannel, model: UnitModel): AxisCompone
250250
});
251251

252252
// 2) Add guide encode definition groups
253-
const axisEncoding = axis.encoding || {};
253+
const axisEncoding = axis.encoding ?? {};
254254
const axisEncode = AXIS_PARTS.reduce((e: VgAxisEncode, part) => {
255255
if (!axisComponent.hasAxisPart(part)) {
256256
// No need to create encode for a disabled part.
257257
return e;
258258
}
259259

260-
const axisEncodingPart = guideEncodeEntry(axisEncoding[part] || {}, model);
260+
const axisEncodingPart = guideEncodeEntry(axisEncoding[part] ?? {}, model);
261261

262262
const value = part === 'labels' ? encode.labels(model, channel, axisEncodingPart) : axisEncodingPart;
263263

src/compile/common.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function applyMarkConfig(e: VgEncodeEntry, model: UnitModel, propsList: (
3636
}
3737

3838
export function getStyles(mark: MarkDef): string[] {
39-
return [].concat(mark.type, mark.style || []);
39+
return [].concat(mark.type, mark.style ?? []);
4040
}
4141

4242
export function getMarkPropOrConfig<P extends keyof MarkConfig>(channel: P, mark: MarkDef, config: Config) {
@@ -142,7 +142,7 @@ function formatExpr(field: string, format: string) {
142142
}
143143

144144
export function numberFormatExpr(field: string, specifiedFormat: string, config: Config) {
145-
return formatExpr(field, specifiedFormat || config.numberFormat);
145+
return formatExpr(field, specifiedFormat ?? config.numberFormat);
146146
}
147147

148148
export function binFormatExpression(startField: string, endField: string, format: string, config: Config) {
@@ -167,7 +167,7 @@ export function timeFormatExpression(
167167
): string {
168168
if (!timeUnit || format) {
169169
// If there is not time unit, or if user explicitly specify format for axis/legend/text.
170-
format = format || rawTimeFormat; // only use provided timeFormat if there is no timeUnit.
170+
format = format ?? rawTimeFormat; // only use provided timeFormat if there is no timeUnit.
171171

172172
if (format || alwaysReturn) {
173173
return `${isUTCScale ? 'utc' : 'time'}Format(${field}, '${format}')`;
@@ -189,7 +189,7 @@ export function sortParams(
189189
return array(orderDef).reduce(
190190
(s, orderChannelDef) => {
191191
s.field.push(vgField(orderChannelDef, fieldRefOption));
192-
s.order.push(orderChannelDef.sort || 'ascending');
192+
s.order.push(orderChannelDef.sort ?? 'ascending');
193193
return s;
194194
},
195195
{field: [], order: []}

src/compile/data/aggregate.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function mergeMeasures(parentMeasures: Measures, childMeasures: Measures) {
4848
for (const op of keys(ops)) {
4949
if (field in parentMeasures) {
5050
// add operator to existing measure field
51-
parentMeasures[field][op] = new Set([...(parentMeasures[field][op] || []), ...ops[op]]);
51+
parentMeasures[field][op] = new Set([...(parentMeasures[field][op] ?? []), ...ops[op]]);
5252
} else {
5353
parentMeasures[field] = {[op]: ops[op]};
5454
}
@@ -93,22 +93,22 @@ export class AggregateNode extends DataFlowNode {
9393
const {aggregate, field} = fieldDef;
9494
if (aggregate) {
9595
if (aggregate === 'count') {
96-
meas['*'] = meas['*'] || {};
96+
meas['*'] = meas['*'] ?? {};
9797
meas['*']['count'] = new Set([vgField(fieldDef, {forAs: true})]);
9898
} else {
9999
if (isArgminDef(aggregate) || isArgmaxDef(aggregate)) {
100100
const op = isArgminDef(aggregate) ? 'argmin' : 'argmax';
101101
const argField = aggregate[op];
102-
meas[argField] = meas[argField] || {};
102+
meas[argField] = meas[argField] ?? {};
103103
meas[argField][op] = new Set([vgField({op, field: argField}, {forAs: true})]);
104104
} else {
105-
meas[field] = meas[field] || {};
105+
meas[field] = meas[field] ?? {};
106106
meas[field][aggregate] = new Set([vgField(fieldDef, {forAs: true})]);
107107
}
108108

109109
// For scale channel with domain === 'unaggregated', add min/max so we can use their union as unaggregated domain
110110
if (isScaleChannel(channel) && model.scaleDomain(channel) === 'unaggregated') {
111-
meas[field] = meas[field] || {};
111+
meas[field] = meas[field] ?? {};
112112
meas[field]['min'] = new Set([vgField({field, aggregate: 'min'}, {forAs: true})]);
113113
meas[field]['max'] = new Set([vgField({field, aggregate: 'max'}, {forAs: true})]);
114114
}
@@ -133,16 +133,16 @@ export class AggregateNode extends DataFlowNode {
133133
const {op, field, as} = s;
134134
if (op) {
135135
if (op === 'count') {
136-
meas['*'] = meas['*'] || {};
136+
meas['*'] = meas['*'] ?? {};
137137
meas['*']['count'] = new Set([as ? as : vgField(s, {forAs: true})]);
138138
} else {
139-
meas[field] = meas[field] || {};
139+
meas[field] = meas[field] ?? {};
140140
meas[field][op] = new Set([as ? as : vgField(s, {forAs: true})]);
141141
}
142142
}
143143
}
144144

145-
for (const s of t.groupby || []) {
145+
for (const s of t.groupby ?? []) {
146146
dims.add(s);
147147
}
148148

src/compile/data/assemble.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function makeWalkTree(data: VgData[]) {
5757
if (node.parent instanceof SourceNode && !dataSource.source) {
5858
// If node's parent is a root source and the data source does not refer to another data source, use normal format parse
5959
dataSource.format = {
60-
...(dataSource.format || {}),
60+
...(dataSource.format ?? {}),
6161
parse: node.assembleFormatParse()
6262
};
6363

@@ -245,14 +245,14 @@ export function assembleRootData(dataComponent: DataComponent, datasets: Dict<In
245245
// move sources without transforms (the ones that are potentially used in lookups) to the beginning
246246
let whereTo = 0;
247247
for (const [i, d] of data.entries()) {
248-
if ((d.transform || []).length === 0 && !d.source) {
248+
if ((d.transform ?? []).length === 0 && !d.source) {
249249
data.splice(whereTo++, 0, data.splice(i, 1)[0]);
250250
}
251251
}
252252

253253
// now fix the from references in lookup transforms
254254
for (const d of data) {
255-
for (const t of d.transform || []) {
255+
for (const t of d.transform ?? []) {
256256
if (t.type === 'lookup') {
257257
t.from = dataComponent.outputNodes[t.from].getSource();
258258
}

src/compile/data/bin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function rangeFormula(model: ModelWithField, fieldDef: TypedFieldDef<string>, ch
1515
if (binRequiresRange(fieldDef, channel)) {
1616
// read format from axis or legend, if there is no format then use config.numberFormat
1717

18-
const guide = isUnitModel(model) ? model.axis(channel) || model.legend(channel) || {} : {};
18+
const guide = isUnitModel(model) ? model.axis(channel) ?? model.legend(channel) ?? {} : {};
1919

2020
const startField = vgField(fieldDef, {expr: 'datum'});
2121
const endField = vgField(fieldDef, {expr: 'datum', binSuffix: 'end'});
@@ -40,7 +40,7 @@ function getSignalsFromModel(model: Model, key: string) {
4040
}
4141

4242
export function getBinSignalName(model: Model, field: string, bin: boolean | BinParams) {
43-
const normalizedBin = normalizeBin(bin, undefined) || {};
43+
const normalizedBin = normalizeBin(bin, undefined) ?? {};
4444
const key = binKey(normalizedBin, field);
4545
return model.getName(`${key}_bins`);
4646
}

src/compile/data/calculate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@ export class CalculateNode extends DataFlowNode {
7171
}
7272

7373
export function sortArrayIndexField(fieldDef: TypedFieldDef<string>, channel: SingleDefChannel, opt?: FieldRefOption) {
74-
return vgField(fieldDef, {prefix: channel, suffix: 'sort_index', ...(opt || {})});
74+
return vgField(fieldDef, {prefix: channel, suffix: 'sort_index', ...(opt ?? {})});
7575
}

0 commit comments

Comments
 (0)