vendor/assets/javascripts/vega-lite.js in vega-0.2.7 vs vendor/assets/javascripts/vega-lite.js in vega-0.3.0

- old
+ new

@@ -4,11 +4,11 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.vegaLite = {}, global.vega)); })(this, (function (exports, vega) { 'use strict'; var name = "vega-lite"; var author = "Dominik Moritz, Kanit \"Ham\" Wongsuphasawat, Arvind Satyanarayan, Jeffrey Heer"; - var version$1 = "5.2.0"; + var version$1 = "5.5.0"; var collaborators = [ "Kanit Wongsuphasawat (http://kanitw.yellowpigz.com)", "Dominik Moritz (https://www.domoritz.de)", "Arvind Satyanarayan (https://arvindsatya.com)", "Jeffrey Heer (https://jheer.org)" @@ -86,74 +86,73 @@ var license = "BSD-3-Clause"; var bugs = { url: "https://github.com/vega/vega-lite/issues" }; var devDependencies = { - "@auto-it/conventional-commits": "^10.34.1", - "@auto-it/first-time-contributor": "^10.34.1", - "@babel/core": "^7.17.5", - "@babel/preset-env": "^7.16.11", - "@babel/preset-typescript": "^7.16.7", - "@rollup/plugin-alias": "^3.1.9", - "@rollup/plugin-babel": "^5.3.1", - "@rollup/plugin-commonjs": "^22.0.0", + "@auto-it/conventional-commits": "^10.37.6", + "@auto-it/first-time-contributor": "^10.37.6", + "@babel/core": "^7.19.1", + "@babel/preset-env": "^7.19.1", + "@babel/preset-typescript": "^7.18.6", + "@rollup/plugin-alias": "^4.0.0", + "@rollup/plugin-babel": "^6.0.0", + "@rollup/plugin-commonjs": "^23.0.0", "@rollup/plugin-json": "^4.1.0", - "@rollup/plugin-node-resolve": "^13.1.3", - "@types/chai": "^4.3.0", - "@types/d3": "^7.1.0", "@types/jest": "^27.4.1", + "@rollup/plugin-node-resolve": "^14.1.0", + "@types/chai": "^4.3.3", + "@types/d3": "^7.4.0", "@types/mkdirp": "^1.0.2", "@types/pako": "^2.0.0", - "@typescript-eslint/eslint-plugin": "^5.14.0", - "@typescript-eslint/parser": "^5.14.0", - ajv: "^8.10.0", + "@typescript-eslint/eslint-plugin": "^5.38.0", + "@typescript-eslint/parser": "^5.38.0", + ajv: "^8.11.0", "ajv-formats": "^2.1.1", - auto: "^10.34.1", + auto: "^10.37.6", chai: "^4.3.6", - cheerio: "^1.0.0-rc.10", + cheerio: "^1.0.0-rc.12", "conventional-changelog-cli": "^2.2.2", - d3: "^7.4.4", + d3: "^7.6.1", "del-cli": "^5.0.0", - eslint: "^8.11.0", + eslint: "^8.23.1", "eslint-config-prettier": "^8.5.0", - "eslint-plugin-jest": "^26.1.1", - "eslint-plugin-prettier": "^4.0.0", + "eslint-plugin-jest": "^27.0.4", + "eslint-plugin-prettier": "^4.2.1", "gh-pages": "^4.0.0", - "highlight.js": "^11.5.0", jest: "^27.5.1", - "jest-dev-server": "^6.0.3", + "highlight.js": "^11.6.0", + "jest-dev-server": "^6.1.1", mkdirp: "^1.0.4", pako: "^2.0.4", - prettier: "^2.5.1", + prettier: "^2.7.1", puppeteer: "^15.0.0", - rollup: "^2.70.1", + rollup: "^2.79.1", "rollup-plugin-bundle-size": "^1.0.3", "rollup-plugin-sourcemaps": "^0.6.3", "rollup-plugin-terser": "^7.0.2", serve: "^14.0.1", - terser: "^5.12.1", - "ts-jest": "^27.1.3", - "ts-json-schema-generator": "^1.0.0", - "vega-cli": "^5.22.0", - typescript: "~4.7.2", - "vega-datasets": "~2.4.0", - "vega-embed": "^6.20.8", + terser: "^5.15.0", + "ts-jest": "^29.0.1", + "ts-json-schema-generator": "^1.1.1", + "vega-cli": "^5.22.1", + typescript: "~4.8.3", + "vega-datasets": "~2.5.1", + "vega-embed": "^6.21.0", "vega-tooltip": "^0.28.0", "yaml-front-matter": "^4.1.1" }; var dependencies = { "@types/clone": "~2.1.1", - "array-flat-polyfill": "^1.0.1", clone: "~2.1.2", "fast-deep-equal": "~3.1.3", "fast-json-stable-stringify": "~2.1.0", "json-stringify-pretty-compact": "~3.0.0", tslib: "~2.4.0", "vega-event-selector": "~3.0.0", "vega-expression": "~5.0.0", "vega-util": "~1.17.0", - yargs: "~17.5.1" + yargs: "~17.6.0" }; var peerDependencies = { vega: "^5.22.0" }; var engines = { @@ -182,12 +181,10 @@ dependencies: dependencies, peerDependencies: peerDependencies, engines: engines }; - Array.prototype.flat||Object.defineProperty(Array.prototype,"flat",{configurable:!0,value:function r(){var t=isNaN(arguments[0])?1:Number(arguments[0]);return t?Array.prototype.reduce.call(this,function(a,e){return Array.isArray(e)?a.push.apply(a,r.call(e,t-1)):a.push(e),a},[]):Array.prototype.slice.call(this)},writable:!0}),Array.prototype.flatMap||Object.defineProperty(Array.prototype,"flatMap",{configurable:!0,value:function(r){return Array.prototype.map.apply(this,arguments).flat()},writable:!0}); - var clone = {exports: {}}; (function (module) { var clone = function () { @@ -655,11 +652,11 @@ /** * Monkey patch Set so that `stringify` produces a string representation of sets. */ Set.prototype['toJSON'] = function () { - return "Set(".concat([...this].map(x => fastJsonStableStringify(x)).join(','), ")"); + return `Set(${[...this].map(x => fastJsonStableStringify(x)).join(',')})`; }; /** * Converts any object to a string representation that can be consumed by humans. */ @@ -738,11 +735,11 @@ for (var _len = arguments.length, src = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { src[_key - 1] = arguments[_key]; } for (const s of src) { - deepMerge_(dest, s !== null && s !== void 0 ? s : {}); + deepMerge_(dest, s ?? {}); } return dest; } @@ -816,11 +813,11 @@ const prefixes = new Set(); for (const x of a) { const splitField = vega.splitAccessPath(x); // Wrap every element other than the first in `[]` - const wrappedWithAccessors = splitField.map((y, i) => i === 0 ? y : "[".concat(y, "]")); + const wrappedWithAccessors = splitField.map((y, i) => i === 0 ? y : `[${y}]`); const computedPrefixes = wrappedWithAccessors.map((_, i) => wrappedWithAccessors.slice(0, i + 1).join('')); for (const y of computedPrefixes) { prefixes.add(y); } @@ -863,15 +860,15 @@ return (s.match(/^\d+/) ? '_' : '') + alphanumericS; } function logicalExpr(op, cb) { if (isLogicalNot(op)) { - return "!(".concat(logicalExpr(op.not, cb), ")"); + return `!(${logicalExpr(op.not, cb)})`; } else if (isLogicalAnd(op)) { - return "(".concat(op.and.map(and => logicalExpr(and, cb)).join(') && ('), ")"); + return `(${op.and.map(and => logicalExpr(and, cb)).join(') && (')})`; } else if (isLogicalOr(op)) { - return "(".concat(op.or.map(or => logicalExpr(or, cb)).join(') || ('), ")"); + return `(${op.or.map(or => logicalExpr(or, cb)).join(') || (')})`; } else { return cb(op); } } /** @@ -904,12 +901,12 @@ let datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'datum'; const pieces = vega.splitAccessPath(path); const prefixes = []; for (let i = 1; i <= pieces.length; i++) { - const prefix = "[".concat(pieces.slice(0, i).map(vega.stringValue).join(']['), "]"); - prefixes.push("".concat(datum).concat(prefix)); + const prefix = `[${pieces.slice(0, i).map(vega.stringValue).join('][')}]`; + prefixes.push(`${datum}${prefix}`); } return prefixes.join(' && '); } /** @@ -919,11 +916,11 @@ * @param datum The string to use for `datum`. */ function flatAccessWithDatum(path) { let datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'datum'; - return "".concat(datum, "[").concat(vega.stringValue(vega.splitAccessPath(path).join('.')), "]"); + return `${datum}[${vega.stringValue(vega.splitAccessPath(path).join('.'))}]`; } function escapePathAccess(string) { return string.replace(/(\[|\]|\.|'|")/g, '\\$1'); } @@ -932,11 +929,11 @@ * For example, `foo["bar"].baz` becomes `foo\\.bar\\.baz`. */ function replacePathInField(path) { - return "".concat(vega.splitAccessPath(path).map(escapePathAccess).join('\\.')); + return `${vega.splitAccessPath(path).map(escapePathAccess).join('\\.')}`; } /** * Replace all occurrences of a string with another string. * * @param string the string to replace in @@ -951,11 +948,11 @@ * Remove path accesses with access from field. * For example, `foo["bar"].baz` becomes `foo.bar.baz`. */ function removePathFromField(path) { - return "".concat(vega.splitAccessPath(path).join('.')); + return `${vega.splitAccessPath(path).join('.')}`; } /** * Count the depth of the path. Returns 1 for fields that are not nested. */ @@ -1001,11 +998,11 @@ function resetIdCounter() { idCounter = 42; } function internalField(name) { - return isInternalField(name) ? name : "__".concat(name); + return isInternalField(name) ? name : `__${name}`; } function isInternalField(name) { return name.startsWith('__'); } /** @@ -1695,11 +1692,11 @@ function binToString(bin) { if (vega.isBoolean(bin)) { bin = normalizeBin(bin, undefined); } - return 'bin' + keys(bin).map(p => isParameterExtent(bin[p]) ? varName("_".concat(p, "_").concat(entries$1(bin[p]))) : varName("_".concat(p, "_").concat(bin[p]))).join(''); + return 'bin' + keys(bin).map(p => isParameterExtent(bin[p]) ? varName(`_${p}_${entries$1(bin[p])}`) : varName(`_${p}_${bin[p]}`)).join(''); } /** * Vega-Lite should bin the data. */ @@ -2041,13 +2038,11 @@ } return e; } function getStyles(mark) { - var _mark$style; - - return [].concat(mark.type, (_mark$style = mark.style) !== null && _mark$style !== void 0 ? _mark$style : []); + return [].concat(mark.type, mark.style ?? []); } function getMarkPropOrConfig(channel, mark, config) { let opt = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; const { vgChannel, @@ -2102,14 +2097,12 @@ * Return Vega sort parameters (tuple of field and order). */ function sortParams(orderDef, fieldRefOption) { return vega.array(orderDef).reduce((s, orderChannelDef) => { - var _orderChannelDef$sort; - s.field.push(vgField(orderChannelDef, fieldRefOption)); - s.order.push((_orderChannelDef$sort = orderChannelDef.sort) !== null && _orderChannelDef$sort !== void 0 ? _orderChannelDef$sort : 'ascending'); + s.order.push(orderChannelDef.sort ?? 'ascending'); return s; }, { field: [], order: [] }); @@ -2246,238 +2239,238 @@ /** * Collection of all Vega-Lite Error Messages */ function invalidSpec(spec) { - return "Invalid specification ".concat(stringify(spec), ". Make sure the specification includes at least one of the following properties: \"mark\", \"layer\", \"facet\", \"hconcat\", \"vconcat\", \"concat\", or \"repeat\"."); + return `Invalid specification ${stringify(spec)}. Make sure the specification includes at least one of the following properties: "mark", "layer", "facet", "hconcat", "vconcat", "concat", or "repeat".`; } // FIT const FIT_NON_SINGLE = 'Autosize "fit" only works for single views and layered views.'; function containerSizeNonSingle(name) { const uName = name == 'width' ? 'Width' : 'Height'; - return "".concat(uName, " \"container\" only works for single views and layered views."); + return `${uName} "container" only works for single views and layered views.`; } function containerSizeNotCompatibleWithAutosize(name) { const uName = name == 'width' ? 'Width' : 'Height'; const fitDirection = name == 'width' ? 'x' : 'y'; - return "".concat(uName, " \"container\" only works well with autosize \"fit\" or \"fit-").concat(fitDirection, "\"."); + return `${uName} "container" only works well with autosize "fit" or "fit-${fitDirection}".`; } function droppingFit(channel) { - return channel ? "Dropping \"fit-".concat(channel, "\" because spec has discrete ").concat(getSizeChannel(channel), ".") : "Dropping \"fit\" because spec has discrete size."; + return channel ? `Dropping "fit-${channel}" because spec has discrete ${getSizeChannel(channel)}.` : `Dropping "fit" because spec has discrete size.`; } // VIEW SIZE function unknownField(channel) { - return "Unknown field for ".concat(channel, ". Cannot calculate view size."); + return `Unknown field for ${channel}. Cannot calculate view size.`; } // SELECTION function cannotProjectOnChannelWithoutField(channel) { - return "Cannot project a selection on encoding channel \"".concat(channel, "\", which has no field."); + return `Cannot project a selection on encoding channel "${channel}", which has no field.`; } function cannotProjectAggregate(channel, aggregate) { - return "Cannot project a selection on encoding channel \"".concat(channel, "\" as it uses an aggregate function (\"").concat(aggregate, "\")."); + return `Cannot project a selection on encoding channel "${channel}" as it uses an aggregate function ("${aggregate}").`; } function nearestNotSupportForContinuous(mark) { - return "The \"nearest\" transform is not supported for ".concat(mark, " marks."); + return `The "nearest" transform is not supported for ${mark} marks.`; } function selectionNotSupported(mark) { - return "Selection not supported for ".concat(mark, " yet."); + return `Selection not supported for ${mark} yet.`; } function selectionNotFound(name) { - return "Cannot find a selection named \"".concat(name, "\"."); + return `Cannot find a selection named "${name}".`; } const SCALE_BINDINGS_CONTINUOUS = 'Scale bindings are currently only supported for scales with unbinned, continuous domains.'; const LEGEND_BINDINGS_MUST_HAVE_PROJECTION = 'Legend bindings are only supported for selections over an individual field or encoding channel.'; function cannotLookupVariableParameter(name) { - return "Lookups can only be performed on selection parameters. \"".concat(name, "\" is a variable parameter."); + return `Lookups can only be performed on selection parameters. "${name}" is a variable parameter.`; } function noSameUnitLookup(name) { - return "Cannot define and lookup the \"".concat(name, "\" selection in the same view. ") + "Try moving the lookup into a second, layered view?"; + return `Cannot define and lookup the "${name}" selection in the same view. ` + `Try moving the lookup into a second, layered view?`; } const NEEDS_SAME_SELECTION = 'The same selection must be used to override scale domains in a layered view.'; const INTERVAL_INITIALIZED_WITH_X_Y = 'Interval selections should be initialized using "x" and/or "y" keys.'; // REPEAT function noSuchRepeatedValue(field) { - return "Unknown repeated value \"".concat(field, "\"."); + return `Unknown repeated value "${field}".`; } function columnsNotSupportByRowCol(type) { - return "The \"columns\" property cannot be used when \"".concat(type, "\" has nested row/column."); + return `The "columns" property cannot be used when "${type}" has nested row/column.`; } // CONCAT / REPEAT const CONCAT_CANNOT_SHARE_AXIS = 'Axes cannot be shared in concatenated or repeated views yet (https://github.com/vega/vega-lite/issues/2415).'; // DATA function unrecognizedParse(p) { - return "Unrecognized parse \"".concat(p, "\"."); + return `Unrecognized parse "${p}".`; } function differentParse(field, local, ancestor) { - return "An ancestor parsed field \"".concat(field, "\" as ").concat(ancestor, " but a child wants to parse the field as ").concat(local, "."); + return `An ancestor parsed field "${field}" as ${ancestor} but a child wants to parse the field as ${local}.`; } const ADD_SAME_CHILD_TWICE = 'Attempt to add the same child twice.'; // TRANSFORMS function invalidTransformIgnored(transform) { - return "Ignoring an invalid transform: ".concat(stringify(transform), "."); + return `Ignoring an invalid transform: ${stringify(transform)}.`; } const NO_FIELDS_NEEDS_AS = 'If "from.fields" is not specified, "as" has to be a string that specifies the key to be used for the data from the secondary source.'; // ENCODING & FACET function customFormatTypeNotAllowed(channel) { - return "Config.customFormatTypes is not true, thus custom format type and format for channel ".concat(channel, " are dropped."); + return `Config.customFormatTypes is not true, thus custom format type and format for channel ${channel} are dropped.`; } function projectionOverridden(opt) { const { parentProjection, projection } = opt; - return "Layer's shared projection ".concat(stringify(parentProjection), " is overridden by a child projection ").concat(stringify(projection), "."); + return `Layer's shared projection ${stringify(parentProjection)} is overridden by a child projection ${stringify(projection)}.`; } const REPLACE_ANGLE_WITH_THETA = 'Arc marks uses theta channel rather than angle, replacing angle with theta.'; function offsetNestedInsideContinuousPositionScaleDropped(mainChannel) { - return "".concat(mainChannel, "Offset dropped because ").concat(mainChannel, " is continuous"); + return `${mainChannel}Offset dropped because ${mainChannel} is continuous`; } function replaceOffsetWithMainChannel(mainChannel) { - return "There is no ".concat(mainChannel, " encoding. Replacing ").concat(mainChannel, "Offset encoding as ").concat(mainChannel, "."); + return `There is no ${mainChannel} encoding. Replacing ${mainChannel}Offset encoding as ${mainChannel}.`; } function primitiveChannelDef(channel, type, value) { - return "Channel ".concat(channel, " is a ").concat(type, ". Converted to {value: ").concat(stringify(value), "}."); + return `Channel ${channel} is a ${type}. Converted to {value: ${stringify(value)}}.`; } function invalidFieldType(type) { - return "Invalid field type \"".concat(type, "\"."); + return `Invalid field type "${type}".`; } function invalidFieldTypeForCountAggregate(type, aggregate) { - return "Invalid field type \"".concat(type, "\" for aggregate: \"").concat(aggregate, "\", using \"quantitative\" instead."); + return `Invalid field type "${type}" for aggregate: "${aggregate}", using "quantitative" instead.`; } function invalidAggregate(aggregate) { - return "Invalid aggregation operator \"".concat(aggregate, "\"."); + return `Invalid aggregation operator "${aggregate}".`; } function droppingColor(type, opt) { const { fill, stroke } = opt; - return "Dropping color ".concat(type, " as the plot also has ").concat(fill && stroke ? 'fill and stroke' : fill ? 'fill' : 'stroke', "."); + return `Dropping color ${type} as the plot also has ${fill && stroke ? 'fill and stroke' : fill ? 'fill' : 'stroke'}.`; } function relativeBandSizeNotSupported(sizeChannel) { - return "Position range does not support relative band size for ".concat(sizeChannel, "."); + return `Position range does not support relative band size for ${sizeChannel}.`; } function emptyFieldDef(fieldDef, channel) { - return "Dropping ".concat(stringify(fieldDef), " from channel \"").concat(channel, "\" since it does not contain any data field, datum, value, or signal."); + return `Dropping ${stringify(fieldDef)} from channel "${channel}" since it does not contain any data field, datum, value, or signal.`; } const LINE_WITH_VARYING_SIZE = 'Line marks cannot encode size with a non-groupby field. You may want to use trail marks instead.'; function incompatibleChannel(channel, markOrFacet, when) { - return "".concat(channel, " dropped as it is incompatible with \"").concat(markOrFacet, "\"").concat(when ? " when ".concat(when) : '', "."); + return `${channel} dropped as it is incompatible with "${markOrFacet}"${when ? ` when ${when}` : ''}.`; } function offsetEncodingScaleIgnored(channel) { - return "".concat(channel, " encoding has no scale, so specified scale is ignored."); + return `${channel} encoding has no scale, so specified scale is ignored.`; } function invalidEncodingChannel(channel) { - return "".concat(channel, "-encoding is dropped as ").concat(channel, " is not a valid encoding channel."); + return `${channel}-encoding is dropped as ${channel} is not a valid encoding channel.`; } function channelShouldBeDiscrete(channel) { - return "".concat(channel, " encoding should be discrete (ordinal / nominal / binned)."); + return `${channel} encoding should be discrete (ordinal / nominal / binned).`; } function channelShouldBeDiscreteOrDiscretizing(channel) { - return "".concat(channel, " encoding should be discrete (ordinal / nominal / binned) or use a discretizing scale (e.g. threshold)."); + return `${channel} encoding should be discrete (ordinal / nominal / binned) or use a discretizing scale (e.g. threshold).`; } function facetChannelDropped(channels) { - return "Facet encoding dropped as ".concat(channels.join(' and '), " ").concat(channels.length > 1 ? 'are' : 'is', " also specified."); + return `Facet encoding dropped as ${channels.join(' and ')} ${channels.length > 1 ? 'are' : 'is'} also specified.`; } function discreteChannelCannotEncode(channel, type) { - return "Using discrete channel \"".concat(channel, "\" to encode \"").concat(type, "\" field can be misleading as it does not encode ").concat(type === 'ordinal' ? 'order' : 'magnitude', "."); + return `Using discrete channel "${channel}" to encode "${type}" field can be misleading as it does not encode ${type === 'ordinal' ? 'order' : 'magnitude'}.`; } // MARK function rangeMarkAlignmentCannotBeExpression(align) { - return "The ".concat(align, " for range marks cannot be an expression"); + return `The ${align} for range marks cannot be an expression`; } function lineWithRange(hasX2, hasY2) { const channels = hasX2 && hasY2 ? 'x2 and y2' : hasX2 ? 'x2' : 'y2'; - return "Line mark is for continuous lines and thus cannot be used with ".concat(channels, ". We will use the rule mark (line segments) instead."); + return `Line mark is for continuous lines and thus cannot be used with ${channels}. We will use the rule mark (line segments) instead.`; } function orientOverridden(original, actual) { - return "Specified orient \"".concat(original, "\" overridden with \"").concat(actual, "\"."); + return `Specified orient "${original}" overridden with "${actual}".`; } // SCALE function cannotUseScalePropertyWithNonColor(prop) { - return "Cannot use the scale property \"".concat(prop, "\" with non-color channel."); + return `Cannot use the scale property "${prop}" with non-color channel.`; } function cannotUseRelativeBandSizeWithNonBandScale(scaleType) { - return "Cannot use the relative band size with ".concat(scaleType, " scale."); + return `Cannot use the relative band size with ${scaleType} scale.`; } function unaggregateDomainHasNoEffectForRawField(fieldDef) { - return "Using unaggregated domain with raw field has no effect (".concat(stringify(fieldDef), ")."); + return `Using unaggregated domain with raw field has no effect (${stringify(fieldDef)}).`; } function unaggregateDomainWithNonSharedDomainOp(aggregate) { - return "Unaggregated domain not applicable for \"".concat(aggregate, "\" since it produces values outside the origin domain of the source data."); + return `Unaggregated domain not applicable for "${aggregate}" since it produces values outside the origin domain of the source data.`; } function unaggregatedDomainWithLogScale(fieldDef) { - return "Unaggregated domain is currently unsupported for log scale (".concat(stringify(fieldDef), ")."); + return `Unaggregated domain is currently unsupported for log scale (${stringify(fieldDef)}).`; } function cannotApplySizeToNonOrientedMark(mark) { - return "Cannot apply size to non-oriented mark \"".concat(mark, "\"."); + return `Cannot apply size to non-oriented mark "${mark}".`; } function scaleTypeNotWorkWithChannel(channel, scaleType, defaultScaleType) { - return "Channel \"".concat(channel, "\" does not work with \"").concat(scaleType, "\" scale. We are using \"").concat(defaultScaleType, "\" scale instead."); + return `Channel "${channel}" does not work with "${scaleType}" scale. We are using "${defaultScaleType}" scale instead.`; } function scaleTypeNotWorkWithFieldDef(scaleType, defaultScaleType) { - return "FieldDef does not work with \"".concat(scaleType, "\" scale. We are using \"").concat(defaultScaleType, "\" scale instead."); + return `FieldDef does not work with "${scaleType}" scale. We are using "${defaultScaleType}" scale instead.`; } function scalePropertyNotWorkWithScaleType(scaleType, propName, channel) { - return "".concat(channel, "-scale's \"").concat(propName, "\" is dropped as it does not work with ").concat(scaleType, " scale."); + return `${channel}-scale's "${propName}" is dropped as it does not work with ${scaleType} scale.`; } function stepDropped(channel) { - return "The step for \"".concat(channel, "\" is dropped because the ").concat(channel === 'width' ? 'x' : 'y', " is continuous."); + return `The step for "${channel}" is dropped because the ${channel === 'width' ? 'x' : 'y'} is continuous.`; } function mergeConflictingProperty(property, propertyOf, v1, v2) { - return "Conflicting ".concat(propertyOf.toString(), " property \"").concat(property.toString(), "\" (").concat(stringify(v1), " and ").concat(stringify(v2), "). Using ").concat(stringify(v1), "."); + return `Conflicting ${propertyOf.toString()} property "${property.toString()}" (${stringify(v1)} and ${stringify(v2)}). Using ${stringify(v1)}.`; } function mergeConflictingDomainProperty(property, propertyOf, v1, v2) { - return "Conflicting ".concat(propertyOf.toString(), " property \"").concat(property.toString(), "\" (").concat(stringify(v1), " and ").concat(stringify(v2), "). Using the union of the two domains."); + return `Conflicting ${propertyOf.toString()} property "${property.toString()}" (${stringify(v1)} and ${stringify(v2)}). Using the union of the two domains.`; } function independentScaleMeansIndependentGuide(channel) { - return "Setting the scale to be independent for \"".concat(channel, "\" means we also have to set the guide (axis or legend) to be independent."); + return `Setting the scale to be independent for "${channel}" means we also have to set the guide (axis or legend) to be independent.`; } function domainSortDropped(sort) { - return "Dropping sort property ".concat(stringify(sort), " as unioned domains only support boolean or op \"count\", \"min\", and \"max\"."); + return `Dropping sort property ${stringify(sort)} as unioned domains only support boolean or op "count", "min", and "max".`; } const MORE_THAN_ONE_SORT = 'Domains that should be unioned has conflicting sort properties. Sort will be set to true.'; const FACETED_INDEPENDENT_DIFFERENT_SOURCES = 'Detected faceted independent scales that union domain of multiple fields from different data sources. We will use the first field. The result view size may be incorrect.'; const FACETED_INDEPENDENT_SAME_FIELDS_DIFFERENT_SOURCES = 'Detected faceted independent scales that union domain of the same fields from different source. We will assume that this is the same field from a different fork of the same data source. However, if this is not the case, the result view size may be incorrect.'; const FACETED_INDEPENDENT_SAME_SOURCE = 'Detected faceted independent scales that union domain of multiple fields from the same data source. We will use the first field. The result view size may be incorrect.'; // AXIS function cannotStackRangedMark(channel) { - return "Cannot stack \"".concat(channel, "\" if there is already \"").concat(channel, "2\"."); + return `Cannot stack "${channel}" if there is already "${channel}2".`; } function cannotStackNonLinearScale(scaleType) { - return "Cannot stack non-linear scale (".concat(scaleType, ")."); + return `Cannot stack non-linear scale (${scaleType}).`; } function stackNonSummativeAggregate(aggregate) { - return "Stacking is applied even though the aggregate function is non-summative (\"".concat(aggregate, "\")."); + return `Stacking is applied even though the aggregate function is non-summative ("${aggregate}").`; } // TIMEUNIT function invalidTimeUnit(unitName, value) { - return "Invalid ".concat(unitName, ": ").concat(stringify(value), "."); + return `Invalid ${unitName}: ${stringify(value)}.`; } function droppedDay(d) { - return "Dropping day from datetime ".concat(stringify(d), " as day cannot be combined with other units."); + return `Dropping day from datetime ${stringify(d)} as day cannot be combined with other units.`; } function errorBarCenterAndExtentAreNotNeeded(center, extent) { - return "".concat(extent ? 'extent ' : '').concat(extent && center ? 'and ' : '').concat(center ? 'center ' : '').concat(extent && center ? 'are ' : 'is ', "not needed when data are aggregated."); + return `${extent ? 'extent ' : ''}${extent && center ? 'and ' : ''}${center ? 'center ' : ''}${extent && center ? 'are ' : 'is '}not needed when data are aggregated.`; } function errorBarCenterIsUsedWithWrongExtent(center, extent, mark) { - return "".concat(center, " is not usually used with ").concat(extent, " for ").concat(mark, "."); + return `${center} is not usually used with ${extent} for ${mark}.`; } function errorBarContinuousAxisHasCustomizedAggregate(aggregate, compositeMark) { - return "Continuous axis should not have customized aggregation function ".concat(aggregate, "; ").concat(compositeMark, " already agregates the axis."); + return `Continuous axis should not have customized aggregation function ${aggregate}; ${compositeMark} already agregates the axis.`; } function errorBand1DNotSupport(property) { - return "1D error band does not support ".concat(property, "."); + return `1D error band does not support ${property}.`; } // CHANNEL function channelRequiredForBinned(channel) { - return "Channel ".concat(channel, " is required for \"binned\" bin."); + return `Channel ${channel} is required for "binned" bin.`; } function channelShouldNotBeUsedForBinned(channel) { - return "Channel ".concat(channel, " should not be used with \"binned\" bin."); + return `Channel ${channel} should not be used with "binned" bin.`; } function domainRequiredForThresholdScale(channel) { - return "Domain for ".concat(channel, " is required for threshold scale."); + return `Domain for ${channel} is required for threshold scale.`; } /** * Main (default) Vega Logger instance for Vega-Lite. */ @@ -2633,22 +2626,22 @@ if (d.month !== undefined) { const month = normalize ? normalizeMonth(d.month) : d.month; parts.push(month); } else if (d.quarter !== undefined) { const quarter = normalize ? normalizeQuarter(d.quarter) : d.quarter; - parts.push(vega.isNumber(quarter) ? quarter * 3 : "".concat(quarter, "*3")); + parts.push(vega.isNumber(quarter) ? quarter * 3 : `${quarter}*3`); } else { parts.push(0); // months start at zero in JS } if (d.date !== undefined) { parts.push(d.date); } else if (d.day !== undefined) { // HACK: Day only works as a standalone unit // This is only correct because we always set year to 2006 for day const day = normalize ? normalizeDay(d.day) : d.day; - parts.push(vega.isNumber(day) ? day + 1 : "".concat(day, "+1")); + parts.push(vega.isNumber(day) ? day + 1 : `${day}+1`); } else { parts.push(1); // Date starts at 1 in JS } // Note: can't use TimeUnit enum here as importing it will create // circular dependency problem! @@ -2671,13 +2664,13 @@ function dateTimeToExpr(d) { const parts = dateTimeParts(d, true); const string = parts.join(', '); if (d.utc) { - return "utc(".concat(string, ")"); + return `utc(${string})`; } else { - return "datetime(".concat(string, ")"); + return `datetime(${string})`; } } /** * Return Vega expression for a date time expression. * @@ -2688,13 +2681,13 @@ function dateTimeExprToExpr(d) { const parts = dateTimeParts(d, false); const string = parts.join(', '); if (d.utc) { - return "utc(".concat(string, ")"); + return `utc(${string})`; } else { - return "datetime(".concat(string, ")"); + return `datetime(${string})`; } } /** * @param d the date time. * @returns the timestamp. @@ -2782,13 +2775,13 @@ const utc = isUTCTimeUnit(fullTimeUnit) ? 'utc' : ''; function func(timeUnit) { if (timeUnit === 'quarter') { // quarter starting at 0 (0,3,6,9). - return "(".concat(utc, "quarter(").concat(fieldRef, ")-1)"); + return `(${utc}quarter(${fieldRef})-1)`; } else { - return "".concat(utc).concat(timeUnit, "(").concat(fieldRef, ")"); + return `${utc}${timeUnit}(${fieldRef})`; } } let lastTimeUnit; const dateExpr = {}; @@ -2810,11 +2803,11 @@ if (!timeUnit) { return undefined; } const timeUnitParts = getTimeUnitParts(timeUnit); - return "timeUnitSpecifier(".concat(stringify(timeUnitParts), ", ").concat(stringify(VEGALITE_TIMEFORMAT), ")"); + return `timeUnitSpecifier(${stringify(timeUnitParts)}, ${stringify(VEGALITE_TIMEFORMAT)})`; } /** * Returns the signal expression used for axis labels for a time unit. */ @@ -2826,11 +2819,11 @@ const expr = timeUnitSpecifierExpression(timeUnit); // We only use utcFormat for utc scale // For utc time units, the data is already converted as a part of timeUnit transform. // Thus, utc time units should use timeFormat to avoid shifting the time twice. const utc = isUTCScale || isUTCTimeUnit(timeUnit); - return "".concat(utc ? 'utc' : 'time', "Format(").concat(field, ", ").concat(expr, ")"); + return `${utc ? 'utc' : 'time'}Format(${field}, ${expr})`; } function normalizeTimeUnit(timeUnit) { if (!timeUnit) { return undefined; } @@ -2861,14 +2854,14 @@ utc, ...rest } = normalizeTimeUnit(tu); if (rest.unit) { - return (utc ? 'utc' : '') + keys(rest).map(p => varName("".concat(p === 'unit' ? '' : "_".concat(p, "_")).concat(rest[p]))).join(''); + return (utc ? 'utc' : '') + keys(rest).map(p => varName(`${p === 'unit' ? '' : `_${p}_`}${rest[p]}`)).join(''); } else { // when maxbins is specified instead of units - return (utc ? 'utc' : '') + 'timeunit' + keys(rest).map(p => varName("_".concat(p, "_").concat(rest[p]))).join(''); + return (utc ? 'utc' : '') + 'timeunit' + keys(rest).map(p => varName(`_${p}_${rest[p]}`)).join(''); } } function isSelectionPredicate(predicate) { return predicate === null || predicate === void 0 ? void 0 : predicate['param']; @@ -2931,71 +2924,71 @@ } = predicate; const timeUnit = (_normalizeTimeUnit = normalizeTimeUnit(predicate.timeUnit)) === null || _normalizeTimeUnit === void 0 ? void 0 : _normalizeTimeUnit.unit; const fieldExpr$1 = timeUnit ? // For timeUnit, cast into integer with time() so we can use ===, inrange, indexOf to compare values directly. // TODO: We calculate timeUnit on the fly here. Consider if we would like to consolidate this with timeUnit pipeline // TODO: support utc - "time(".concat(fieldExpr(timeUnit, field), ")") : vgField(predicate, { + `time(${fieldExpr(timeUnit, field)})` : vgField(predicate, { expr: 'datum' }); if (isFieldEqualPredicate(predicate)) { - return "".concat(fieldExpr$1, "===").concat(predicateValueExpr(predicate.equal, timeUnit)); + return `${fieldExpr$1}===${predicateValueExpr(predicate.equal, timeUnit)}`; } else if (isFieldLTPredicate(predicate)) { const upper = predicate.lt; - return "".concat(fieldExpr$1, "<").concat(predicateValueExpr(upper, timeUnit)); + return `${fieldExpr$1}<${predicateValueExpr(upper, timeUnit)}`; } else if (isFieldGTPredicate(predicate)) { const lower = predicate.gt; - return "".concat(fieldExpr$1, ">").concat(predicateValueExpr(lower, timeUnit)); + return `${fieldExpr$1}>${predicateValueExpr(lower, timeUnit)}`; } else if (isFieldLTEPredicate(predicate)) { const upper = predicate.lte; - return "".concat(fieldExpr$1, "<=").concat(predicateValueExpr(upper, timeUnit)); + return `${fieldExpr$1}<=${predicateValueExpr(upper, timeUnit)}`; } else if (isFieldGTEPredicate(predicate)) { const lower = predicate.gte; - return "".concat(fieldExpr$1, ">=").concat(predicateValueExpr(lower, timeUnit)); + return `${fieldExpr$1}>=${predicateValueExpr(lower, timeUnit)}`; } else if (isFieldOneOfPredicate(predicate)) { - return "indexof([".concat(predicateValuesExpr(predicate.oneOf, timeUnit).join(','), "], ").concat(fieldExpr$1, ") !== -1"); + return `indexof([${predicateValuesExpr(predicate.oneOf, timeUnit).join(',')}], ${fieldExpr$1}) !== -1`; } else if (isFieldValidPredicate(predicate)) { return fieldValidPredicate(fieldExpr$1, predicate.valid); } else if (isFieldRangePredicate(predicate)) { const { range } = predicate; const lower = isSignalRef(range) ? { - signal: "".concat(range.signal, "[0]") + signal: `${range.signal}[0]` } : range[0]; const upper = isSignalRef(range) ? { - signal: "".concat(range.signal, "[1]") + signal: `${range.signal}[1]` } : range[1]; if (lower !== null && upper !== null && useInRange) { return 'inrange(' + fieldExpr$1 + ', [' + predicateValueExpr(lower, timeUnit) + ', ' + predicateValueExpr(upper, timeUnit) + '])'; } const exprs = []; if (lower !== null) { - exprs.push("".concat(fieldExpr$1, " >= ").concat(predicateValueExpr(lower, timeUnit))); + exprs.push(`${fieldExpr$1} >= ${predicateValueExpr(lower, timeUnit)}`); } if (upper !== null) { - exprs.push("".concat(fieldExpr$1, " <= ").concat(predicateValueExpr(upper, timeUnit))); + exprs.push(`${fieldExpr$1} <= ${predicateValueExpr(upper, timeUnit)}`); } return exprs.length > 0 ? exprs.join(' && ') : 'true'; } /* istanbul ignore next: it should never reach here */ - throw new Error("Invalid field predicate: ".concat(stringify(predicate))); + throw new Error(`Invalid field predicate: ${stringify(predicate)}`); } function fieldValidPredicate(fieldExpr) { let valid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; if (valid) { - return "isValid(".concat(fieldExpr, ") && isFinite(+").concat(fieldExpr, ")"); + return `isValid(${fieldExpr}) && isFinite(+${fieldExpr})`; } else { - return "!isValid(".concat(fieldExpr, ") || !isFinite(+").concat(fieldExpr, ")"); + return `!isValid(${fieldExpr}) || !isFinite(+${fieldExpr})`; } } function normalizePredicate$1(f) { if (isFieldPredicate(f) && f.timeUnit) { var _normalizeTimeUnit2; @@ -3190,11 +3183,12 @@ minSize: 9, // Point size is area. For square point, 9 = 3 pixel ^ 2, not too small! minStrokeWidth: 1, maxStrokeWidth: 4, quantileCount: 4, - quantizeCount: 4 + quantizeCount: 4, + zero: true }; function isExtendedScheme(scheme) { return !vega.isString(scheme) && !!scheme['name']; } function isParameterDomain(domain) { @@ -3598,11 +3592,11 @@ if (isDateTime(datum)) { return dateTimeToExpr(datum); } - return "".concat(stringify(datum)); + return `${stringify(datum)}`; } function valueRefForFieldOrDatumDef(fieldDef, scaleName, opt, encode) { const ref = {}; if (scaleName) { @@ -3673,12 +3667,12 @@ if (bandPosition === 0 || bandPosition === 1) { ref.scale = scaleName; const val = bandPosition === 0 ? start : end; ref.field = val; } else { - const datum = isSignalRef(bandPosition) ? "".concat(bandPosition.signal, " * ").concat(start, " + (1-").concat(bandPosition.signal, ") * ").concat(end) : "".concat(bandPosition, " * ").concat(start, " + ").concat(1 - bandPosition, " * ").concat(end); - ref.signal = "scale(\"".concat(scaleName, "\", ").concat(datum, ")"); + const datum = isSignalRef(bandPosition) ? `${bandPosition.signal} * ${start} + (1-${bandPosition.signal}) * ${end}` : `${bandPosition} * ${start} + ${1 - bandPosition} * ${end}`; + ref.signal = `scale("${scaleName}", ${datum})`; } if (offset) { ref.offset = offset; } @@ -3706,18 +3700,14 @@ // TODO: datum support if (channelDef) { /* istanbul ignore else */ if (isFieldOrDatumDef(channelDef)) { - var _ref4, _bandPosition2; - const scaleType = scale === null || scale === void 0 ? void 0 : scale.get('type'); if (isTypedFieldDef(channelDef)) { - var _bandPosition; - - (_bandPosition = bandPosition) !== null && _bandPosition !== void 0 ? _bandPosition : bandPosition = getBandPosition({ + bandPosition ??= getBandPosition({ fieldDef: channelDef, fieldDef2: channel2Def, markDef, config }); @@ -3775,11 +3765,11 @@ binSuffix: 'range' } : {}, // no need for bin suffix if there is no scale { offset, // For band, to get mid point, need to offset by half of the band - band: scaleType === 'band' ? (_ref4 = (_bandPosition2 = bandPosition) !== null && _bandPosition2 !== void 0 ? _bandPosition2 : channelDef.bandPosition) !== null && _ref4 !== void 0 ? _ref4 : 0.5 : undefined + band: scaleType === 'band' ? bandPosition ?? channelDef.bandPosition ?? 0.5 : undefined }); } else if (isValueDef(channelDef)) { const value = channelDef.value; const offsetMixins = offset ? { offset @@ -3833,11 +3823,11 @@ function isCustomFormatType(formatType) { return formatType && formatType !== 'number' && formatType !== 'time'; } function customFormatExpr(formatType, field, format) { - return "".concat(formatType, "(").concat(field).concat(format ? ", ".concat(stringify(format)) : '', ")"); + return `${formatType}(${field}${format ? `, ${stringify(format)}` : ''})`; } const BIN_RANGE_DELIMITER = ' \u2013 '; function formatSignalRef(_ref) { let { @@ -3925,29 +3915,29 @@ return { signal: binFormatExpression(field, endField, format, formatType, config) }; } else if (format || channelDefType(fieldOrDatumDef) === 'quantitative') { return { - signal: "".concat(formatExpr(field, format)) + signal: `${formatExpr(field, format)}` }; } else { return { - signal: "isValid(".concat(field, ") ? ").concat(field, " : \"\"+").concat(field) + signal: `isValid(${field}) ? ${field} : ""+${field}` }; } } function fieldToFormat(fieldOrDatumDef, expr, normalizeStack) { if (isFieldDef(fieldOrDatumDef)) { if (normalizeStack) { - return "".concat(vgField(fieldOrDatumDef, { - expr, - suffix: 'end' - }), "-").concat(vgField(fieldOrDatumDef, { - expr, - suffix: 'start' - })); + return `${vgField(fieldOrDatumDef, { + expr, + suffix: 'end' + })}-${vgField(fieldOrDatumDef, { + expr, + suffix: 'start' + })}`; } else { return vgField(fieldOrDatumDef, { expr }); } @@ -3955,22 +3945,20 @@ return datumDefToExpr(fieldOrDatumDef); } } function formatCustomType(_ref2) { - var _field; - let { fieldOrDatumDef, format, formatType, expr, normalizeStack, config, field } = _ref2; - (_field = field) !== null && _field !== void 0 ? _field : field = fieldToFormat(fieldOrDatumDef, expr, normalizeStack); + field ??= fieldToFormat(fieldOrDatumDef, expr, normalizeStack); if (field !== 'datum.value' && // For axis/legend, we can't correctly know the end of the bin from `datum` isFieldDef(fieldOrDatumDef) && isBinning(fieldOrDatumDef.bin)) { const endField = vgField(fieldOrDatumDef, { expr, @@ -4092,55 +4080,53 @@ return omitTimeFormatConfig ? undefined : config.timeFormat; } function formatExpr(field, format) { - return "format(".concat(field, ", \"").concat(format || '', "\")"); + return `format(${field}, "${format || ''}")`; } function binNumberFormatExpr(field, format, formatType, config) { - var _ref5; - if (isCustomFormatType(formatType)) { return customFormatExpr(formatType, field, format); } - return formatExpr(field, (_ref5 = vega.isString(format) ? format : undefined) !== null && _ref5 !== void 0 ? _ref5 : config.numberFormat); + return formatExpr(field, (vega.isString(format) ? format : undefined) ?? config.numberFormat); } function binFormatExpression(startField, endField, format, formatType, config) { if (format === undefined && formatType === undefined && config.customFormatTypes && config.numberFormatType) { return binFormatExpression(startField, endField, config.numberFormat, config.numberFormatType, config); } const start = binNumberFormatExpr(startField, format, formatType, config); const end = binNumberFormatExpr(endField, format, formatType, config); - return "".concat(fieldValidPredicate(startField, false), " ? \"null\" : ").concat(start, " + \"").concat(BIN_RANGE_DELIMITER, "\" + ").concat(end); + return `${fieldValidPredicate(startField, false)} ? "null" : ${start} + "${BIN_RANGE_DELIMITER}" + ${end}`; } /** * Returns the time expression used for axis/legend labels or text mark for a temporal field */ - function timeFormatExpression(_ref6) { + function timeFormatExpression(_ref5) { let { field, timeUnit, format, formatType, rawTimeFormat, isUTCScale - } = _ref6; + } = _ref5; if (!timeUnit || format) { // If there is no time unit, or if user explicitly specifies format for axis/legend/text. if (!timeUnit && formatType) { - return "".concat(formatType, "(").concat(field, ", '").concat(format, "')"); + return `${formatType}(${field}, '${format}')`; } format = vega.isString(format) ? format : rawTimeFormat; // only use provided timeFormat if there is no timeUnit. - return "".concat(isUTCScale ? 'utc' : 'time', "Format(").concat(field, ", '").concat(format, "')"); + return `${isUTCScale ? 'utc' : 'time'}Format(${field}, '${format}')`; } else { return formatExpression(timeUnit, field, isUTCScale); } } @@ -4418,44 +4404,40 @@ aggregate, timeUnit } = fieldDef; if (isBinning(bin)) { - var _opt$binSuffix, _opt$suffix; - fn = binToString(bin); - suffix = ((_opt$binSuffix = opt.binSuffix) !== null && _opt$binSuffix !== void 0 ? _opt$binSuffix : '') + ((_opt$suffix = opt.suffix) !== null && _opt$suffix !== void 0 ? _opt$suffix : ''); + suffix = (opt.binSuffix ?? '') + (opt.suffix ?? ''); } else if (aggregate) { if (isArgmaxDef(aggregate)) { - argAccessor = "[\"".concat(field, "\"]"); - field = "argmax_".concat(aggregate.argmax); + argAccessor = `["${field}"]`; + field = `argmax_${aggregate.argmax}`; } else if (isArgminDef(aggregate)) { - argAccessor = "[\"".concat(field, "\"]"); - field = "argmin_".concat(aggregate.argmin); + argAccessor = `["${field}"]`; + field = `argmin_${aggregate.argmin}`; } else { fn = String(aggregate); } } else if (timeUnit) { - var _opt$suffix2; - fn = timeUnitToString(timeUnit); - suffix = (!['range', 'mid'].includes(opt.binSuffix) && opt.binSuffix || '') + ((_opt$suffix2 = opt.suffix) !== null && _opt$suffix2 !== void 0 ? _opt$suffix2 : ''); + suffix = (!['range', 'mid'].includes(opt.binSuffix) && opt.binSuffix || '') + (opt.suffix ?? ''); } } } if (fn) { - field = field ? "".concat(fn, "_").concat(field) : fn; + field = field ? `${fn}_${field}` : fn; } } if (suffix) { - field = "".concat(field, "_").concat(suffix); + field = `${field}_${suffix}`; } if (prefix) { - field = "".concat(prefix, "_").concat(field); + field = `${prefix}_${field}`; } if (opt.forAs) { return removePathFromField(field); } else if (opt.expr) { @@ -4499,26 +4481,26 @@ } = fieldDef; if (aggregate === 'count') { return config.countTitle; } else if (isBinning(bin)) { - return "".concat(field, " (binned)"); + return `${field} (binned)`; } else if (timeUnit) { var _normalizeTimeUnit; const unit = (_normalizeTimeUnit = normalizeTimeUnit(timeUnit)) === null || _normalizeTimeUnit === void 0 ? void 0 : _normalizeTimeUnit.unit; if (unit) { - return "".concat(field, " (").concat(getTimeUnitParts(unit).join('-'), ")"); + return `${field} (${getTimeUnitParts(unit).join('-')})`; } } else if (aggregate) { if (isArgmaxDef(aggregate)) { - return "".concat(field, " for max ").concat(aggregate.argmax); + return `${field} for max ${aggregate.argmax}`; } else if (isArgminDef(aggregate)) { - return "".concat(field, " for min ").concat(aggregate.argmin); + return `${field} for min ${aggregate.argmin}`; } else { - return "".concat(titleCase(aggregate), " of ").concat(field); + return `${titleCase(aggregate)} of ${field}`; } } return field; } @@ -4529,20 +4511,20 @@ timeUnit, field } = fieldDef; if (isArgmaxDef(aggregate)) { - return "".concat(field, " for argmax(").concat(aggregate.argmax, ")"); + return `${field} for argmax(${aggregate.argmax})`; } else if (isArgminDef(aggregate)) { - return "".concat(field, " for argmin(").concat(aggregate.argmin, ")"); + return `${field} for argmin(${aggregate.argmin})`; } const timeUnitParams = normalizeTimeUnit(timeUnit); const fn = aggregate || (timeUnitParams === null || timeUnitParams === void 0 ? void 0 : timeUnitParams.unit) || (timeUnitParams === null || timeUnitParams === void 0 ? void 0 : timeUnitParams.maxbins) && 'timeunit' || isBinning(bin) && 'bin'; if (fn) { - return "".concat(fn.toUpperCase(), "(").concat(field, ")"); + return `${fn.toUpperCase()}(${field})`; } else { return field; } } const defaultTitleFormatter = (fieldDef, config) => { @@ -4572,22 +4554,20 @@ includeDefault = true } = _ref3; const guideTitle = (_getGuide = getGuide(fieldOrDatumDef)) === null || _getGuide === void 0 ? void 0 : _getGuide.title; if (!isFieldDef(fieldOrDatumDef)) { - return guideTitle !== null && guideTitle !== void 0 ? guideTitle : fieldOrDatumDef.title; + return guideTitle ?? fieldOrDatumDef.title; } const fieldDef = fieldOrDatumDef; const def = includeDefault ? defaultTitle(fieldDef, config) : undefined; if (allowDisabling) { return getFirstDefined(guideTitle, fieldDef.title, def); } else { - var _ref4; - - return (_ref4 = guideTitle !== null && guideTitle !== void 0 ? guideTitle : fieldDef.title) !== null && _ref4 !== void 0 ? _ref4 : def; + return guideTitle ?? fieldDef.title ?? def; } } function getGuide(fieldDef) { if (isPositionFieldOrDatumDef(fieldDef) && fieldDef.axis) { return fieldDef.axis; @@ -4611,13 +4591,11 @@ return { format, formatType }; } else { - var _getGuide2; - - const guide = (_getGuide2 = getGuide(fieldDef)) !== null && _getGuide2 !== void 0 ? _getGuide2 : {}; + const guide = getGuide(fieldDef) ?? {}; const { format, formatType } = guide; return { @@ -4802,11 +4780,11 @@ if (timeUnit) { fieldDef.timeUnit = normalizeTimeUnit(timeUnit); } if (field) { - fieldDef.field = "".concat(field); + fieldDef.field = `${field}`; } // Normalize bin if (isBinning(bin)) { fieldDef.bin = normalizeBin(bin, channel); @@ -4924,11 +4902,11 @@ const type = fieldDef.type; if (type === 'geojson' && channel !== 'shape') { return { compatible: false, - warning: "Channel ".concat(channel, " should not be used with a geojson data.") + warning: `Channel ${channel} should not be used with a geojson data.` }; } switch (channel) { case ROW: @@ -4967,11 +4945,11 @@ case LATITUDE: case LATITUDE2: if (type !== QUANTITATIVE) { return { compatible: false, - warning: "Channel ".concat(channel, " should be used with a quantitative field only, not ").concat(fieldDef.type, " field.") + warning: `Channel ${channel} should be used with a quantitative field only, not ${fieldDef.type} field.` }; } return COMPATIBLE; @@ -4985,11 +4963,11 @@ case X2: case Y2: if (type === 'nominal' && !fieldDef['sort']) { return { compatible: false, - warning: "Channel ".concat(channel, " should not be used with an unsorted discrete field.") + warning: `Channel ${channel} should not be used with an unsorted discrete field.` }; } return COMPATIBLE; @@ -5006,11 +4984,11 @@ case ORDER: if (fieldDef.type === 'nominal' && !('sort' in fieldDef)) { return { compatible: false, - warning: "Channel order is inappropriate for nominal field, which has no inherent order." + warning: `Channel order is inappropriate for nominal field, which has no inherent order.` }; } return COMPATIBLE; } @@ -5036,19 +5014,19 @@ /** * Getting a value associated with a fielddef. * Convert the value to Vega expression if applicable (for datetime object, or string if the field def is temporal or has timeUnit) */ - function valueExpr(v, _ref5) { + function valueExpr(v, _ref4) { var _normalizeTimeUnit2; let { timeUnit, type, wrapTime, undefinedIfExprNotRequired - } = _ref5; + } = _ref4; const unit = timeUnit && ((_normalizeTimeUnit2 = normalizeTimeUnit(timeUnit)) === null || _normalizeTimeUnit2 === void 0 ? void 0 : _normalizeTimeUnit2.unit); let isTime = unit || type === 'temporal'; let expr; if (isExprRef(v)) { @@ -5058,11 +5036,11 @@ } else if (isDateTime(v)) { isTime = true; expr = dateTimeToExpr(v); } else if (vega.isString(v) || vega.isNumber(v)) { if (isTime) { - expr = "datetime(".concat(stringify(v), ")"); + expr = `datetime(${stringify(v)})`; if (isLocalSingleTimeUnit(unit)) { // for single timeUnit, we will use dateTimeToExpr to convert number/string to match the timeUnit if (vega.isNumber(v) && v < 10000 || vega.isString(v) && isNaN(Date.parse(v))) { expr = dateTimeToExpr({ @@ -5072,11 +5050,11 @@ } } } if (expr) { - return wrapTime && isTime ? "time(".concat(expr, ")") : expr; + return wrapTime && isTime ? `time(${expr})` : expr; } // number or boolean or normal string return undefinedIfExprNotRequired ? undefined : stringify(v); } @@ -5538,20 +5516,20 @@ op: 'argmax', field: aggOp.argmax }, { forAs: true }); - newFieldDef.field = "".concat(newField, ".").concat(field); + newFieldDef.field = `${newField}.${field}`; } else if (isArgminDef(aggOp)) { op = 'argmin'; newField = vgField({ op: 'argmin', field: aggOp.argmin }, { forAs: true }); - newFieldDef.field = "".concat(newField, ".").concat(field); + newFieldDef.field = `${newField}.${field}`; } else if (aggOp !== 'boxplot' && aggOp !== 'errorbar' && aggOp !== 'errorband') { op = aggOp; } if (op) { @@ -5587,13 +5565,13 @@ } // Create accompanying 'x2' or 'y2' field if channel is 'x' or 'y' respectively if (isXorY(channel)) { const secondaryChannel = { - field: "".concat(newField, "_end") + field: `${newField}_end` }; - encoding["".concat(channel, "2")] = secondaryChannel; + encoding[`${channel}2`] = secondaryChannel; } newFieldDef.bin = 'binned'; if (!isSecondaryRangeChannel(channel)) { @@ -5984,16 +5962,16 @@ const fiveSummaryTooltip = tooltipSummary.map(_ref => { let { fieldPrefix, titlePrefix } = _ref; - const mainTitle = withFieldName ? " of ".concat(getTitle(continuousAxisChannelDef)) : ''; + const mainTitle = withFieldName ? ` of ${getTitle(continuousAxisChannelDef)}` : ''; return { field: fieldPrefix + continuousAxisChannelDef.field, type: continuousAxisChannelDef.type, title: isSignalRef(titlePrefix) ? { - signal: "".concat(titlePrefix, "\"").concat(escape(mainTitle), "\"") + signal: `${titlePrefix}"${escape(mainTitle)}"` } : titlePrefix + mainTitle }; }); const tooltipFieldDefs = fieldDefs(encodingWithoutContinuousAxis).map(toStringFieldDef); return { @@ -6025,11 +6003,11 @@ return partLayerMixins(compositeMarkDef, partName, compositeMarkConfig, { mark, // TODO better remove this method and just have mark as a parameter of the method encoding: { [continuousAxis]: { - field: "".concat(positionPrefix, "_").concat(continuousAxisChannelDef.field), + field: `${positionPrefix}_${continuousAxisChannelDef.field}`, type: continuousAxisChannelDef.type, ...(title !== undefined ? { title } : {}), ...(scale !== undefined ? { @@ -6038,12 +6016,12 @@ ...(axis !== undefined ? { axis } : {}) }, ...(vega.isString(endPositionPrefix) ? { - ["".concat(continuousAxis, "2")]: { - field: "".concat(endPositionPrefix, "_").concat(continuousAxisChannelDef.field) + [`${continuousAxis}2`]: { + field: `${endPositionPrefix}_${continuousAxisChannelDef.field}` } } : {}), ...sharedEncoding, ...extraEncoding } @@ -6071,11 +6049,11 @@ opacity } : {}), ...(isMarkDef(partBaseSpec.mark) ? partBaseSpec.mark : { type: partBaseSpec.mark }), - style: "".concat(mark, "-").concat(String(part)), + style: `${mark}-${String(part)}`, ...(vega.isBoolean(markDef[part]) ? {} : markDef[part]) } }]; } @@ -6086,13 +6064,13 @@ encoding } = spec; const continuousAxis = orient === 'vertical' ? 'y' : 'x'; const continuousAxisChannelDef = encoding[continuousAxis]; // Safe to cast because if x is not continuous fielddef, the orient would not be horizontal. - const continuousAxisChannelDef2 = encoding["".concat(continuousAxis, "2")]; - const continuousAxisChannelDefError = encoding["".concat(continuousAxis, "Error")]; - const continuousAxisChannelDefError2 = encoding["".concat(continuousAxis, "Error2")]; + const continuousAxisChannelDef2 = encoding[`${continuousAxis}2`]; + const continuousAxisChannelDefError = encoding[`${continuousAxis}Error`]; + const continuousAxisChannelDefError2 = encoding[`${continuousAxis}Error2`]; return { continuousAxisChannelDef: filterAggregateFromChannelDef(continuousAxisChannelDef, compositeMark), continuousAxisChannelDef2: filterAggregateFromChannelDef(continuousAxisChannelDef2, compositeMark), continuousAxisChannelDefError: filterAggregateFromChannelDef(continuousAxisChannelDefError, compositeMark), continuousAxisChannelDefError2: filterAggregateFromChannelDef(continuousAxisChannelDefError2, compositeMark), @@ -6159,11 +6137,11 @@ } else if (isContinuousFieldOrDatumDef(y)) { // y is continuous but x is not return 'vertical'; } else { // Neither x nor y is continuous. - throw new Error("Need a valid continuous axis for ".concat(compositeMark, "s")); + throw new Error(`Need a valid continuous axis for ${compositeMark}s`); } } const BOXPLOT = 'boxplot'; const BOXPLOT_PARTS = ['box', 'median', 'outliers', 'rule', 'ticks']; @@ -6175,12 +6153,10 @@ return extent; } function normalizeBoxPlot(spec, _ref) { - var _markDef$extent; - let { config } = _ref; // Need to initEncoding first so we can infer type spec = { ...spec, @@ -6199,13 +6175,14 @@ if (params) { warn(selectionNotSupported('boxplot')); } - const extent = (_markDef$extent = markDef.extent) !== null && _markDef$extent !== void 0 ? _markDef$extent : config.boxplot.extent; + const extent = markDef.extent ?? config.boxplot.extent; const sizeValue = getMarkPropOrConfig('size', markDef, // TODO: https://github.com/vega/vega-lite/issues/6245 config); + const invalid = markDef.invalid; const boxPlotType = getBoxPlotType(extent); const { bins, timeUnits, transform, @@ -6255,11 +6232,11 @@ const endTick = { type: 'tick', color: 'black', opacity: 1, orient: ticksOrient, - invalid: null, + invalid, aria: false }; const whiskerTooltipEncoding = boxPlotType === 'min-max' ? fiveSummaryTooltipEncoding // for min-max, show five-summary tooltip for whisker : // for tukey / k-IQR, just show upper/lower-whisker getCompositeMarkTooltip([{ @@ -6271,21 +6248,21 @@ }], continuousAxisChannelDef, encodingWithoutContinuousAxis); const whiskerLayers = [...makeBoxPlotExtent({ partName: 'rule', mark: { type: 'rule', - invalid: null, + invalid, aria: false }, positionPrefix: 'lower_whisker', endPositionPrefix: 'lower_box', extraEncoding: whiskerTooltipEncoding }), ...makeBoxPlotExtent({ partName: 'rule', mark: { type: 'rule', - invalid: null, + invalid, aria: false }, positionPrefix: 'upper_box', endPositionPrefix: 'upper_whisker', extraEncoding: whiskerTooltipEncoding @@ -6308,21 +6285,21 @@ type: 'bar', ...(sizeValue ? { size: sizeValue } : {}), orient: boxOrient, - invalid: null, + invalid, ariaRoleDescription: 'box' }, positionPrefix: 'lower_box', endPositionPrefix: 'upper_box', extraEncoding: fiveSummaryTooltipEncoding }), ...makeBoxPlotMidTick({ partName: 'median', mark: { type: 'tick', - invalid: null, + invalid, ...(vega.isObject(config.boxplot.median) && config.boxplot.median.color ? { color: config.boxplot.median.color } : {}), ...(sizeValue ? { size: sizeValue @@ -6333,50 +6310,48 @@ positionPrefix: 'mid_box', extraEncoding: fiveSummaryTooltipEncoding })]; if (boxPlotType === 'min-max') { - var _outerSpec$transform; - return { ...outerSpec, - transform: ((_outerSpec$transform = outerSpec.transform) !== null && _outerSpec$transform !== void 0 ? _outerSpec$transform : []).concat(transform), + transform: (outerSpec.transform ?? []).concat(transform), layer: boxLayers }; } // Tukey Box Plot - const lowerBoxExpr = "datum[\"lower_box_".concat(continuousAxisChannelDef.field, "\"]"); - const upperBoxExpr = "datum[\"upper_box_".concat(continuousAxisChannelDef.field, "\"]"); - const iqrExpr = "(".concat(upperBoxExpr, " - ").concat(lowerBoxExpr, ")"); - const lowerWhiskerExpr = "".concat(lowerBoxExpr, " - ").concat(extent, " * ").concat(iqrExpr); - const upperWhiskerExpr = "".concat(upperBoxExpr, " + ").concat(extent, " * ").concat(iqrExpr); - const fieldExpr = "datum[\"".concat(continuousAxisChannelDef.field, "\"]"); + const lowerBoxExpr = `datum["lower_box_${continuousAxisChannelDef.field}"]`; + const upperBoxExpr = `datum["upper_box_${continuousAxisChannelDef.field}"]`; + const iqrExpr = `(${upperBoxExpr} - ${lowerBoxExpr})`; + const lowerWhiskerExpr = `${lowerBoxExpr} - ${extent} * ${iqrExpr}`; + const upperWhiskerExpr = `${upperBoxExpr} + ${extent} * ${iqrExpr}`; + const fieldExpr = `datum["${continuousAxisChannelDef.field}"]`; const joinaggregateTransform = { joinaggregate: boxParamsQuartiles(continuousAxisChannelDef.field), groupby }; const filteredWhiskerSpec = { transform: [{ - filter: "(".concat(lowerWhiskerExpr, " <= ").concat(fieldExpr, ") && (").concat(fieldExpr, " <= ").concat(upperWhiskerExpr, ")") + filter: `(${lowerWhiskerExpr} <= ${fieldExpr}) && (${fieldExpr} <= ${upperWhiskerExpr})` }, { aggregate: [{ op: 'min', field: continuousAxisChannelDef.field, - as: "lower_whisker_".concat(continuousAxisChannelDef.field) + as: `lower_whisker_${continuousAxisChannelDef.field}` }, { op: 'max', field: continuousAxisChannelDef.field, - as: "upper_whisker_".concat(continuousAxisChannelDef.field) + as: `upper_whisker_${continuousAxisChannelDef.field}` }, // preserve lower_box / upper_box { op: 'min', - field: "lower_box_".concat(continuousAxisChannelDef.field), - as: "lower_box_".concat(continuousAxisChannelDef.field) + field: `lower_box_${continuousAxisChannelDef.field}`, + as: `lower_box_${continuousAxisChannelDef.field}` }, { op: 'max', - field: "upper_box_".concat(continuousAxisChannelDef.field), - as: "upper_box_".concat(continuousAxisChannelDef.field) + field: `upper_box_${continuousAxisChannelDef.field}`, + as: `upper_box_${continuousAxisChannelDef.field}` }, ...aggregate], groupby }], layer: whiskerLayers }; @@ -6390,11 +6365,11 @@ } = continuousAxisChannelDef; const title = getTitle(continuousAxisChannelDef); const axisWithoutTitle = omit(axis, ['title']); const outlierLayersMixins = partLayerMixins(markDef, 'outliers', config.boxplot, { transform: [{ - filter: "(".concat(fieldExpr, " < ").concat(lowerWhiskerExpr, ") || (").concat(fieldExpr, " > ").concat(upperWhiskerExpr, ")") + filter: `(${fieldExpr} < ${lowerWhiskerExpr}) || (${fieldExpr} > ${upperWhiskerExpr})` }], mark: 'point', encoding: { [continuousAxis]: { field: continuousAxisChannelDef.field, @@ -6443,15 +6418,15 @@ function boxParamsQuartiles(continousAxisField) { return [{ op: 'q1', field: continousAxisField, - as: "lower_box_".concat(continousAxisField) + as: `lower_box_${continousAxisField}` }, { op: 'q3', field: continousAxisField, - as: "upper_box_".concat(continousAxisField) + as: `upper_box_${continousAxisField}` }]; } function boxParams(spec, extent, config) { const orient = compositeMarkOrient(spec, BOXPLOT); @@ -6462,11 +6437,11 @@ const continuousFieldName = continuousAxisChannelDef.field; const boxPlotType = getBoxPlotType(extent); const boxplotSpecificAggregate = [...boxParamsQuartiles(continuousFieldName), { op: 'median', field: continuousFieldName, - as: "mid_box_".concat(continuousFieldName) + as: `mid_box_${continuousFieldName}` }, { op: 'min', field: continuousFieldName, as: (boxPlotType === 'min-max' ? 'lower_whisker_' : 'min_') + continuousFieldName }, { @@ -6474,18 +6449,18 @@ field: continuousFieldName, as: (boxPlotType === 'min-max' ? 'upper_whisker_' : 'max_') + continuousFieldName }]; const postAggregateCalculates = boxPlotType === 'min-max' || boxPlotType === 'tukey' ? [] : [// This is for the original k-IQR, which we do not expose { - calculate: "datum[\"upper_box_".concat(continuousFieldName, "\"] - datum[\"lower_box_").concat(continuousFieldName, "\"]"), - as: "iqr_".concat(continuousFieldName) + calculate: `datum["upper_box_${continuousFieldName}"] - datum["lower_box_${continuousFieldName}"]`, + as: `iqr_${continuousFieldName}` }, { - calculate: "min(datum[\"upper_box_".concat(continuousFieldName, "\"] + datum[\"iqr_").concat(continuousFieldName, "\"] * ").concat(extent, ", datum[\"max_").concat(continuousFieldName, "\"])"), - as: "upper_whisker_".concat(continuousFieldName) + calculate: `min(datum["upper_box_${continuousFieldName}"] + datum["iqr_${continuousFieldName}"] * ${extent}, datum["max_${continuousFieldName}"])`, + as: `upper_whisker_${continuousFieldName}` }, { - calculate: "max(datum[\"lower_box_".concat(continuousFieldName, "\"] - datum[\"iqr_").concat(continuousFieldName, "\"] * ").concat(extent, ", datum[\"min_").concat(continuousFieldName, "\"])"), - as: "lower_whisker_".concat(continuousFieldName) + calculate: `max(datum["lower_box_${continuousFieldName}"] - datum["iqr_${continuousFieldName}"] * ${extent}, datum["min_${continuousFieldName}"])`, + as: `lower_whisker_${continuousFieldName}` }]; const { [continuousAxis]: oldContinuousAxisChannelDef, ...oldEncodingWithoutContinuousAxis } = spec.encoding; @@ -6607,29 +6582,29 @@ const y = encoding.y; if (isTypeAggregatedUpperLower) { // type is aggregated-upper-lower if (isTypeAggregatedError) { - throw new Error("".concat(compositeMark, " cannot be both type aggregated-upper-lower and aggregated-error")); + throw new Error(`${compositeMark} cannot be both type aggregated-upper-lower and aggregated-error`); } const x2 = encoding.x2; const y2 = encoding.y2; if (isFieldOrDatumDef(x2) && isFieldOrDatumDef(y2)) { // having both x, x2 and y, y2 - throw new Error("".concat(compositeMark, " cannot have both x2 and y2")); + throw new Error(`${compositeMark} cannot have both x2 and y2`); } else if (isFieldOrDatumDef(x2)) { if (isContinuousFieldOrDatumDef(x)) { // having x, x2 quantitative and field y, y2 are not specified return { orient: 'horizontal', inputType: 'aggregated-upper-lower' }; } else { // having x, x2 that are not both quantitative - throw new Error("Both x and x2 have to be quantitative in ".concat(compositeMark)); + throw new Error(`Both x and x2 have to be quantitative in ${compositeMark}`); } } else if (isFieldOrDatumDef(y2)) { // y2 is a FieldDef if (isContinuousFieldOrDatumDef(y)) { // having y, y2 quantitative and field x, x2 are not specified @@ -6637,11 +6612,11 @@ orient: 'vertical', inputType: 'aggregated-upper-lower' }; } else { // having y, y2 that are not both quantitative - throw new Error("Both y and y2 have to be quantitative in ".concat(compositeMark)); + throw new Error(`Both y and y2 have to be quantitative in ${compositeMark}`); } } throw new Error('No ranged axis'); } else { @@ -6651,21 +6626,21 @@ const yError = encoding.yError; const yError2 = encoding.yError2; if (isFieldOrDatumDef(xError2) && !isFieldOrDatumDef(xError)) { // having xError2 without xError - throw new Error("".concat(compositeMark, " cannot have xError2 without xError")); + throw new Error(`${compositeMark} cannot have xError2 without xError`); } if (isFieldOrDatumDef(yError2) && !isFieldOrDatumDef(yError)) { // having yError2 without yError - throw new Error("".concat(compositeMark, " cannot have yError2 without yError")); + throw new Error(`${compositeMark} cannot have yError2 without yError`); } if (isFieldOrDatumDef(xError) && isFieldOrDatumDef(yError)) { // having both xError and yError - throw new Error("".concat(compositeMark, " cannot have both xError and yError with both are quantiative")); + throw new Error(`${compositeMark} cannot have both xError and yError with both are quantiative`); } else if (isFieldOrDatumDef(xError)) { if (isContinuousFieldOrDatumDef(x)) { // having x and xError that are all quantitative return { orient: 'horizontal', @@ -6703,12 +6678,10 @@ function errorBarIsInputTypeAggregatedError(encoding) { return isFieldOrDatumDef(encoding.xError) || isFieldOrDatumDef(encoding.xError2) || isFieldOrDatumDef(encoding.yError) || isFieldOrDatumDef(encoding.yError2); } function errorBarParams(spec, compositeMark, config) { - var _outerSpec$transform; - // TODO: use selection const { mark, encoding, params, @@ -6756,11 +6729,11 @@ } = extractTransformsFromEncoding(oldEncodingWithoutContinuousAxis, config); const aggregate = [...oldAggregate, ...errorBarSpecificAggregate]; const groupby = inputType !== 'raw' ? [] : oldGroupBy; const tooltipEncoding = getCompositeMarkTooltip(tooltipSummary, continuousAxisChannelDef, encodingWithoutContinuousAxis, tooltipTitleWithFieldName); return { - transform: [...((_outerSpec$transform = outerSpec.transform) !== null && _outerSpec$transform !== void 0 ? _outerSpec$transform : []), ...bins, ...timeUnits, ...(aggregate.length === 0 ? [] : [{ + transform: [...(outerSpec.transform ?? []), ...bins, ...timeUnits, ...(aggregate.length === 0 ? [] : [{ aggregate, groupby }]), ...postAggregateCalculates], groupby, continuousAxisChannelDef, @@ -6790,22 +6763,22 @@ if (extent === 'stderr' || extent === 'stdev') { errorBarSpecificAggregate = [{ op: extent, field: continuousFieldName, - as: "extent_".concat(continuousFieldName) + as: `extent_${continuousFieldName}` }, { op: center, field: continuousFieldName, - as: "center_".concat(continuousFieldName) + as: `center_${continuousFieldName}` }]; postAggregateCalculates = [{ - calculate: "datum[\"center_".concat(continuousFieldName, "\"] + datum[\"extent_").concat(continuousFieldName, "\"]"), - as: "upper_".concat(continuousFieldName) + calculate: `datum["center_${continuousFieldName}"] + datum["extent_${continuousFieldName}"]`, + as: `upper_${continuousFieldName}` }, { - calculate: "datum[\"center_".concat(continuousFieldName, "\"] - datum[\"extent_").concat(continuousFieldName, "\"]"), - as: "lower_".concat(continuousFieldName) + calculate: `datum["center_${continuousFieldName}"] - datum["extent_${continuousFieldName}"]`, + as: `lower_${continuousFieldName}` }]; tooltipSummary = [{ fieldPrefix: 'center_', titlePrefix: titleCase(center) }, { @@ -6832,19 +6805,19 @@ } errorBarSpecificAggregate = [{ op: lowerExtentOp, field: continuousFieldName, - as: "lower_".concat(continuousFieldName) + as: `lower_${continuousFieldName}` }, { op: upperExtentOp, field: continuousFieldName, - as: "upper_".concat(continuousFieldName) + as: `upper_${continuousFieldName}` }, { op: centerOp, field: continuousFieldName, - as: "center_".concat(continuousFieldName) + as: `center_${continuousFieldName}` }]; tooltipSummary = [{ fieldPrefix: 'upper_', titlePrefix: title({ field: continuousFieldName, @@ -6879,35 +6852,35 @@ } if (inputType === 'aggregated-upper-lower') { tooltipSummary = []; postAggregateCalculates = [{ - calculate: "datum[\"".concat(continuousAxisChannelDef2.field, "\"]"), - as: "upper_".concat(continuousFieldName) + calculate: `datum["${continuousAxisChannelDef2.field}"]`, + as: `upper_${continuousFieldName}` }, { - calculate: "datum[\"".concat(continuousFieldName, "\"]"), - as: "lower_".concat(continuousFieldName) + calculate: `datum["${continuousFieldName}"]`, + as: `lower_${continuousFieldName}` }]; } else if (inputType === 'aggregated-error') { tooltipSummary = [{ fieldPrefix: '', titlePrefix: continuousFieldName }]; postAggregateCalculates = [{ - calculate: "datum[\"".concat(continuousFieldName, "\"] + datum[\"").concat(continuousAxisChannelDefError.field, "\"]"), - as: "upper_".concat(continuousFieldName) + calculate: `datum["${continuousFieldName}"] + datum["${continuousAxisChannelDefError.field}"]`, + as: `upper_${continuousFieldName}` }]; if (continuousAxisChannelDefError2) { postAggregateCalculates.push({ - calculate: "datum[\"".concat(continuousFieldName, "\"] + datum[\"").concat(continuousAxisChannelDefError2.field, "\"]"), - as: "lower_".concat(continuousFieldName) + calculate: `datum["${continuousFieldName}"] + datum["${continuousAxisChannelDefError2.field}"]`, + as: `lower_${continuousFieldName}` }); } else { postAggregateCalculates.push({ - calculate: "datum[\"".concat(continuousFieldName, "\"] - datum[\"").concat(continuousAxisChannelDefError.field, "\"]"), - as: "lower_".concat(continuousFieldName) + calculate: `datum["${continuousFieldName}"] - datum["${continuousAxisChannelDefError.field}"]`, + as: `lower_${continuousFieldName}` }); } } for (const postAggregateCalculate of postAggregateCalculates) { @@ -6925,11 +6898,11 @@ tooltipTitleWithFieldName }; } function getTitlePrefix(center, extent, operation) { - return "".concat(titleCase(center), " ").concat(operation, " ").concat(extent); + return `${titleCase(center)} ${operation} ${extent}`; } const ERRORBAND = 'errorband'; const ERRORBAND_PARTS = ['band', 'borders']; const errorBandNormalizer = new CompositeMarkNormalizer(ERRORBAND, normalizeErrorBand); @@ -7245,13 +7218,11 @@ step, offsetIsDiscrete } = _ref; if (offsetIsDiscrete) { - var _step$for; - - return (_step$for = step.for) !== null && _step$for !== void 0 ? _step$for : 'offset'; + return step.for ?? 'offset'; } else { return 'position'; } } function isStep(size) { @@ -7299,16 +7270,14 @@ for (const prop of COMPOSITION_LAYOUT_PROPERTIES) { if (spec[prop] !== undefined) { if (prop === 'spacing') { - var _spacing$row, _spacing$column; - const spacing = spec[prop]; layout[prop] = vega.isNumber(spacing) ? spacing : { - row: (_spacing$row = spacing.row) !== null && _spacing$row !== void 0 ? _spacing$row : spacingConfig, - column: (_spacing$column = spacing.column) !== null && _spacing$column !== void 0 ? _spacing$column : spacingConfig + row: spacing.row ?? spacingConfig, + column: spacing.column ?? spacingConfig }; } else { layout[prop] = spec[prop]; } } @@ -7316,23 +7285,19 @@ return layout; } function getViewConfigContinuousSize(viewConfig, channel) { - var _viewConfig$channel; - - return (_viewConfig$channel = viewConfig[channel]) !== null && _viewConfig$channel !== void 0 ? _viewConfig$channel : viewConfig[channel === 'width' ? 'continuousWidth' : 'continuousHeight']; // get width/height for backwards compatibility + return viewConfig[channel] ?? viewConfig[channel === 'width' ? 'continuousWidth' : 'continuousHeight']; // get width/height for backwards compatibility } function getViewConfigDiscreteStep(viewConfig, channel) { const size = getViewConfigDiscreteSize(viewConfig, channel); return isStep(size) ? size.step : DEFAULT_STEP; } function getViewConfigDiscreteSize(viewConfig, channel) { - var _viewConfig$channel2; + const size = viewConfig[channel] ?? viewConfig[channel === 'width' ? 'discreteWidth' : 'discreteHeight']; // get width/height for backwards compatibility - const size = (_viewConfig$channel2 = viewConfig[channel]) !== null && _viewConfig$channel2 !== void 0 ? _viewConfig$channel2 : viewConfig[channel === 'width' ? 'discreteWidth' : 'discreteHeight']; // get width/height for backwards compatibility - return getFirstDefined(size, { step: viewConfig.step }); } const DEFAULT_STEP = 20; @@ -7805,26 +7770,22 @@ } } function redirectConfigToStyleConfig(config, prop, // string = composite mark toProp, compositeMarkPart) { - var _toProp; - const propConfig = compositeMarkPart ? config[prop][compositeMarkPart] : config[prop]; if (prop === 'view') { toProp = 'cell'; // View's default style is "cell" } const style = { ...propConfig, - ...config.style[(_toProp = toProp) !== null && _toProp !== void 0 ? _toProp : prop] + ...config.style[toProp ?? prop] }; // set config.style if it is not an empty object if (!isEmpty(style)) { - var _toProp2; - - config.style[(_toProp2 = toProp) !== null && _toProp2 !== void 0 ? _toProp2 : prop] = style; + config.style[toProp ?? prop] = style; } if (!compositeMarkPart) { // For composite mark, so don't delete the whole config yet as we have to do multiple redirections. delete config[prop]; @@ -8272,12 +8233,17 @@ ...(offset ? { stack: offset } : {}) } }; - } + } // overlay line layer should be on the edge of area but passing y2/x2 makes + // it as "rule" mark so that it draws unwanted vertical/horizontal lines. + // point overlay also should not have y2/x2 as it does not support. + + overlayEncoding = omit(overlayEncoding, ['y2', 'x2']); + if (lineOverlay) { layer.push({ ...(projection ? { projection } : {}), mark: { @@ -8588,11 +8554,11 @@ return { ...rest, layer: layer.map(layerValue => { const childRepeater = { ...repeater, layer: layerValue }; - const childName = "".concat((childSpec.name || '') + repeaterPrefix, "child__layer_").concat(varName(layerValue)); + const childName = `${(childSpec.name || '') + repeaterPrefix}child__layer_${varName(layerValue)}`; const child = this.mapLayerOrUnit(childSpec, { ...params, repeater: childRepeater, repeaterPrefix: childName }); child.name = childName; @@ -8601,12 +8567,10 @@ }; } } mapNonLayerRepeat(spec, params) { - var _childSpec$data; - const { repeat, spec: childSpec, data, ...remainingProperties @@ -8634,11 +8598,11 @@ repeat: repeatValue, row: rowValue, column: columnValue, layer: repeater.layer }; - const childName = (childSpec.name || '') + repeaterPrefix + 'child__' + (vega.isArray(repeat) ? "".concat(varName(repeatValue)) : (repeat.row ? "row_".concat(varName(rowValue)) : '') + (repeat.column ? "column_".concat(varName(columnValue)) : '')); + const childName = (childSpec.name || '') + repeaterPrefix + 'child__' + (vega.isArray(repeat) ? `${varName(repeatValue)}` : (repeat.row ? `row_${varName(rowValue)}` : '') + (repeat.column ? `column_${varName(columnValue)}` : '')); const child = this.map(childSpec, { ...params, repeater: childRepeater, repeaterPrefix: childName }); child.name = childName; // we move data up @@ -8648,11 +8612,11 @@ } } const columns = vega.isArray(repeat) ? spec.columns : repeat.column ? repeat.column.length : 1; return { - data: (_childSpec$data = childSpec.data) !== null && _childSpec$data !== void 0 ? _childSpec$data : data, + data: childSpec.data ?? data, // data from child spec should have precedence align: 'all', ...remainingProperties, columns, concat @@ -8785,13 +8749,11 @@ } = def; facetMapping[channel] = defWithoutLayout; for (const prop of ['align', 'center', 'spacing']) { if (def[prop] !== undefined) { - var _layout$prop; - - (_layout$prop = layout[prop]) !== null && _layout$prop !== void 0 ? _layout$prop : layout[prop] = {}; + layout[prop] ??= {}; layout[prop][channel] = def[prop]; } } } } @@ -8907,11 +8869,11 @@ parentProjection, projection })); } - return projection !== null && projection !== void 0 ? projection : parentProjection; + return projection ?? parentProjection; } function isFilter(t) { return 'filter' in t; } @@ -8987,14 +8949,12 @@ }); } class SelectionCompatibilityNormalizer extends SpecMapper { map(spec, normParams) { - var _normParams$emptySele, _normParams$selection; - - (_normParams$emptySele = normParams.emptySelections) !== null && _normParams$emptySele !== void 0 ? _normParams$emptySele : normParams.emptySelections = {}; - (_normParams$selection = normParams.selectionPredicates) !== null && _normParams$selection !== void 0 ? _normParams$selection : normParams.selectionPredicates = {}; + normParams.emptySelections ??= {}; + normParams.selectionPredicates ??= {}; spec = normalizeTransforms(spec, normParams); return super.map(spec, normParams); } mapLayerOrUnit(spec, normParams) { @@ -9040,13 +9000,11 @@ } // Propagate emptiness forwards and backwards normParams.emptySelections[name] = empty !== 'none'; - for (const pred of vals((_normParams$selection2 = normParams.selectionPredicates[name]) !== null && _normParams$selection2 !== void 0 ? _normParams$selection2 : {})) { - var _normParams$selection2; - + for (const pred of vals(normParams.selectionPredicates[name] ?? {})) { pred.empty = empty !== 'none'; } return { name, @@ -9172,32 +9130,28 @@ function normalizePredicate(op, normParams) { // Normalize old compositions of selection names (e.g., selection: {and: ["one", "two"]}) const normalizeSelectionComposition = o => { return normalizeLogicalComposition(o, param => { - var _normParams$emptySele2, _normParams$selection3, _normParams$selection4; - - const empty = (_normParams$emptySele2 = normParams.emptySelections[param]) !== null && _normParams$emptySele2 !== void 0 ? _normParams$emptySele2 : true; + const empty = normParams.emptySelections[param] ?? true; const pred = { param, empty }; - (_normParams$selection4 = (_normParams$selection3 = normParams.selectionPredicates)[param]) !== null && _normParams$selection4 !== void 0 ? _normParams$selection4 : _normParams$selection3[param] = []; + normParams.selectionPredicates[param] ??= []; normParams.selectionPredicates[param].push(pred); return pred; }); }; return op.selection ? normalizeSelectionComposition(op.selection) : normalizeLogicalComposition(op.test || op.filter, o => o.selection ? normalizeSelectionComposition(o.selection) : o); } class TopLevelSelectionsNormalizer extends SpecMapper { map(spec, normParams) { - var _normParams$selection; + const selections = normParams.selections ?? []; - const selections = (_normParams$selection = normParams.selections) !== null && _normParams$selection !== void 0 ? _normParams$selection : []; - if (spec.params && !isUnitSpec(spec)) { const params = []; for (const param of spec.params) { if (isSelectionParameter(param)) { @@ -9213,15 +9167,13 @@ normParams.selections = selections; return super.map(spec, addSpecNameToParams(spec, normParams)); } mapUnit(spec, normParams) { - var _normParams$path; - const selections = normParams.selections; if (!selections || !selections.length) return spec; - const path = ((_normParams$path = normParams.path) !== null && _normParams$path !== void 0 ? _normParams$path : []).concat(spec.name); + const path = (normParams.path ?? []).concat(spec.name); const params = []; for (const selection of selections) { // By default, apply selections to all unit views. if (!selection.views || !selection.views.length) { @@ -9249,14 +9201,12 @@ return proto.call(this, spec, addSpecNameToParams(spec, params)); }; } function addSpecNameToParams(spec, params) { - var _params$path; - return spec.name ? { ...params, - path: ((_params$path = params.path) !== null && _params$path !== void 0 ? _params$path : []).concat(spec.name) + path: (params.path ?? []).concat(spec.name) } : params; } function normalize(spec, config) { if (config === undefined) { @@ -9296,11 +9246,11 @@ } function _normalizeAutoSize(autosize) { return vega.isString(autosize) ? { type: autosize - } : autosize !== null && autosize !== void 0 ? autosize : {}; + } : autosize ?? {}; } /** * Normalize autosize and deal with width or height == "container". */ @@ -9370,11 +9320,11 @@ function isFitType(autoSizeType) { return autoSizeType === 'fit' || autoSizeType === 'fit-x' || autoSizeType === 'fit-y'; } function getFitType(sizeType) { - return sizeType ? "fit-".concat(getPositionScaleChannel(sizeType)) : 'fit'; + return sizeType ? `fit-${getPositionScaleChannel(sizeType)}` : 'fit'; } const TOP_LEVEL_PROPERTIES = ['background', 'padding' // We do not include "autosize" here as it is supported by only unit and layer specs and thus need to be normalized ]; function extractTopLevelProperties(t, includeParams) { const o = {}; @@ -9610,11 +9560,11 @@ let isExpr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; let wrap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : vega.identity; if (vega.isArray(init)) { const assembled = init.map(v => assembleInit(v, isExpr, wrap)); - return isExpr ? "[".concat(assembled.join(', '), "]") : assembled; + return isExpr ? `[${assembled.join(', ')}]` : assembled; } else if (isDateTime(init)) { if (isExpr) { return wrap(dateTimeToExpr(init)); } else { return wrap(dateTimeToTimestamp(init)); @@ -9622,15 +9572,13 @@ } return isExpr ? wrap(stringify(init)) : init; } function assembleUnitSelectionSignals(model, signals) { - for (const selCmpt of vals((_model$component$sele = model.component.selection) !== null && _model$component$sele !== void 0 ? _model$component$sele : {})) { - var _model$component$sele; - + for (const selCmpt of vals(model.component.selection ?? {})) { const name = selCmpt.name; - let modifyExpr = "".concat(name).concat(TUPLE, ", ").concat(selCmpt.resolve === 'global' ? 'true' : "{unit: ".concat(unitName(model), "}")); + let modifyExpr = `${name}${TUPLE}, ${selCmpt.resolve === 'global' ? 'true' : `{unit: ${unitName(model)}}`}`; for (const c of selectionCompilers) { if (!c.defined(selCmpt)) continue; if (c.signals) signals = c.signals(model, selCmpt, signals); if (c.modifyExpr) modifyExpr = c.modifyExpr(model, selCmpt, modifyExpr); @@ -9640,11 +9588,11 @@ name: name + MODIFY, on: [{ events: { signal: selCmpt.name + TUPLE }, - update: "modify(".concat(vega.stringValue(selCmpt.name + STORE), ", ").concat(modifyExpr, ")") + update: `modify(${vega.stringValue(selCmpt.name + STORE)}, ${modifyExpr})` }] }); } return cleanupEmptyOnArray(signals); @@ -9655,33 +9603,31 @@ signals.unshift({ name: 'facet', value: {}, on: [{ events: vega.parseSelector('mousemove', 'scope'), - update: "isTuple(facet) ? facet : group(".concat(name, ").datum") + update: `isTuple(facet) ? facet : group(${name}).datum` }] }); } return cleanupEmptyOnArray(signals); } function assembleTopLevelSignals(model, signals) { let hasSelections = false; - for (const selCmpt of vals((_model$component$sele2 = model.component.selection) !== null && _model$component$sele2 !== void 0 ? _model$component$sele2 : {})) { - var _model$component$sele2; - + for (const selCmpt of vals(model.component.selection ?? {})) { const name = selCmpt.name; const store = vega.stringValue(name + STORE); const hasSg = signals.filter(s => s.name === name); if (hasSg.length === 0) { const resolve = selCmpt.resolve === 'global' ? 'union' : selCmpt.resolve; const isPoint = selCmpt.type === 'point' ? ', true, true)' : ')'; signals.push({ name: selCmpt.name, - update: "".concat(VL_SELECTION_RESOLVE, "(").concat(store, ", ").concat(vega.stringValue(resolve)).concat(isPoint) + update: `${VL_SELECTION_RESOLVE}(${store}, ${vega.stringValue(resolve)}${isPoint}` }); } hasSelections = true; @@ -9713,13 +9659,11 @@ const dataCopy = [...data]; const unit = unitName(model, { escape: false }); - for (const selCmpt of vals((_model$component$sele3 = model.component.selection) !== null && _model$component$sele3 !== void 0 ? _model$component$sele3 : {})) { - var _model$component$sele3; - + for (const selCmpt of vals(model.component.selection ?? {})) { const store = { name: selCmpt.name + STORE }; if (selCmpt.project.hasSelectionId) { @@ -9757,13 +9701,11 @@ } return dataCopy; } function assembleUnitSelectionMarks(model, marks) { - for (const selCmpt of vals((_model$component$sele4 = model.component.selection) !== null && _model$component$sele4 !== void 0 ? _model$component$sele4 : {})) { - var _model$component$sele4; - + for (const selCmpt of vals(model.component.selection ?? {})) { for (const c of selectionCompilers) { if (c.defined(selCmpt) && c.marks) { marks = c.marks(model, selCmpt, marks); } } @@ -9781,11 +9723,11 @@ return marks; } function assembleSelectionScaleDomain(model, extent, scaleCmpt, domain) { const parsedExtent = parseSelectionExtent(model, extent.param, extent); return { - signal: hasContinuousDomain(scaleCmpt.get('type')) && vega.isArray(domain) && domain[0] > domain[1] ? "isValid(".concat(parsedExtent, ") && reverse(").concat(parsedExtent, ")") : parsedExtent + signal: hasContinuousDomain(scaleCmpt.get('type')) && vega.isArray(domain) && domain[0] > domain[1] ? `isValid(${parsedExtent}) && reverse(${parsedExtent})` : parsedExtent }; } function cleanupEmptyOnArray(signals) { return signals.map(s => { @@ -9918,13 +9860,13 @@ } class OutputNode extends DataFlowNode { clone() { const cloneObj = new this.constructor(); - cloneObj.debugName = "clone_".concat(this.debugName); + cloneObj.debugName = `clone_${this.debugName}`; cloneObj._source = this._source; - cloneObj._name = "clone_".concat(this._name); + cloneObj._name = `clone_${this._name}`; cloneObj.type = this.type; cloneObj.refCounts = this.refCounts; cloneObj.refCounts[cloneObj._name] = 0; return cloneObj; } @@ -9959,11 +9901,11 @@ return new Set(); } hash() { if (this._hash === undefined) { - this._hash = "Output ".concat(uniqueId()); + this._hash = `Output ${uniqueId()}`; } return this._hash; } /** @@ -10096,11 +10038,11 @@ dependentFields() { return new Set(vals(this.formula).map(f => f.field)); } hash() { - return "TimeUnit ".concat(hash(this.formula)); + return `TimeUnit ${hash(this.formula)}`; } assemble() { const transforms = []; @@ -10123,11 +10065,11 @@ } : {}), ...(utc ? { timezone: 'utc' } : {}), ...params, - as: [as, "".concat(as, "_end")] + as: [as, `${as}_end`] }); } return transforms; } @@ -10165,24 +10107,22 @@ const project = { defined: () => { return true; // This transform handles its own defaults, so always run parse. }, parse: (model, selCmpt, selDef) => { - var _selCmpt$project; - const name = selCmpt.name; - const proj = (_selCmpt$project = selCmpt.project) !== null && _selCmpt$project !== void 0 ? _selCmpt$project : selCmpt.project = new SelectionProjectionComponent(); + const proj = selCmpt.project ??= new SelectionProjectionComponent(); const parsed = {}; const timeUnits = {}; const signals = new Set(); const signalName = (p, range) => { const suffix = range === 'visual' ? p.channel : p.field; - let sg = varName("".concat(name, "_").concat(suffix)); + let sg = varName(`${name}_${suffix}`); for (let counter = 1; signals.has(sg); counter++) { - sg = varName("".concat(name, "_").concat(suffix, "_").concat(counter)); + sg = varName(`${name}_${suffix}_${counter}`); } signals.add(sg); return { [range]: sg @@ -10230,13 +10170,11 @@ if ('fields' in cfg) { fields = cfg.fields; } } - for (const channel of (_encodings = encodings) !== null && _encodings !== void 0 ? _encodings : []) { - var _encodings; - + for (const channel of encodings ?? []) { const fieldDef = model.fieldDef(channel); if (fieldDef) { let field = fieldDef.field; @@ -10295,13 +10233,11 @@ } else { warn(cannotProjectOnChannelWithoutField(channel)); } } - for (const field of (_fields = fields) !== null && _fields !== void 0 ? _fields : []) { - var _fields; - + for (const field of fields ?? []) { if (proj.hasField[field]) continue; const p = { type: 'E', field }; @@ -10387,17 +10323,17 @@ const namedSg = signals.filter(s => s.name === selCmpt.name)[0]; let update = namedSg.update; if (update.indexOf(VL_SELECTION_RESOLVE) >= 0) { - namedSg.update = "{".concat(bound.map(proj => "".concat(vega.stringValue(replacePathInField(proj.field)), ": ").concat(proj.signals.data)).join(', '), "}"); + namedSg.update = `{${bound.map(proj => `${vega.stringValue(replacePathInField(proj.field))}: ${proj.signals.data}`).join(', ')}}`; } else { for (const proj of bound) { - const mapping = "".concat(vega.stringValue(replacePathInField(proj.field)), ": ").concat(proj.signals.data); + const mapping = `${vega.stringValue(replacePathInField(proj.field))}: ${proj.signals.data}`; if (!update.includes(mapping)) { - update = "".concat(update.substring(0, update.length - 1), ", ").concat(mapping, "}"); + update = `${update.substring(0, update.length - 1)}, ${mapping}}`; } } namedSg.update = update; } @@ -10420,17 +10356,15 @@ return signals; } }; function domain(model, channel) { const scale = vega.stringValue(model.scaleName(channel)); - return "domain(".concat(scale, ")"); + return `domain(${scale})`; } function isTopLevelLayer(model) { - var _model$parent$parent; - - return model.parent && isLayerModel(model.parent) && ((_model$parent$parent = !model.parent.parent) !== null && _model$parent$parent !== void 0 ? _model$parent$parent : isTopLevelLayer(model.parent.parent)); + return model.parent && isLayerModel(model.parent) && (!model.parent.parent ?? isTopLevelLayer(model.parent.parent)); } const BRUSH = '_brush'; const SCALE_TRIGGER = '_scale_trigger'; const interval = { @@ -10442,16 +10376,14 @@ const init = selCmpt.init ? selCmpt.init[0] : null; const dataSignals = []; const scaleTriggers = []; if (selCmpt.translate && !hasScales) { - const filterExpr = "!event.item || event.item.mark.name !== ".concat(vega.stringValue(name + BRUSH)); + const filterExpr = `!event.item || event.item.mark.name !== ${vega.stringValue(name + BRUSH)}`; events(selCmpt, (on, evt) => { - var _evt$between$, _evt$between$$filter; + const filters = vega.array(evt.between[0].filter ??= []); - const filters = vega.array((_evt$between$$filter = (_evt$between$ = evt.between[0]).filter) !== null && _evt$between$$filter !== void 0 ? _evt$between$$filter : _evt$between$.filter = []); - if (!filters.includes(filterExpr)) { filters.push(filterExpr); } return on; @@ -10475,11 +10407,11 @@ const toNum = hasContinuousDomain(scaleType) ? '+' : ''; signals.push(...cs); dataSignals.push(dname); scaleTriggers.push({ scaleName: model.scaleName(channel), - expr: "(!isArray(".concat(dname, ") || ") + "(".concat(toNum, "invert(").concat(scaleName, ", ").concat(vname, ")[0] === ").concat(toNum).concat(dname, "[0] && ") + "".concat(toNum, "invert(").concat(scaleName, ", ").concat(vname, ")[1] === ").concat(toNum).concat(dname, "[1]))") + expr: `(!isArray(${dname}) || ` + `(${toNum}invert(${scaleName}, ${vname})[0] === ${toNum}${dname}[0] && ` + `${toNum}invert(${scaleName}, ${vname})[1] === ${toNum}${dname}[1]))` }); }); // Proxy scale reactions to ensure that an infinite loop doesn't occur // when an interval selection filter touches the scale. if (!hasScales && scaleTriggers.length) { @@ -10488,31 +10420,31 @@ value: {}, on: [{ events: scaleTriggers.map(t => ({ scale: t.scaleName })), - update: "".concat(scaleTriggers.map(t => t.expr).join(' && '), " ? ").concat(name + SCALE_TRIGGER, " : {}") + update: `${scaleTriggers.map(t => t.expr).join(' && ')} ? ${name + SCALE_TRIGGER} : {}` }] }); } // Only add an interval to the store if it has valid data extents. Data extents // are set to null if pixel extents are equal to account for intervals over // ordinal/nominal domains which, when inverted, will still produce a valid datum. - const update = "unit: ".concat(unitName(model), ", fields: ").concat(fieldsSg, ", values"); + const update = `unit: ${unitName(model)}, fields: ${fieldsSg}, values`; return signals.concat({ name: name + TUPLE, ...(init ? { - init: "{".concat(update, ": ").concat(assembleInit(init), "}") + init: `{${update}: ${assembleInit(init)}}` } : {}), ...(dataSignals.length ? { on: [{ events: [{ signal: dataSignals.join(' || ') }], // Prevents double invocation, see https://github.com/vega/vega#1672. - update: "".concat(dataSignals.join(' && '), " ? {").concat(update, ": [").concat(dataSignals, "]} : null") + update: `${dataSignals.join(' && ')} ? {${update}: [${dataSignals}]} : null` }] } : {}) }); }, marks: (model, selCmpt, marks) => { @@ -10521,37 +10453,37 @@ x, y } = selCmpt.project.hasChannel; const xvname = x === null || x === void 0 ? void 0 : x.signals.visual; const yvname = y === null || y === void 0 ? void 0 : y.signals.visual; - const store = "data(".concat(vega.stringValue(selCmpt.name + STORE), ")"); // Do not add a brush if we're binding to scales + const store = `data(${vega.stringValue(selCmpt.name + STORE)})`; // Do not add a brush if we're binding to scales // or we don't have a valid interval projection if (scaleBindings.defined(selCmpt) || !x && !y) { return marks; } const update = { x: x !== undefined ? { - signal: "".concat(xvname, "[0]") + signal: `${xvname}[0]` } : { value: 0 }, y: y !== undefined ? { - signal: "".concat(yvname, "[0]") + signal: `${yvname}[0]` } : { value: 0 }, x2: x !== undefined ? { - signal: "".concat(xvname, "[1]") + signal: `${xvname}[1]` } : { field: { group: 'width' } }, y2: y !== undefined ? { - signal: "".concat(yvname, "[1]") + signal: `${yvname}[1]` } : { field: { group: 'height' } } @@ -10561,11 +10493,11 @@ // to a unit different from the one in the store. if (selCmpt.resolve === 'global') { for (const key of keys(update)) { update[key] = [{ - test: "".concat(store, ".length && ").concat(store, "[0].unit === ").concat(unitName(model)), + test: `${store}.length && ${store}[0].unit === ${unitName(model)}`, ...update[key] }, { value: 0 }]; } @@ -10580,19 +10512,19 @@ cursor, ...stroke } = selCmpt.mark; const vgStroke = keys(stroke).reduce((def, k) => { def[k] = [{ - test: [x !== undefined && "".concat(xvname, "[0] !== ").concat(xvname, "[1]"), y !== undefined && "".concat(yvname, "[0] !== ").concat(yvname, "[1]")].filter(t => t).join(' && '), + test: [x !== undefined && `${xvname}[0] !== ${xvname}[1]`, y !== undefined && `${yvname}[0] !== ${yvname}[1]`].filter(t => t).join(' && '), value: stroke[k] }, { value: null }]; return def; }, {}); return [{ - name: "".concat(name + BRUSH, "_bg"), + name: `${name + BRUSH}_bg`, type: 'rect', clip: true, encode: { enter: { fill: { @@ -10636,33 +10568,33 @@ const hasScales = scaleBindings.defined(selCmpt); const scaleName = vega.stringValue(model.scaleName(channel)); const scale = model.getScaleComponent(channel); const scaleType = scale ? scale.get('type') : undefined; - const scaled = str => "scale(".concat(scaleName, ", ").concat(str, ")"); + const scaled = str => `scale(${scaleName}, ${str})`; const size = model.getSizeSignalRef(channel === X ? 'width' : 'height').signal; - const coord = "".concat(channel, "(unit)"); + const coord = `${channel}(unit)`; const on = events(selCmpt, (def, evt) => { return [...def, { events: evt.between[0], - update: "[".concat(coord, ", ").concat(coord, "]") + update: `[${coord}, ${coord}]` }, // Brush Start { events: evt, - update: "[".concat(vname, "[0], clamp(").concat(coord, ", 0, ").concat(size, ")]") + update: `[${vname}[0], clamp(${coord}, 0, ${size})]` } // Brush End ]; }); // React to pan/zooms of continuous scales. Non-continuous scales // (band, point) cannot be pan/zoomed and any other changes // to their domains (e.g., filtering) should clear the brushes. on.push({ events: { signal: selCmpt.name + SCALE_TRIGGER }, - update: hasContinuousDomain(scaleType) ? "[".concat(scaled("".concat(dname, "[0]")), ", ").concat(scaled("".concat(dname, "[1]")), "]") : "[0, 0]" + update: hasContinuousDomain(scaleType) ? `[${scaled(`${dname}[0]`)}, ${scaled(`${dname}[1]`)}]` : `[0, 0]` }); return hasScales ? [{ name: dname, on: [] }] : [{ @@ -10681,31 +10613,29 @@ // Cannot be `value` as `init` may require datetime exprs. on: [{ events: { signal: vname }, - update: "".concat(vname, "[0] === ").concat(vname, "[1] ? null : invert(").concat(scaleName, ", ").concat(vname, ")") + update: `${vname}[0] === ${vname}[1] ? null : invert(${scaleName}, ${vname})` }] }]; } function events(selCmpt, cb) { return selCmpt.events.reduce((on, evt) => { if (!evt.between) { - warn("".concat(evt, " is not an ordered event stream for interval selections.")); + warn(`${evt} is not an ordered event stream for interval selections.`); return on; } return cb(on, evt); }, []); } const point$1 = { defined: selCmpt => selCmpt.type === 'point', signals: (model, selCmpt, signals) => { - var _model$component$sele; - const name = selCmpt.name; const fieldsSg = name + TUPLE_FIELDS; const project = selCmpt.project; const datum = '(item().isVoronoi ? datum.datum : datum)'; // Only add a discrete selection to the store if a datum is present _and_ // the interaction isn't occurring on a group mark. This guards against @@ -10713,35 +10643,35 @@ // as the group marks are also data-driven. We force the update to account // for constant null states but varying toggles (e.g., shift-click in // whitespace followed by a click in whitespace; the store should only // be cleared on the second click). - const brushes = vals((_model$component$sele = model.component.selection) !== null && _model$component$sele !== void 0 ? _model$component$sele : {}).reduce((acc, cmpt) => { + const brushes = vals(model.component.selection ?? {}).reduce((acc, cmpt) => { return cmpt.type === 'interval' ? acc.concat(cmpt.name + BRUSH) : acc; - }, []).map(b => "indexof(item().mark.name, '".concat(b, "') < 0")).join(' && '); - const test = "datum && item().mark.marktype !== 'group' && indexof(item().mark.role, 'legend') < 0".concat(brushes ? " && ".concat(brushes) : ''); - let update = "unit: ".concat(unitName(model), ", "); + }, []).map(b => `indexof(item().mark.name, '${b}') < 0`).join(' && '); + const test = `datum && item().mark.marktype !== 'group' && indexof(item().mark.role, 'legend') < 0${brushes ? ` && ${brushes}` : ''}`; + let update = `unit: ${unitName(model)}, `; if (selCmpt.project.hasSelectionId) { - update += "".concat(SELECTION_ID, ": ").concat(datum, "[").concat(vega.stringValue(SELECTION_ID), "]"); + update += `${SELECTION_ID}: ${datum}[${vega.stringValue(SELECTION_ID)}]`; } else { const values = project.items.map(p => { const fieldDef = model.fieldDef(p.channel); // Binned fields should capture extents, for a range test against the raw field. - return fieldDef !== null && fieldDef !== void 0 && fieldDef.bin ? "[".concat(datum, "[").concat(vega.stringValue(model.vgField(p.channel, {})), "], ") + "".concat(datum, "[").concat(vega.stringValue(model.vgField(p.channel, { - binSuffix: 'end' - })), "]]") : "".concat(datum, "[").concat(vega.stringValue(p.field), "]"); + return fieldDef !== null && fieldDef !== void 0 && fieldDef.bin ? `[${datum}[${vega.stringValue(model.vgField(p.channel, {}))}], ` + `${datum}[${vega.stringValue(model.vgField(p.channel, { + binSuffix: 'end' + }))}]]` : `${datum}[${vega.stringValue(p.field)}]`; }).join(', '); - update += "fields: ".concat(fieldsSg, ", values: [").concat(values, "]"); + update += `fields: ${fieldsSg}, values: [${values}]`; } const events = selCmpt.events; return signals.concat([{ name: name + TUPLE, on: events ? [{ events, - update: "".concat(test, " ? {").concat(update, "} : null"), + update: `${test} ? {${update}} : null`, force: true }] : [] }]); } }; @@ -10890,12 +10820,10 @@ const toSkip = {}; const expr = reactiveGeom ? 'datum.datum' : 'datum'; const tuples = []; function add(fDef, channel) { - var _value; - const mainChannel = getMainRangeChannel(channel); const fieldDef = isTypedFieldDef(fDef) ? fDef : { ...fDef, type: encoding[mainChannel].type // for secondary field def, copy type from main channel }; @@ -10936,11 +10864,11 @@ config, normalizeStack: true }).signal; } - (_value = value) !== null && _value !== void 0 ? _value : value = textRef(fieldDef, config, expr).signal; + value ??= textRef(fieldDef, config, expr).signal; tuples.push({ channel, key, value }); @@ -10974,14 +10902,14 @@ const data = tooltipData(encoding, stack, config, { reactiveGeom }); const keyValues = entries$1(data).map(_ref => { let [key, value] = _ref; - return "\"".concat(key, "\": ").concat(value); + return `"${key}": ${value}`; }); return keyValues.length > 0 ? { - signal: "{".concat(keyValues.join(', '), "}") + signal: `{${keyValues.join(', ')}}` } : undefined; } function aria(model) { const { @@ -11066,11 +10994,11 @@ return { description: { signal: entries$1(data).map((_ref, index) => { let [key, value] = _ref; - return "\"".concat(index > 0 ? '; ' : '').concat(key, ": \" + (").concat(value, ")"); + return `"${index > 0 ? '; ' : ''}${key}: " + (${value})`; }).join(' + ') } }; } @@ -11092,25 +11020,23 @@ defaultRef, defaultValue } = opt; if (defaultRef === undefined) { - var _defaultValue; - // prettier-ignore - (_defaultValue = defaultValue) !== null && _defaultValue !== void 0 ? _defaultValue : defaultValue = getMarkPropOrConfig(channel, markDef, config, { + defaultValue ??= getMarkPropOrConfig(channel, markDef, config, { vgChannel, ignoreVgConfig: true }); if (defaultValue !== undefined) { defaultRef = signalOrValueRef(defaultValue); } } const channelDef = encoding[channel]; - return wrapCondition(model, channelDef, vgChannel !== null && vgChannel !== void 0 ? vgChannel : channel, cDef => { + return wrapCondition(model, channelDef, vgChannel ?? channel, cDef => { return midPoint({ channel, channelDef: cDef, markDef, config, @@ -11122,12 +11048,10 @@ }); }); } function color(model) { - var _opt$filled, _ref, _getMarkPropOrConfig, _getMarkPropOrConfig2; - let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { filled: undefined }; const { markDef, @@ -11136,21 +11060,21 @@ } = model; const { type: markType } = markDef; // Allow filled to be overridden (for trail's "filled") - const filled = (_opt$filled = opt.filled) !== null && _opt$filled !== void 0 ? _opt$filled : getMarkPropOrConfig('filled', markDef, config); + const filled = opt.filled ?? getMarkPropOrConfig('filled', markDef, config); const transparentIfNeeded = contains(['bar', 'point', 'circle', 'square', 'geoshape'], markType) ? 'transparent' : undefined; - const defaultFill = (_ref = (_getMarkPropOrConfig = getMarkPropOrConfig(filled === true ? 'color' : undefined, markDef, config, { + const defaultFill = getMarkPropOrConfig(filled === true ? 'color' : undefined, markDef, config, { vgChannel: 'fill' - })) !== null && _getMarkPropOrConfig !== void 0 ? _getMarkPropOrConfig : // need to add this manually as getMarkConfig normally drops config.mark[channel] if vgChannel is specified - config.mark[filled === true && 'color']) !== null && _ref !== void 0 ? _ref : // If there is no fill, always fill symbols, bar, geoshape + }) ?? // need to add this manually as getMarkConfig normally drops config.mark[channel] if vgChannel is specified + config.mark[filled === true && 'color'] ?? // If there is no fill, always fill symbols, bar, geoshape // with transparent fills https://github.com/vega/vega-lite/issues/1316 transparentIfNeeded; - const defaultStroke = (_getMarkPropOrConfig2 = getMarkPropOrConfig(filled === false ? 'color' : undefined, markDef, config, { + const defaultStroke = getMarkPropOrConfig(filled === false ? 'color' : undefined, markDef, config, { vgChannel: 'stroke' - })) !== null && _getMarkPropOrConfig2 !== void 0 ? _getMarkPropOrConfig2 : // need to add this manually as getMarkConfig normally drops config.mark[channel] if vgChannel is specified + }) ?? // need to add this manually as getMarkConfig normally drops config.mark[channel] if vgChannel is specified config.mark[filled === false && 'color']; const colorVgChannel = filled ? 'fill' : 'stroke'; const fillStrokeMarkDefAndConfig = { ...(defaultFill ? { fill: signalOrValueRef(defaultFill) } : {}), @@ -11205,11 +11129,11 @@ markDef, encoding = {}, model, bandPosition } = _ref; - const channel = "".concat(baseChannel, "Offset"); // Need to cast as the type can't be inferred automatically + const channel = `${baseChannel}Offset`; // Need to cast as the type can't be inferred automatically const defaultValue = markDef[channel]; const channelDef = encoding[channel]; if ((channel === 'xOffset' || channel === 'yOffset') && channelDef) { @@ -11398,11 +11322,11 @@ // zeroOrMax switch (mainChannel) { case 'radius': // max of radius is min(width, height) / 2 return { - signal: "min(".concat(model.width.signal, ",").concat(model.height.signal, ")/2") + signal: `min(${model.width.signal},${model.height.signal})/2` }; case 'theta': return { signal: '2*PI' @@ -11668,12 +11592,10 @@ return undefined; } function rectPosition(model, channel) { - var _ref, _encoding$sizeChannel; - const { config, encoding, markDef } = model; @@ -11683,11 +11605,11 @@ const channelDef = encoding[channel]; const channelDef2 = encoding[channel2]; const scale = model.getScaleComponent(channel); const scaleType = scale ? scale.get('type') : undefined; const orient = markDef.orient; - const hasSizeDef = (_ref = (_encoding$sizeChannel = encoding[sizeChannel]) !== null && _encoding$sizeChannel !== void 0 ? _encoding$sizeChannel : encoding.size) !== null && _ref !== void 0 ? _ref : getMarkPropOrConfig('size', markDef, config, { + const hasSizeDef = encoding[sizeChannel] ?? encoding.size ?? getMarkPropOrConfig('size', markDef, config, { vgChannel: sizeChannel }); const isBarBand = mark === 'bar' && (channel === 'x' ? orient === 'vertical' : orient === 'horizontal'); // x, x2, and width -- we must specify two of these in all conditions if (isFieldDef(channelDef) && (isBinning(channelDef.bin) || isBinned(channelDef.bin) || channelDef.timeUnit && !channelDef2) && !(hasSizeDef && !isRelativeBandSize(hasSizeDef)) && !hasDiscreteDomain(scaleType)) { @@ -11711,19 +11633,19 @@ if (isRelativeBandSize(bandSize)) { if (scale) { const scaleType = scale.get('type'); if (scaleType === 'band') { - let bandWidth = "bandwidth('".concat(scaleName, "')"); + let bandWidth = `bandwidth('${scaleName}')`; if (bandSize.band !== 1) { - bandWidth = "".concat(bandSize.band, " * ").concat(bandWidth); + bandWidth = `${bandSize.band} * ${bandWidth}`; } // TODO(#8351): make 0.25 here configurable return { - signal: "max(0.25, ".concat(bandWidth, ")") + signal: `max(0.25, ${bandWidth})` }; } else if (bandSize.band !== 1) { warn(cannotUseRelativeBandSizeWithNonBandScale(scaleType)); bandSize = undefined; } @@ -11843,11 +11765,11 @@ channel, scaleName, scale }), bandPosition: center ? offsetType === 'encoding' ? 0 : 0.5 : isSignalRef(bandSize) ? { - signal: "(1-".concat(bandSize, ")/2") + signal: `(1-${bandSize})/2` } : isRelativeBandSize(bandSize) ? (1 - bandSize.band) / 2 : 0 }); if (vgSizeChannel) { return { @@ -11883,31 +11805,31 @@ if (isSignalRef(reverse) || isSignalRef(offset) || isSignalRef(translate)) { const reverseExpr = signalOrStringValue(reverse); const offsetExpr = signalOrStringValue(offset); const translateExpr = signalOrStringValue(translate); - const t = translateExpr ? "".concat(translateExpr, " + ") : ''; - const r = reverseExpr ? "(".concat(reverseExpr, " ? -1 : 1) * ") : ''; - const o = offsetExpr ? "(".concat(offsetExpr, " + ").concat(spacingOffset, ")") : spacingOffset; + const t = translateExpr ? `${translateExpr} + ` : ''; + const r = reverseExpr ? `(${reverseExpr} ? -1 : 1) * ` : ''; + const o = offsetExpr ? `(${offsetExpr} + ${spacingOffset})` : spacingOffset; return { signal: t + r + o }; } else { offset = offset || 0; return translate + (reverse ? -offset - spacingOffset : +offset + spacingOffset); } } - function rectBinPosition(_ref2) { - var _model$component$axes, _axis$get, _getMarkPropOrConfig; + function rectBinPosition(_ref) { + var _model$component$axes; let { fieldDef, fieldDef2, channel, model - } = _ref2; + } = _ref; const { config, markDef, encoding } = model; @@ -11921,13 +11843,13 @@ markDef, config, scaleType }); const axis = (_model$component$axes = model.component.axes[channel]) === null || _model$component$axes === void 0 ? void 0 : _model$component$axes[0]; - const axisTranslate = (_axis$get = axis === null || axis === void 0 ? void 0 : axis.get('translate')) !== null && _axis$get !== void 0 ? _axis$get : 0.5; // vega default is 0.5 + const axisTranslate = (axis === null || axis === void 0 ? void 0 : axis.get('translate')) ?? 0.5; // vega default is 0.5 - const spacing = isXorY(channel) ? (_getMarkPropOrConfig = getMarkPropOrConfig('binSpacing', markDef, config)) !== null && _getMarkPropOrConfig !== void 0 ? _getMarkPropOrConfig : 0 : 0; + const spacing = isXorY(channel) ? getMarkPropOrConfig('binSpacing', markDef, config) ?? 0 : 0; const channel2 = getSecondaryRangeChannel(channel); const vgChannel = getVgPositionChannel(channel); const vgChannel2 = getVgPositionChannel(channel2); const { offset @@ -11937,11 +11859,11 @@ encoding, model, bandPosition: 0 }); const bandPosition = isSignalRef(bandSize) ? { - signal: "(1-".concat(bandSize.signal, ")/2") + signal: `(1-${bandSize.signal})/2` } : isRelativeBandSize(bandSize) ? (1 - bandSize.band) / 2 : 0.5; if (isBinning(fieldDef.bin) || fieldDef.timeUnit) { return { [vgChannel2]: rectBinRef({ @@ -11952,11 +11874,11 @@ }), [vgChannel]: rectBinRef({ fieldDef, scaleName, bandPosition: isSignalRef(bandPosition) ? { - signal: "1-".concat(bandPosition.signal) + signal: `1-${bandPosition.signal}` } : 1 - bandPosition, offset: getBinSpacing(channel, spacing, reverse, axisTranslate, offset) }) }; } else if (isBinned(fieldDef.bin)) { @@ -11973,13 +11895,13 @@ }; } else if (isBinParams(fieldDef.bin) && fieldDef.bin.step) { return { [vgChannel2]: startRef, [vgChannel]: { - signal: "scale(\"".concat(scaleName, "\", ").concat(vgField(fieldDef, { - expr: 'datum' - }), " + ").concat(fieldDef.bin.step, ")"), + signal: `scale("${scaleName}", ${vgField(fieldDef, { + expr: 'datum' + })} + ${fieldDef.bin.step})`, offset: getBinSpacing(channel, spacing, reverse, axisTranslate, offset) } }; } } @@ -11990,17 +11912,17 @@ /** * Value Ref for binned fields */ - function rectBinRef(_ref3) { + function rectBinRef(_ref2) { let { fieldDef, scaleName, bandPosition, offset - } = _ref3; + } = _ref2; return interpolatedSignalRef({ scaleName, fieldOrDatumDef: fieldDef, bandPosition, offset @@ -12094,11 +12016,11 @@ }, {}); const fields = keys(filterIndex); if (fields.length > 0) { const op = invalid ? '||' : '&&'; - return fields.map(field => fieldInvalidPredicate(field, invalid)).join(" ".concat(op, " ")); + return fields.map(field => fieldInvalidPredicate(field, invalid)).join(` ${op} `); } return undefined; } @@ -12152,11 +12074,11 @@ }, {}); const fields = keys(filterIndex); if (fields.length > 0) { const op = invalid ? '||' : '&&'; - return fields.map(field => fieldInvalidPredicate(field, invalid)).join(" ".concat(op, " ")); + return fields.map(field => fieldInvalidPredicate(field, invalid)).join(` ${op} `); } return undefined; } @@ -12234,14 +12156,12 @@ }] }; let index = 0; let exists = false; marks.forEach((mark, i) => { - var _mark$name; + const name = mark.name ?? ''; - const name = (_mark$name = mark.name) !== null && _mark$name !== void 0 ? _mark$name : ''; - if (name === model.component.mark[0].name) { index = i; } else if (name.indexOf(VORONOI) >= 0) { exists = true; } @@ -12266,43 +12186,41 @@ const bind = selCmpt.bind; const init = selCmpt.init && selCmpt.init[0]; // Can only exist on single selections (one initial value). const datum = nearest.defined(selCmpt) ? '(item().isVoronoi ? datum.datum : datum)' : 'datum'; proj.items.forEach((p, i) => { - const sgname = varName("".concat(name, "_").concat(p.field)); + const sgname = varName(`${name}_${p.field}`); const hasSignal = signals.filter(s => s.name === sgname); if (!hasSignal.length) { - var _ref, _bind$p$field; - signals.unshift({ name: sgname, ...(init ? { init: assembleInit(init[i]) } : { value: null }), on: selCmpt.events ? [{ events: selCmpt.events, - update: "datum && item().mark.marktype !== 'group' ? ".concat(datum, "[").concat(vega.stringValue(p.field), "] : null") + update: `datum && item().mark.marktype !== 'group' ? ${datum}[${vega.stringValue(p.field)}] : null` }] : [], - bind: (_ref = (_bind$p$field = bind[p.field]) !== null && _bind$p$field !== void 0 ? _bind$p$field : bind[p.channel]) !== null && _ref !== void 0 ? _ref : bind + bind: bind[p.field] ?? bind[p.channel] ?? bind }); } }); return signals; }, signals: (model, selCmpt, signals) => { const name = selCmpt.name; const proj = selCmpt.project; const signal = signals.filter(s => s.name === name + TUPLE)[0]; const fields = name + TUPLE_FIELDS; - const values = proj.items.map(p => varName("".concat(name, "_").concat(p.field))); - const valid = values.map(v => "".concat(v, " !== null")).join(' && '); + const values = proj.items.map(p => varName(`${name}_${p.field}`)); + const valid = values.map(v => `${v} !== null`).join(' && '); if (values.length) { - signal.update = "".concat(valid, " ? {fields: ").concat(fields, ", values: [").concat(values.join(', '), "]} : null"); + signal.update = `${valid} ? {fields: ${fields}, values: [${values.join(', ')}]} : null`; } delete signal.value; delete signal.on; return signals; @@ -12325,11 +12243,11 @@ }); }, modifyExpr: (model, selCmpt) => { const tpl = selCmpt.name + TUPLE; const signal = selCmpt.name + TOGGLE; - return "".concat(signal, " ? null : ").concat(tpl, ", ") + (selCmpt.resolve === 'global' ? "".concat(signal, " ? null : true, ") : "".concat(signal, " ? null : {unit: ").concat(unitName(model), "}, ")) + "".concat(signal, " ? ").concat(tpl, " : null"); + return `${signal} ? null : ${tpl}, ` + (selCmpt.resolve === 'global' ? `${signal} ? null : true, ` : `${signal} ? null : {unit: ${unitName(model)}}, `) + `${signal} ? ${tpl} : null`; } }; const clear = { defined: selCmpt => { @@ -12341,11 +12259,11 @@ } }, topLevelSignals: (model, selCmpt, signals) => { if (inputBindings.defined(selCmpt)) { for (const proj of selCmpt.project.items) { - const idx = signals.findIndex(n => n.name === varName("".concat(selCmpt.name, "_").concat(proj.field))); + const idx = signals.findIndex(n => n.name === varName(`${selCmpt.name}_${proj.field}`)); if (idx !== -1) { signals[idx].on.push({ events: selCmpt.clear, update: 'null' @@ -12415,14 +12333,12 @@ if (vega.isObject(selDef.select) && (selDef.select.on || selDef.select.clear)) { const legendFilter = 'event.item && indexof(event.item.mark.role, "legend") < 0'; for (const evt of selCmpt.events) { - var _evt$filter; + evt.filter = vega.array(evt.filter ?? []); - evt.filter = vega.array((_evt$filter = evt.filter) !== null && _evt$filter !== void 0 ? _evt$filter : []); - if (!evt.filter.includes(legendFilter)) { evt.filter.push(legendFilter); } } } @@ -12445,16 +12361,16 @@ return ds; }; for (const proj of selCmpt.project.items) { if (!proj.hasLegend) continue; - const prefix = "".concat(varName(proj.field), "_legend"); - const sgName = "".concat(selName, "_").concat(prefix); + const prefix = `${varName(proj.field)}_legend`; + const sgName = `${selName}_${prefix}`; const hasSignal = signals.filter(s => s.name === sgName); if (hasSignal.length === 0) { - const events = stream.merge.map(markName("".concat(prefix, "_symbols"))).concat(stream.merge.map(markName("".concat(prefix, "_labels")))).concat(stream.merge.map(markName("".concat(prefix, "_entries")))); + const events = stream.merge.map(markName(`${prefix}_symbols`)).concat(stream.merge.map(markName(`${prefix}_labels`))).concat(stream.merge.map(markName(`${prefix}_entries`))); signals.unshift({ name: sgName, ...(!selCmpt.init ? { value: null } : {}), @@ -12463,11 +12379,11 @@ events, update: 'datum.value || item().items[0].items[0].datum.value', force: true }, { events: stream.merge, - update: "!event.item || !datum ? null : ".concat(sgName), + update: `!event.item || !datum ? null : ${sgName}`, force: true }] }); } } @@ -12477,13 +12393,13 @@ signals: (model, selCmpt, signals) => { const name = selCmpt.name; const proj = selCmpt.project; const tuple = signals.find(s => s.name === name + TUPLE); const fields = name + TUPLE_FIELDS; - const values = proj.items.filter(p => p.hasLegend).map(p => varName("".concat(name, "_").concat(varName(p.field), "_legend"))); - const valid = values.map(v => "".concat(v, " !== null")).join(' && '); - const update = "".concat(valid, " ? {fields: ").concat(fields, ", values: [").concat(values.join(', '), "]} : null"); + const values = proj.items.filter(p => p.hasLegend).map(p => varName(`${name}_${varName(p.field)}_legend`)); + const valid = values.map(v => `${v} !== null`).join(' && '); + const update = `${valid} ? {fields: ${fields}, values: [${values.join(', ')}]} : null`; if (selCmpt.events && values.length > 0) { tuple.on.push({ events: values.map(signal => ({ signal @@ -12511,19 +12427,15 @@ function parseInteractiveLegend(model, channel, legendCmpt) { var _model$fieldDef; const field = (_model$fieldDef = model.fieldDef(channel)) === null || _model$fieldDef === void 0 ? void 0 : _model$fieldDef.field; - for (const selCmpt of vals((_model$component$sele = model.component.selection) !== null && _model$component$sele !== void 0 ? _model$component$sele : {})) { - var _model$component$sele, _selCmpt$project$hasF; + for (const selCmpt of vals(model.component.selection ?? {})) { + const proj = selCmpt.project.hasField[field] ?? selCmpt.project.hasChannel[channel]; - const proj = (_selCmpt$project$hasF = selCmpt.project.hasField[field]) !== null && _selCmpt$project$hasF !== void 0 ? _selCmpt$project$hasF : selCmpt.project.hasChannel[channel]; - if (proj && legendBindings.defined(selCmpt)) { - var _legendCmpt$get; - - const legendSelections = (_legendCmpt$get = legendCmpt.get('selections')) !== null && _legendCmpt$get !== void 0 ? _legendCmpt$get : []; + const legendSelections = legendCmpt.get('selections') ?? []; legendSelections.push(selCmpt.name); legendCmpt.set('selections', legendSelections, false); proj.hasLegend = true; } } @@ -12552,18 +12464,18 @@ signals.push({ name: anchor, value: {}, on: [{ events: events.map(e => e.between[0]), - update: '{x: x(unit), y: y(unit)' + (x !== undefined ? ", extent_x: ".concat(hasScales ? domain(model, X) : "slice(".concat(x.signals.visual, ")")) : '') + (y !== undefined ? ", extent_y: ".concat(hasScales ? domain(model, Y) : "slice(".concat(y.signals.visual, ")")) : '') + '}' + update: '{x: x(unit), y: y(unit)' + (x !== undefined ? `, extent_x: ${hasScales ? domain(model, X) : `slice(${x.signals.visual})`}` : '') + (y !== undefined ? `, extent_y: ${hasScales ? domain(model, Y) : `slice(${y.signals.visual})`}` : '') + '}' }] }, { name: name + DELTA$1, value: {}, on: [{ events, - update: "{x: ".concat(anchor, ".x - x(unit), y: ").concat(anchor, ".y - y(unit)}") + update: `{x: ${anchor}.x - x(unit), y: ${anchor}.y - y(unit)}` }] }); if (x !== undefined) { onDelta$1(model, selCmpt, x, 'width', signals); @@ -12576,12 +12488,10 @@ return signals; } }; function onDelta$1(model, selCmpt, proj, size, signals) { - var _scaleCmpt$get, _scaleCmpt$get2; - const name = selCmpt.name; const anchor = name + ANCHOR$1; const delta = name + DELTA$1; const channel = proj.channel; const hasScales = scaleBindings.defined(selCmpt); @@ -12590,20 +12500,20 @@ const scaleCmpt = model.getScaleComponent(channel); const scaleType = scaleCmpt.get('type'); const reversed = scaleCmpt.get('reverse'); // scale parsing sets this flag for fieldDef.sort const sign = !hasScales ? '' : channel === X ? reversed ? '' : '-' : reversed ? '-' : ''; - const extent = "".concat(anchor, ".extent_").concat(channel); - const offset = "".concat(sign).concat(delta, ".").concat(channel, " / ").concat(hasScales ? "".concat(sizeSg) : "span(".concat(extent, ")")); + const extent = `${anchor}.extent_${channel}`; + const offset = `${sign}${delta}.${channel} / ${hasScales ? `${sizeSg}` : `span(${extent})`}`; const panFn = !hasScales ? 'panLinear' : scaleType === 'log' ? 'panLog' : scaleType === 'symlog' ? 'panSymlog' : scaleType === 'pow' ? 'panPow' : 'panLinear'; - const arg = !hasScales ? '' : scaleType === 'pow' ? ", ".concat((_scaleCmpt$get = scaleCmpt.get('exponent')) !== null && _scaleCmpt$get !== void 0 ? _scaleCmpt$get : 1) : scaleType === 'symlog' ? ", ".concat((_scaleCmpt$get2 = scaleCmpt.get('constant')) !== null && _scaleCmpt$get2 !== void 0 ? _scaleCmpt$get2 : 1) : ''; - const update = "".concat(panFn, "(").concat(extent, ", ").concat(offset).concat(arg, ")"); + const arg = !hasScales ? '' : scaleType === 'pow' ? `, ${scaleCmpt.get('exponent') ?? 1}` : scaleType === 'symlog' ? `, ${scaleCmpt.get('constant') ?? 1}` : ''; + const update = `${panFn}(${extent}, ${offset}${arg})`; signal.on.push({ events: { signal: delta }, - update: hasScales ? update : "clampRange(".concat(update, ", 0, ").concat(sizeSg, ")") + update: hasScales ? update : `clampRange(${update}, 0, ${sizeSg})` }); } const ANCHOR = '_zoom_anchor'; const DELTA = '_zoom_delta'; @@ -12629,11 +12539,11 @@ signals.push({ name: name + ANCHOR, on: [{ events, - update: !hasScales ? "{x: x(unit), y: y(unit)}" : '{' + [sx ? "x: invert(".concat(sx, ", x(unit))") : '', sy ? "y: invert(".concat(sy, ", y(unit))") : ''].filter(expr => !!expr).join(', ') + '}' + update: !hasScales ? `{x: x(unit), y: y(unit)}` : '{' + [sx ? `x: invert(${sx}, x(unit))` : '', sy ? `y: invert(${sy}, y(unit))` : ''].filter(expr => !!expr).join(', ') + '}' }] }, { name: delta, on: [{ events, @@ -12653,30 +12563,28 @@ return signals; } }; function onDelta(model, selCmpt, proj, size, signals) { - var _scaleCmpt$get, _scaleCmpt$get2; - const name = selCmpt.name; const channel = proj.channel; const hasScales = scaleBindings.defined(selCmpt); const signal = signals.filter(s => s.name === proj.signals[hasScales ? 'data' : 'visual'])[0]; const sizeSg = model.getSizeSignalRef(size).signal; const scaleCmpt = model.getScaleComponent(channel); const scaleType = scaleCmpt.get('type'); const base = hasScales ? domain(model, channel) : signal.name; const delta = name + DELTA; - const anchor = "".concat(name).concat(ANCHOR, ".").concat(channel); + const anchor = `${name}${ANCHOR}.${channel}`; const zoomFn = !hasScales ? 'zoomLinear' : scaleType === 'log' ? 'zoomLog' : scaleType === 'symlog' ? 'zoomSymlog' : scaleType === 'pow' ? 'zoomPow' : 'zoomLinear'; - const arg = !hasScales ? '' : scaleType === 'pow' ? ", ".concat((_scaleCmpt$get = scaleCmpt.get('exponent')) !== null && _scaleCmpt$get !== void 0 ? _scaleCmpt$get : 1) : scaleType === 'symlog' ? ", ".concat((_scaleCmpt$get2 = scaleCmpt.get('constant')) !== null && _scaleCmpt$get2 !== void 0 ? _scaleCmpt$get2 : 1) : ''; - const update = "".concat(zoomFn, "(").concat(base, ", ").concat(anchor, ", ").concat(delta).concat(arg, ")"); + const arg = !hasScales ? '' : scaleType === 'pow' ? `, ${scaleCmpt.get('exponent') ?? 1}` : scaleType === 'symlog' ? `, ${scaleCmpt.get('constant') ?? 1}` : ''; + const update = `${zoomFn}(${base}, ${anchor}, ${delta}${arg})`; signal.on.push({ events: { signal: delta }, - update: hasScales ? update : "clampRange(".concat(update, ", 0, ").concat(sizeSg, ")") + update: hasScales ? update : `clampRange(${update}, 0, ${sizeSg})` }); } const STORE = '_store'; const TUPLE = '_tuple'; @@ -12711,21 +12619,19 @@ facet } = facetModel; for (const channel of FACET_CHANNELS) { if (facet[channel]) { - name += " + '__facet_".concat(channel, "_' + (facet[").concat(vega.stringValue(facetModel.vgField(channel)), "])"); + name += ` + '__facet_${channel}_' + (facet[${vega.stringValue(facetModel.vgField(channel))}])`; } } } return name; } function requiresSelectionId(model) { - var _model$component$sele; - - return vals((_model$component$sele = model.component.selection) !== null && _model$component$sele !== void 0 ? _model$component$sele : {}).reduce((identifier, selCmpt) => { + return vals(model.component.selection ?? {}).reduce((identifier, selCmpt) => { return identifier || selCmpt.project.hasSelectionId; }, false); } // Binding a point selection to query widgets or legends disables default direct manipulation interaction. // A user can choose to re-enable it by explicitly specifying triggering input events. @@ -12808,11 +12714,11 @@ expr: this.expr }; } hash() { - return "Filter ".concat(this.expr); + return `Filter ${this.expr}`; } } function parseUnitSelection(model, selDefs) { @@ -12844,13 +12750,11 @@ ...defaults[key] }; } if (defaults[key] === undefined || defaults[key] === true) { - var _cfg$key; - - defaults[key] = (_cfg$key = cfg[key]) !== null && _cfg$key !== void 0 ? _cfg$key : defaults[key]; + defaults[key] = cfg[key] ?? defaults[key]; } } const selCmpt = selCmpts[name] = { ...defaults, name, @@ -12878,29 +12782,29 @@ try { selCmpt = model.getSelectionComponent(vname, name); } catch (e) { // If a selection isn't found, treat as a variable parameter and coerce to boolean. - return "!!".concat(vname); + return `!!${vname}`; } if (selCmpt.project.timeUnit) { - const child = dfnode !== null && dfnode !== void 0 ? dfnode : model.component.data.raw; + const child = dfnode ?? model.component.data.raw; const tunode = selCmpt.project.timeUnit.clone(); if (child.parent) { tunode.insertAsParentOf(child); } else { child.parent = tunode; } } const fn = selCmpt.project.hasSelectionId ? 'vlSelectionIdTest(' : 'vlSelectionTest('; - const resolve = selCmpt.resolve === 'global' ? ')' : ", ".concat(vega.stringValue(selCmpt.resolve), ")"); - const test = "".concat(fn).concat(store, ", ").concat(datum).concat(resolve); - const length = "length(data(".concat(store, "))"); - return pred.empty === false ? "".concat(length, " && ").concat(test) : "!".concat(length, " || ").concat(test); + const resolve = selCmpt.resolve === 'global' ? ')' : `, ${vega.stringValue(selCmpt.resolve)})`; + const test = `${fn}${store}, ${datum}${resolve}`; + const length = `length(data(${store}))`; + return pred.empty === false ? `${length} && ${test}` : `!${length} || ${test}`; } function parseSelectionExtent(model, name, extent) { const vname = varName(name); const encoding = extent['encoding']; let field = extent['field']; @@ -12915,30 +12819,28 @@ if (!encoding && !field) { field = selCmpt.project.items[0].field; if (selCmpt.project.items.length > 1) { - warn('A "field" or "encoding" must be specified when using a selection as a scale domain. ' + "Using \"field\": ".concat(vega.stringValue(field), ".")); + warn('A "field" or "encoding" must be specified when using a selection as a scale domain. ' + `Using "field": ${vega.stringValue(field)}.`); } } else if (encoding && !field) { const encodings = selCmpt.project.items.filter(p => p.channel === encoding); if (!encodings.length || encodings.length > 1) { field = selCmpt.project.items[0].field; - warn((!encodings.length ? 'No ' : 'Multiple ') + "matching ".concat(vega.stringValue(encoding), " encoding found for selection ").concat(vega.stringValue(extent.param), ". ") + "Using \"field\": ".concat(vega.stringValue(field), ".")); + warn((!encodings.length ? 'No ' : 'Multiple ') + `matching ${vega.stringValue(encoding)} encoding found for selection ${vega.stringValue(extent.param)}. ` + `Using "field": ${vega.stringValue(field)}.`); } else { field = encodings[0].field; } } - return "".concat(selCmpt.name, "[").concat(vega.stringValue(replacePathInField(field)), "]"); + return `${selCmpt.name}[${vega.stringValue(replacePathInField(field))}]`; } function materializeSelections(model, main) { - for (const [selection, selCmpt] of entries$1((_model$component$sele = model.component.selection) !== null && _model$component$sele !== void 0 ? _model$component$sele : {})) { - var _model$component$sele; - - const lookupName = model.getName("lookup_".concat(selection)); + for (const [selection, selCmpt] of entries$1(model.component.selection ?? {})) { + const lookupName = model.getName(`lookup_${selection}`); model.component.data.outputNodes[lookupName] = selCmpt.materialized = new OutputNode(new FilterNode(main, model, { param: selection }), lookupName, DataSourceType.Lookup, model.component.data.outputNodeRefCounts); } } @@ -12972,16 +12874,14 @@ return title; } function setAxisEncode(axis, part, vgProp, vgRef) { - var _axis$encode, _axis$encode2, _axis$encode2$part, _axis$encode$part, _axis$encode$part$upd; + axis.encode ??= {}; + axis.encode[part] ??= {}; + axis.encode[part].update ??= {}; // TODO: remove as any after https://github.com/prisma/nexus-prisma/issues/291 - (_axis$encode = axis.encode) !== null && _axis$encode !== void 0 ? _axis$encode : axis.encode = {}; - (_axis$encode2$part = (_axis$encode2 = axis.encode)[part]) !== null && _axis$encode2$part !== void 0 ? _axis$encode2$part : _axis$encode2[part] = {}; - (_axis$encode$part$upd = (_axis$encode$part = axis.encode[part]).update) !== null && _axis$encode$part$upd !== void 0 ? _axis$encode$part$upd : _axis$encode$part.update = {}; // TODO: remove as any after https://github.com/prisma/nexus-prisma/issues/291 - axis.encode[part].update[vgProp] = vgRef; } function assembleAxis(axisCmpt, kind, config) { let opt = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : { @@ -13042,11 +12942,11 @@ signal: conditions.map(c => { const { test, ...valueOrSignalCRef } = c; - return "".concat(expression(null, test), " ? ").concat(exprFromValueRefOrSignalRef(valueOrSignalCRef), " : "); + return `${expression(null, test)} ? ${exprFromValueRefOrSignalRef(valueOrSignalCRef)} : `; }).join('') + exprFromValueRefOrSignalRef(valueOrSignalRef) }; axis[prop] = signalRef; } } else if (isSignalRef(propValue)) { @@ -13113,15 +13013,15 @@ // if mainExtracted has been extracted to a separate facet return undefined; } if (labelExpr !== undefined) { - var _axis$encode3, _axis$encode3$labels; + var _axis$encode, _axis$encode$labels; let expr = labelExpr; - if ((_axis$encode3 = axis.encode) !== null && _axis$encode3 !== void 0 && (_axis$encode3$labels = _axis$encode3.labels) !== null && _axis$encode3$labels !== void 0 && _axis$encode3$labels.update && isSignalRef(axis.encode.labels.update.text)) { + if ((_axis$encode = axis.encode) !== null && _axis$encode !== void 0 && (_axis$encode$labels = _axis$encode.labels) !== null && _axis$encode$labels !== void 0 && _axis$encode$labels.update && isSignalRef(axis.encode.labels.update.text)) { expr = replaceAll(labelExpr, 'datum.label', axis.encode.labels.update.text.signal); } setAxisEncode(axis, 'labels', 'text', { signal: expr @@ -13213,11 +13113,11 @@ const conditionalOrientAxisConfig = {}; for (const prop of props.values()) { conditionalOrientAxisConfig[prop] = { // orient is surely signal in this case - signal: "".concat(orient['signal'], " === \"").concat(orient1, "\" ? ").concat(signalOrStringValue(orientConfig1[prop]), " : ").concat(signalOrStringValue(orientConfig2[prop])) + signal: `${orient['signal']} === "${orient1}" ? ${signalOrStringValue(orientConfig1[prop])} : ${signalOrStringValue(orientConfig2[prop])}` }; } return conditionalOrientAxisConfig; } @@ -13227,11 +13127,11 @@ } function getAxisConfigs(channel, scaleType, orient, config) { const typeBasedConfigTypes = scaleType === 'band' ? ['axisDiscrete', 'axisBand'] : scaleType === 'point' ? ['axisDiscrete', 'axisPoint'] : isQuantitative(scaleType) ? ['axisQuantitative'] : scaleType === 'time' || scaleType === 'utc' ? ['axisTemporal'] : []; const axisChannel = channel === 'x' ? 'axisX' : 'axisY'; - const axisOrient = isSignalRef(orient) ? 'axisOrient' : "axis".concat(titleCase(orient)); // axisTop, axisBottom, ... + const axisOrient = isSignalRef(orient) ? 'axisOrient' : `axis${titleCase(orient)}`; // axisTop, axisBottom, ... const vlOnlyConfigTypes = [// technically Vega does have axisBand, but if we make another separation here, // it will further introduce complexity in the code ...typeBasedConfigTypes, ...typeBasedConfigTypes.map(c => axisChannel + c.substr(4))]; const vgConfigTypes = ['axis', axisOrient, axisChannel]; @@ -13316,18 +13216,16 @@ formatType } = axis; return guideFormatType(formatType, fieldOrDatumDef, scaleType); }, grid: _ref4 => { - var _axis$grid; - let { fieldOrDatumDef, axis, scaleType } = _ref4; - return (_axis$grid = axis.grid) !== null && _axis$grid !== void 0 ? _axis$grid : defaultGrid(scaleType, fieldOrDatumDef); + return axis.grid ?? defaultGrid(scaleType, fieldOrDatumDef); }, gridScale: _ref5 => { let { model, channel @@ -13358,50 +13256,44 @@ channel } = _ref8; return axis.labelBaseline || defaultLabelBaseline(labelAngle, orient, channel); }, labelFlush: _ref9 => { - var _axis$labelFlush; - let { axis, fieldOrDatumDef, channel } = _ref9; - return (_axis$labelFlush = axis.labelFlush) !== null && _axis$labelFlush !== void 0 ? _axis$labelFlush : defaultLabelFlush(fieldOrDatumDef.type, channel); + return axis.labelFlush ?? defaultLabelFlush(fieldOrDatumDef.type, channel); }, labelOverlap: _ref10 => { - var _axis$labelOverlap; - let { axis, fieldOrDatumDef, scaleType } = _ref10; - return (_axis$labelOverlap = axis.labelOverlap) !== null && _axis$labelOverlap !== void 0 ? _axis$labelOverlap : defaultLabelOverlap$1(fieldOrDatumDef.type, scaleType, isFieldDef(fieldOrDatumDef) && !!fieldOrDatumDef.timeUnit, isFieldDef(fieldOrDatumDef) ? fieldOrDatumDef.sort : undefined); + return axis.labelOverlap ?? defaultLabelOverlap$1(fieldOrDatumDef.type, scaleType, isFieldDef(fieldOrDatumDef) && !!fieldOrDatumDef.timeUnit, isFieldDef(fieldOrDatumDef) ? fieldOrDatumDef.sort : undefined); }, // we already calculate orient in parse orient: _ref11 => { let { orient } = _ref11; return orient; }, // Need to cast until Vega supports signal tickCount: _ref12 => { - var _axis$tickCount; - let { channel, model, axis, fieldOrDatumDef, scaleType } = _ref12; const sizeType = channel === 'x' ? 'width' : channel === 'y' ? 'height' : undefined; const size = sizeType ? model.getSizeSignalRef(sizeType) : undefined; - return (_axis$tickCount = axis.tickCount) !== null && _axis$tickCount !== void 0 ? _axis$tickCount : defaultTickCount({ + return axis.tickCount ?? defaultTickCount({ fieldOrDatumDef, scaleType, size, values: axis.values }); @@ -13435,18 +13327,16 @@ fieldOrDatumDef } = _ref14; return values$1(axis, fieldOrDatumDef); }, zindex: _ref15 => { - var _axis$zindex; - let { axis, fieldOrDatumDef, mark } = _ref15; - return (_axis$zindex = axis.zindex) !== null && _axis$zindex !== void 0 ? _axis$zindex : defaultZindex(mark, fieldOrDatumDef); + return axis.zindex ?? defaultZindex(mark, fieldOrDatumDef); } }; // TODO: we need to refactor this method after we take care of config refactoring /** * Default rules for whether to show a grid should be shown for a channel. @@ -13488,53 +13378,53 @@ return undefined; } } } function normalizeAngleExpr(angle) { - return "(((".concat(angle.signal, " % 360) + 360) % 360)"); + return `(((${angle.signal} % 360) + 360) % 360)`; } function defaultLabelBaseline(angle, orient, channel, alwaysIncludeMiddle) { if (angle !== undefined) { if (channel === 'x') { if (isSignalRef(angle)) { const a = normalizeAngleExpr(angle); - const orientIsTop = isSignalRef(orient) ? "(".concat(orient.signal, " === \"top\")") : orient === 'top'; + const orientIsTop = isSignalRef(orient) ? `(${orient.signal} === "top")` : orient === 'top'; return { - signal: "(45 < ".concat(a, " && ").concat(a, " < 135) || (225 < ").concat(a, " && ").concat(a, " < 315) ? \"middle\" :") + "(".concat(a, " <= 45 || 315 <= ").concat(a, ") === ").concat(orientIsTop, " ? \"bottom\" : \"top\"") + signal: `(45 < ${a} && ${a} < 135) || (225 < ${a} && ${a} < 315) ? "middle" :` + `(${a} <= 45 || 315 <= ${a}) === ${orientIsTop} ? "bottom" : "top"` }; } if (45 < angle && angle < 135 || 225 < angle && angle < 315) { return 'middle'; } if (isSignalRef(orient)) { const op = angle <= 45 || 315 <= angle ? '===' : '!=='; return { - signal: "".concat(orient.signal, " ").concat(op, " \"top\" ? \"bottom\" : \"top\"") + signal: `${orient.signal} ${op} "top" ? "bottom" : "top"` }; } return (angle <= 45 || 315 <= angle) === (orient === 'top') ? 'bottom' : 'top'; } else { if (isSignalRef(angle)) { const a = normalizeAngleExpr(angle); - const orientIsLeft = isSignalRef(orient) ? "(".concat(orient.signal, " === \"left\")") : orient === 'left'; + const orientIsLeft = isSignalRef(orient) ? `(${orient.signal} === "left")` : orient === 'left'; const middle = alwaysIncludeMiddle ? '"middle"' : 'null'; return { - signal: "".concat(a, " <= 45 || 315 <= ").concat(a, " || (135 <= ").concat(a, " && ").concat(a, " <= 225) ? ").concat(middle, " : (45 <= ").concat(a, " && ").concat(a, " <= 135) === ").concat(orientIsLeft, " ? \"top\" : \"bottom\"") + signal: `${a} <= 45 || 315 <= ${a} || (135 <= ${a} && ${a} <= 225) ? ${middle} : (45 <= ${a} && ${a} <= 135) === ${orientIsLeft} ? "top" : "bottom"` }; } if (angle <= 45 || 315 <= angle || 135 <= angle && angle <= 225) { return alwaysIncludeMiddle ? 'middle' : null; } if (isSignalRef(orient)) { const op = 45 <= angle && angle <= 135 ? '===' : '!=='; return { - signal: "".concat(orient.signal, " ").concat(op, " \"left\" ? \"top\" : \"bottom\"") + signal: `${orient.signal} ${op} "left" ? "top" : "bottom"` }; } return (45 <= angle && angle <= 135) === (orient === 'left') ? 'top' : 'bottom'; } @@ -13551,26 +13441,26 @@ const startAngle = isX ? 0 : 90; const mainOrient = isX ? 'bottom' : 'left'; if (isSignalRef(angle)) { const a = normalizeAngleExpr(angle); - const orientIsMain = isSignalRef(orient) ? "(".concat(orient.signal, " === \"").concat(mainOrient, "\")") : orient === mainOrient; + const orientIsMain = isSignalRef(orient) ? `(${orient.signal} === "${mainOrient}")` : orient === mainOrient; return { - signal: "(".concat(startAngle ? "(".concat(a, " + 90)") : a, " % 180 === 0) ? ").concat(isX ? null : '"center"', " :") + "(".concat(startAngle, " < ").concat(a, " && ").concat(a, " < ").concat(180 + startAngle, ") === ").concat(orientIsMain, " ? \"left\" : \"right\"") + signal: `(${startAngle ? `(${a} + 90)` : a} % 180 === 0) ? ${isX ? null : '"center"'} :` + `(${startAngle} < ${a} && ${a} < ${180 + startAngle}) === ${orientIsMain} ? "left" : "right"` }; } if ((angle + startAngle) % 180 === 0) { // For bottom, use default label align so label flush still works return isX ? null : 'center'; } if (isSignalRef(orient)) { const op = startAngle < angle && angle < 180 + startAngle ? '===' : '!=='; - const orientIsMain = "".concat(orient.signal, " ").concat(op, " \"").concat(mainOrient, "\""); + const orientIsMain = `${orient.signal} ${op} "${mainOrient}"`; return { - signal: "".concat(orientIsMain, " ? \"left\" : \"right\"") + signal: `${orientIsMain} ? "left" : "right"` }; } if ((startAngle < angle && angle < 180 + startAngle) === (orient === mainOrient)) { return 'left'; @@ -13613,21 +13503,21 @@ var _normalizeTimeUnit; if (isBinning(fieldOrDatumDef.bin)) { // for binned data, we don't want more ticks than maxbins return { - signal: "ceil(".concat(size.signal, "/10)") + signal: `ceil(${size.signal}/10)` }; } if (fieldOrDatumDef.timeUnit && contains(['month', 'hours', 'day', 'quarter'], (_normalizeTimeUnit = normalizeTimeUnit(fieldOrDatumDef.timeUnit)) === null || _normalizeTimeUnit === void 0 ? void 0 : _normalizeTimeUnit.unit)) { return undefined; } } return { - signal: "ceil(".concat(size.signal, "/40)") + signal: `ceil(${size.signal}/40)` }; } return undefined; } @@ -13700,15 +13590,15 @@ timeUnit } = fieldDef; const sort = fieldDef.sort; // generate `datum["a"] === val0 ? 0 : datum["a"] === val1 ? 1 : ... : n` via FieldEqualPredicate const calculate = sort.map((sortValue, i) => { - return "".concat(fieldFilterExpression({ - field, - timeUnit, - equal: sortValue - }), " ? ").concat(i, " : "); + return `${fieldFilterExpression({ + field, + timeUnit, + equal: sortValue + })} ? ${i} : `; }).join('') + sort.length; parent = new CalculateNode(parent, { calculate, as: sortArrayIndexField(fieldDef, channel, { forAs: true @@ -13734,19 +13624,19 @@ as: this.transform.as }; } hash() { - return "Calculate ".concat(hash(this.transform)); + return `Calculate ${hash(this.transform)}`; } } function sortArrayIndexField(fieldDef, channel, opt) { return vgField(fieldDef, { prefix: channel, suffix: 'sort_index', - ...(opt !== null && opt !== void 0 ? opt : {}) + ...(opt ?? {}) }); } /** * Get header channel, which can be different from facet channel when orient is specified or when the facet channel is facet. @@ -13798,13 +13688,13 @@ titleOrient } = getHeaderProperties(['titleAnchor', 'titleAngle', 'titleOrient'], facetFieldDef.header, config, channel); const headerChannel = getHeaderChannel(channel, titleOrient); const titleAngle = normalizeAngle(ta); return { - name: "".concat(channel, "-title"), + name: `${channel}-title`, type: 'group', - role: "".concat(headerChannel, "-title"), + role: `${headerChannel}-title`, title: { text: title, ...(channel === 'row' ? { orient: 'left' } : {}), @@ -13864,17 +13754,15 @@ const { sort } = facetFieldDef; if (isSortField(sort)) { - var _sort$order; - return { field: vgField(sort, { expr: 'datum' }), - order: (_sort$order = sort.order) !== null && _sort$order !== void 0 ? _sort$order : 'ascending' + order: sort.order ?? 'ascending' }; } else if (vega.isArray(sort)) { return { field: sortArrayIndexField(facetFieldDef, channel, { expr: 'datum' @@ -13884,11 +13772,11 @@ } else { return { field: vgField(facetFieldDef, { expr: 'datum' }), - order: sort !== null && sort !== void 0 ? sort : 'ascending' + order: sort ?? 'ascending' }; } } function assembleLabelTitle(facetFieldDef, channel, config) { @@ -13947,22 +13835,22 @@ const hasAxes = (axes === null || axes === void 0 ? void 0 : axes.length) > 0; if (title || hasAxes) { const sizeChannel = channel === 'row' ? 'height' : 'width'; return { - name: model.getName("".concat(channel, "_").concat(headerType)), + name: model.getName(`${channel}_${headerType}`), type: 'group', - role: "".concat(channel, "-").concat(headerType), + role: `${channel}-${headerType}`, ...(layoutHeader.facetFieldDef ? { from: { - data: model.getName("".concat(channel, "_domain")) + data: model.getName(`${channel}_domain`) }, sort: getSort$1(facetFieldDef, channel) } : {}), ...(hasAxes && isFacetWithoutRowCol ? { from: { - data: model.getName("facet_domain_".concat(channel)) + data: model.getName(`facet_domain_${channel}`) } } : {}), ...(title ? { title } : {}), @@ -14070,11 +13958,11 @@ } } return [stepSignal(scaleName, range), { name, - update: sizeExpr(scaleName, scaleComponent, "domain('".concat(scaleName, "').length")) + update: sizeExpr(scaleName, scaleComponent, `domain('${scaleName}').length`) }]; } } /* istanbul ignore next: Condition should not happen -- only for warning in development. */ @@ -14082,11 +13970,11 @@ throw new Error('layout size is step although width/height is not step.'); } else if (size == 'container') { const isWidth = name.endsWith('width'); const expr = isWidth ? 'containerSize()[0]' : 'containerSize()[1]'; const defaultValue = getViewConfigContinuousSize(model.config.view, isWidth ? 'width' : 'height'); - const safeExpr = "isFinite(".concat(expr, ") ? ").concat(expr, " : ").concat(defaultValue); + const safeExpr = `isFinite(${expr}) ? ${expr} : ${defaultValue}`; return [{ name, init: safeExpr, on: [{ update: safeExpr, @@ -14100,11 +13988,11 @@ }]; } } function stepSignal(scaleName, range) { - const name = "".concat(scaleName, "_step"); + const name = `${scaleName}_step`; if (isSignalRef(range.step)) { return { name, update: range.step.signal @@ -14124,11 +14012,11 @@ let paddingInner = scaleComponent.get('paddingInner'); paddingInner = type === 'band' ? // only band has real paddingInner paddingInner !== undefined ? paddingInner : padding : // For point, as calculated in https://github.com/vega/vega-scale/blob/master/src/band.js#L128, // it's equivalent to have paddingInner = 1 since there is only n-1 steps between n points. 1; - return "bandspace(".concat(cardinality, ", ").concat(signalOrStringValue(paddingInner), ", ").concat(signalOrStringValue(paddingOuter), ") * ").concat(scaleName, "_step"); + return `bandspace(${cardinality}, ${signalOrStringValue(paddingInner)}, ${signalOrStringValue(paddingOuter)}) * ${scaleName}_step`; } function getSizeTypeFromLayoutSizeType(layoutSizeType) { return layoutSizeType === 'childWidth' ? 'width' : layoutSizeType === 'childHeight' ? 'height' : layoutSizeType; } @@ -14193,12 +14081,10 @@ gradient, labels: labels$1, entries }; function symbols(symbolsSpec, _ref) { - var _legendCmpt$get, _legendCmpt$get2, _legendCmpt$get3, _getMaxValue; - let { fieldOrDatumDef, model, channel, legendCmpt, @@ -14220,14 +14106,14 @@ ...color(model, { filled }) }; // FIXME: remove this when VgEncodeEntry is compatible with SymbolEncodeEntry - const symbolOpacity = (_legendCmpt$get = legendCmpt.get('symbolOpacity')) !== null && _legendCmpt$get !== void 0 ? _legendCmpt$get : config.legend.symbolOpacity; - const symbolFillColor = (_legendCmpt$get2 = legendCmpt.get('symbolFillColor')) !== null && _legendCmpt$get2 !== void 0 ? _legendCmpt$get2 : config.legend.symbolFillColor; - const symbolStrokeColor = (_legendCmpt$get3 = legendCmpt.get('symbolStrokeColor')) !== null && _legendCmpt$get3 !== void 0 ? _legendCmpt$get3 : config.legend.symbolStrokeColor; - const opacity = symbolOpacity === undefined ? (_getMaxValue = getMaxValue(encoding.opacity)) !== null && _getMaxValue !== void 0 ? _getMaxValue : markDef.opacity : undefined; + const symbolOpacity = legendCmpt.get('symbolOpacity') ?? config.legend.symbolOpacity; + const symbolFillColor = legendCmpt.get('symbolFillColor') ?? config.legend.symbolFillColor; + const symbolStrokeColor = legendCmpt.get('symbolStrokeColor') ?? config.legend.symbolStrokeColor; + const opacity = symbolOpacity === undefined ? getMaxValue(encoding.opacity) ?? markDef.opacity : undefined; if (out.fill) { // for fill legend, we don't want any fill in symbol if (channel === 'fill' || filled && channel === COLOR) { delete out.fill; @@ -14235,20 +14121,16 @@ if (out.fill['field']) { // For others, set fill to some opaque value (or nothing if a color is already set) if (symbolFillColor) { delete out.fill; } else { - var _config$legend$symbol; - - out.fill = signalOrValueRef((_config$legend$symbol = config.legend.symbolBaseFillColor) !== null && _config$legend$symbol !== void 0 ? _config$legend$symbol : 'black'); - out.fillOpacity = signalOrValueRef(opacity !== null && opacity !== void 0 ? opacity : 1); + out.fill = signalOrValueRef(config.legend.symbolBaseFillColor ?? 'black'); + out.fillOpacity = signalOrValueRef(opacity ?? 1); } } else if (vega.isArray(out.fill)) { - var _ref2, _getFirstConditionVal, _encoding$fill; + const fill = getFirstConditionValue(encoding.fill ?? encoding.color) ?? markDef.fill ?? (filled && markDef.color); - const fill = (_ref2 = (_getFirstConditionVal = getFirstConditionValue((_encoding$fill = encoding.fill) !== null && _encoding$fill !== void 0 ? _encoding$fill : encoding.color)) !== null && _getFirstConditionVal !== void 0 ? _getFirstConditionVal : markDef.fill) !== null && _ref2 !== void 0 ? _ref2 : filled && markDef.color; - if (fill) { out.fill = signalOrValueRef(fill); } } } @@ -14277,11 +14159,11 @@ const condition = isFieldDef(fieldOrDatumDef) && selectedCondition(model, legendCmpt, fieldOrDatumDef); if (condition) { out.opacity = [{ test: condition, - ...signalOrValueRef(opacity !== null && opacity !== void 0 ? opacity : 1) + ...signalOrValueRef(opacity ?? 1) }, signalOrValueRef(config.legend.unselectedOpacity)]; } else if (opacity) { out.opacity = signalOrValueRef(opacity); } } @@ -14289,18 +14171,16 @@ out = { ...out, ...symbolsSpec }; return isEmpty(out) ? undefined : out; } - function gradient(gradientSpec, _ref3) { - var _legendCmpt$get4; - + function gradient(gradientSpec, _ref2) { let { model, legendType, legendCmpt - } = _ref3; + } = _ref2; if (legendType !== 'gradient') { return undefined; } @@ -14308,11 +14188,11 @@ config, markDef, encoding } = model; let out = {}; - const gradientOpacity = (_legendCmpt$get4 = legendCmpt.get('gradientOpacity')) !== null && _legendCmpt$get4 !== void 0 ? _legendCmpt$get4 : config.legend.gradientOpacity; + const gradientOpacity = legendCmpt.get('gradientOpacity') ?? config.legend.gradientOpacity; const opacity = gradientOpacity === undefined ? getMaxValue(encoding.opacity) || markDef.opacity : undefined; if (opacity) { // only apply opacity if it is neither zero or undefined out.opacity = signalOrValueRef(opacity); @@ -14321,17 +14201,17 @@ out = { ...out, ...gradientSpec }; return isEmpty(out) ? undefined : out; } - function labels$1(specifiedlabelsSpec, _ref4) { + function labels$1(specifiedlabelsSpec, _ref3) { let { fieldOrDatumDef, model, channel, legendCmpt - } = _ref4; + } = _ref3; const legend = model.legend(channel) || {}; const config = model.config; const condition = isFieldDef(fieldOrDatumDef) ? selectedCondition(model, legendCmpt, fieldOrDatumDef) : undefined; const opacity = condition ? [{ test: condition, @@ -14381,14 +14261,14 @@ } : {}), ...specifiedlabelsSpec }; return isEmpty(labelsSpec) ? undefined : labelsSpec; } - function entries(entriesSpec, _ref5) { + function entries(entriesSpec, _ref4) { let { legendCmpt - } = _ref5; + } = _ref4; const selections = legendCmpt.get('selections'); return selections !== null && selections !== void 0 && selections.length ? { ...entriesSpec, fill: { value: 'transparent' } @@ -14419,11 +14299,11 @@ const selections = legendCmpt.get('selections'); if (!(selections !== null && selections !== void 0 && selections.length)) return undefined; const field = vega.stringValue(fieldDef.field); return selections.map(name => { const store = vega.stringValue(varName(name) + STORE); - return "(!length(data(".concat(store, ")) || (").concat(name, "[").concat(field, "] && indexof(").concat(name, "[").concat(field, "], datum.value) >= 0))"); + return `(!length(data(${store})) || (${name}[${field}] && indexof(${name}[${field}], datum.value) >= 0))`; }).join(' || '); } const legendRules = { direction: _ref => { @@ -14454,54 +14334,48 @@ formatType } = legend; return guideFormatType(formatType, fieldOrDatumDef, scaleType); }, gradientLength: params => { - var _ref4, _legend$gradientLengt; - const { legend, legendConfig } = params; - return (_ref4 = (_legend$gradientLengt = legend.gradientLength) !== null && _legend$gradientLengt !== void 0 ? _legend$gradientLengt : legendConfig.gradientLength) !== null && _ref4 !== void 0 ? _ref4 : defaultGradientLength(params); + return legend.gradientLength ?? legendConfig.gradientLength ?? defaultGradientLength(params); }, - labelOverlap: _ref5 => { - var _ref6, _legend$labelOverlap; - + labelOverlap: _ref4 => { let { legend, legendConfig, scaleType - } = _ref5; - return (_ref6 = (_legend$labelOverlap = legend.labelOverlap) !== null && _legend$labelOverlap !== void 0 ? _legend$labelOverlap : legendConfig.labelOverlap) !== null && _ref6 !== void 0 ? _ref6 : defaultLabelOverlap(scaleType); + } = _ref4; + return legend.labelOverlap ?? legendConfig.labelOverlap ?? defaultLabelOverlap(scaleType); }, - symbolType: _ref7 => { - var _legend$symbolType; - + symbolType: _ref5 => { let { legend, markDef, channel, encoding - } = _ref7; - return (_legend$symbolType = legend.symbolType) !== null && _legend$symbolType !== void 0 ? _legend$symbolType : defaultSymbolType(markDef.type, channel, encoding.shape, markDef.shape); + } = _ref5; + return legend.symbolType ?? defaultSymbolType(markDef.type, channel, encoding.shape, markDef.shape); }, - title: _ref8 => { + title: _ref6 => { let { fieldOrDatumDef, config - } = _ref8; + } = _ref6; return title(fieldOrDatumDef, config, { allowDisabling: true }); }, - type: _ref9 => { + type: _ref7 => { let { legendType, scaleType, channel - } = _ref9; + } = _ref7; if (isColorChannel(channel) && isContinuousToContinuous(scaleType)) { if (legendType === 'gradient') { return undefined; } @@ -14510,15 +14384,15 @@ } return legendType; }, // depended by other property, let's define upfront - values: _ref10 => { + values: _ref8 => { let { fieldOrDatumDef, legend - } = _ref10; + } = _ref8; return values(legend, fieldOrDatumDef); } }; function values(legend, fieldOrDatumDef) { const vals = legend.values; @@ -14531,14 +14405,12 @@ return undefined; } function defaultSymbolType(mark, channel, shapeChannelDef, markShape) { if (channel !== 'shape') { - var _getFirstConditionVal; - // use the value from the shape encoding or the mark config if they exist - const shape = (_getFirstConditionVal = getFirstConditionValue(shapeChannelDef)) !== null && _getFirstConditionVal !== void 0 ? _getFirstConditionVal : markShape; + const shape = getFirstConditionValue(shapeChannelDef) ?? markShape; if (shape) { return shape; } } @@ -14569,16 +14441,16 @@ const { legend } = params; return getFirstDefined(legend.type, defaultType$1(params)); } - function defaultType$1(_ref11) { + function defaultType$1(_ref9) { let { channel, timeUnit, scaleType - } = _ref11; + } = _ref9; // Following the logic in https://github.com/vega/vega-parser/blob/master/src/parsers/legend.js if (isColorChannel(channel)) { if (contains(['quarter', 'month', 'day'], timeUnit)) { return 'symbol'; @@ -14589,20 +14461,18 @@ } } return 'symbol'; } - function getDirection(_ref12) { - var _ref13, _legend$direction; - + function getDirection(_ref10) { let { legendConfig, legendType, orient, legend - } = _ref12; - return (_ref13 = (_legend$direction = legend.direction) !== null && _legend$direction !== void 0 ? _legend$direction : legendConfig[legendType ? 'gradientDirection' : 'symbolDirection']) !== null && _ref13 !== void 0 ? _ref13 : defaultDirection(orient, legendType); + } = _ref10; + return legend.direction ?? legendConfig[legendType ? 'gradientDirection' : 'symbolDirection'] ?? defaultDirection(orient, legendType); } function defaultDirection(orient, legendType) { switch (orient) { case 'top': case 'bottom': @@ -14620,18 +14490,18 @@ // top-left / ... // For inner legend, uses compact layout like Tableau return legendType === 'gradient' ? 'horizontal' : undefined; } } - function defaultGradientLength(_ref14) { + function defaultGradientLength(_ref11) { let { legendConfig, model, direction, orient, scaleType - } = _ref14; + } = _ref11; const { gradientHorizontalMaxLength, gradientHorizontalMinLength, gradientVerticalMaxLength, gradientVerticalMinLength @@ -14654,11 +14524,11 @@ } function gradientLengthSignal(model, sizeType, min, max) { const sizeSignal = model.getSizeSignalRef(sizeType).signal; return { - signal: "clamp(".concat(sizeSignal, ", ").concat(min, ", ").concat(max, ")") + signal: `clamp(${sizeSignal}, ${min}, ${max})` }; } function defaultLabelOverlap(scaleType) { if (contains(['quantile', 'threshold', 'log', 'symlog'], scaleType)) { @@ -14748,11 +14618,11 @@ return value === (legend || {})[property]; } function parseLegendForChannel(model, channel) { - var _normalizeTimeUnit, _legend$encoding, _legend; + var _normalizeTimeUnit, _legend; let legend = model.legend(channel); const { markDef, encoding, @@ -14814,11 +14684,11 @@ legendCmpt.set(property, value, explicit); } } } - const legendEncoding = (_legend$encoding = (_legend = legend) === null || _legend === void 0 ? void 0 : _legend.encoding) !== null && _legend$encoding !== void 0 ? _legend$encoding : {}; + const legendEncoding = ((_legend = legend) === null || _legend === void 0 ? void 0 : _legend.encoding) ?? {}; const selections = legendCmpt.get('selections'); const legendEncode = {}; const legendEncodeParams = { fieldOrDatumDef, model, @@ -14826,19 +14696,17 @@ legendCmpt, legendType }; for (const part of ['labels', 'legend', 'title', 'symbols', 'gradient', 'entries']) { - var _legendEncoding$part; - - const legendEncodingPart = guideEncodeEntry((_legendEncoding$part = legendEncoding[part]) !== null && _legendEncoding$part !== void 0 ? _legendEncoding$part : {}, model); + const legendEncodingPart = guideEncodeEntry(legendEncoding[part] ?? {}, model); const value = part in legendEncodeRules ? legendEncodeRules[part](legendEncodingPart, legendEncodeParams) // apply rule : legendEncodingPart; // no rule -- just default values if (value !== undefined && !isEmpty(value)) { legendEncode[part] = { ...(selections !== null && selections !== void 0 && selections.length && isFieldDef(fieldOrDatumDef) ? { - name: "".concat(varName(fieldOrDatumDef.field), "_legend_").concat(part) + name: `${varName(fieldOrDatumDef.field)}_legend_${part}` } : {}), ...(selections !== null && selections !== void 0 && selections.length ? { interactive: !!selections } : {}), update: value @@ -14959,16 +14827,14 @@ return st1; } function setLegendEncode(legend, part, vgProp, vgRef) { - var _legend$encode, _legend$encode2, _legend$encode2$part, _legend$encode$part, _legend$encode$part$u; + legend.encode ??= {}; + legend.encode[part] ??= {}; + legend.encode[part].update ??= {}; // TODO: remove as any after https://github.com/prisma/nexus-prisma/issues/291 - (_legend$encode = legend.encode) !== null && _legend$encode !== void 0 ? _legend$encode : legend.encode = {}; - (_legend$encode2$part = (_legend$encode2 = legend.encode)[part]) !== null && _legend$encode2$part !== void 0 ? _legend$encode2$part : _legend$encode2[part] = {}; - (_legend$encode$part$u = (_legend$encode$part = legend.encode[part]).update) !== null && _legend$encode$part$u !== void 0 ? _legend$encode$part$u : _legend$encode$part.update = {}; // TODO: remove as any after https://github.com/prisma/nexus-prisma/issues/291 - legend.encode[part].update[vgProp] = vgRef; } function assembleLegends(model) { const legendComponentIndex = model.component.legends; @@ -14994,11 +14860,11 @@ const legends = vals(legendByDomain).flat().map(l => assembleLegend(l, model.config)).filter(l => l !== undefined); return legends; } function assembleLegend(legendCmpt, config) { - var _legend$encode3; + var _legend$encode; const { disable, labelExpr, selections, @@ -15011,11 +14877,11 @@ if (config.aria === false && legend.aria == undefined) { legend.aria = false; } - if ((_legend$encode3 = legend.encode) !== null && _legend$encode3 !== void 0 && _legend$encode3.symbols) { + if ((_legend$encode = legend.encode) !== null && _legend$encode !== void 0 && _legend$encode.symbols) { const out = legend.encode.symbols.update; if (out.fill && out.fill['value'] !== 'transparent' && !out.stroke && !legend.stroke) { // For non color channel's legend, we need to override symbol stroke config from Vega config if stroke channel is not used. out.stroke = { @@ -15035,15 +14901,15 @@ // title schema doesn't include null, '' delete legend.title; } if (labelExpr !== undefined) { - var _legend$encode4, _legend$encode4$label; + var _legend$encode2, _legend$encode2$label; let expr = labelExpr; - if ((_legend$encode4 = legend.encode) !== null && _legend$encode4 !== void 0 && (_legend$encode4$label = _legend$encode4.labels) !== null && _legend$encode4$label !== void 0 && _legend$encode4$label.update && isSignalRef(legend.encode.labels.update.text)) { + if ((_legend$encode2 = legend.encode) !== null && _legend$encode2 !== void 0 && (_legend$encode2$label = _legend$encode2.labels) !== null && _legend$encode2$label !== void 0 && _legend$encode2$label.update && isSignalRef(legend.encode.labels.update.text)) { expr = replaceAll(labelExpr, 'datum.label', legend.encode.labels.update.text.signal); } setLegendEncode(legend, 'labels', 'text', { signal: expr @@ -15091,14 +14957,14 @@ ...projection }]; } else { // generate projection that uses extent fitting const size = { - signal: "[".concat(component.size.map(ref => ref.signal).join(', '), "]") + signal: `[${component.size.map(ref => ref.signal).join(', ')}]` }; const fits = component.data.reduce((sources, data) => { - const source = isSignalRef(data) ? data.signal : "data('".concat(model.lookupDataSource(data), "')"); + const source = isSignalRef(data) ? data.signal : `data('${model.lookupDataSource(data)}')`; if (!contains(sources, source)) { // build a unique list of sources sources.push(source); } @@ -15112,11 +14978,11 @@ return [{ name, size, fit: { - signal: fits.length > 1 ? "[".concat(fits.join(', '), "]") : fits[0] + signal: fits.length > 1 ? `[${fits.join(', ')}]` : fits[0] }, ...projection }]; } } @@ -15155,18 +15021,16 @@ model.component.projection = isUnitModel(model) ? parseUnitProjection(model) : parseNonUnitProjections(model); } function parseUnitProjection(model) { if (model.hasProjection) { - var _replaceExprRef; - const proj = replaceExprRef(model.specifiedProjection); const fit = !(proj && (proj.scale != null || proj.translate != null)); const size = fit ? [model.getSizeSignalRef('width'), model.getSizeSignalRef('height')] : undefined; const data = fit ? gatherFitData(model) : undefined; - const projComp = new ProjectionComponent(model.projectionName(true), { ...((_replaceExprRef = replaceExprRef(model.config.projection)) !== null && _replaceExprRef !== void 0 ? _replaceExprRef : {}), - ...(proj !== null && proj !== void 0 ? proj : {}) + const projComp = new ProjectionComponent(model.projectionName(true), { ...(replaceExprRef(model.config.projection) ?? {}), + ...(proj ?? {}) }, size, data); if (!projComp.get('type')) { projComp.set('type', 'equalEarth', false); } @@ -15184,18 +15048,18 @@ } = model; for (const posssiblePair of [[LONGITUDE, LATITUDE], [LONGITUDE2, LATITUDE2]]) { if (getFieldOrDatumDef(encoding[posssiblePair[0]]) || getFieldOrDatumDef(encoding[posssiblePair[1]])) { data.push({ - signal: model.getName("geojson_".concat(data.length)) + signal: model.getName(`geojson_${data.length}`) }); } } if (model.channelHasField(SHAPE) && model.typedFieldDef(SHAPE).type === GEOJSON) { data.push({ - signal: model.getName("geojson_".concat(data.length)) + signal: model.getName(`geojson_${data.length}`) }); } if (data.length === 0) { // main source is geojson, so we can just use that @@ -15293,14 +15157,12 @@ return undefined; } function rangeFormula(model, fieldDef, channel, config) { if (binRequiresRange(fieldDef, channel)) { - var _ref, _model$axis; - // read format from axis or legend, if there is no format then use config.numberFormat - const guide = isUnitModel(model) ? (_ref = (_model$axis = model.axis(channel)) !== null && _model$axis !== void 0 ? _model$axis : model.legend(channel)) !== null && _ref !== void 0 ? _ref : {} : {}; + const guide = isUnitModel(model) ? model.axis(channel) ?? model.legend(channel) ?? {} : {}; const startField = vgField(fieldDef, { expr: 'datum' }); const endField = vgField(fieldDef, { expr: 'datum', @@ -15317,26 +15179,24 @@ return {}; } function binKey(bin, field) { - return "".concat(binToString(bin), "_").concat(field); + return `${binToString(bin)}_${field}`; } function getSignalsFromModel(model, key) { return { - signal: model.getName("".concat(key, "_bins")), - extentSignal: model.getName("".concat(key, "_extent")) + signal: model.getName(`${key}_bins`), + extentSignal: model.getName(`${key}_extent`) }; } function getBinSignalName(model, field, bin) { - var _normalizeBin; - - const normalizedBin = (_normalizeBin = normalizeBin(bin, undefined)) !== null && _normalizeBin !== void 0 ? _normalizeBin : {}; + const normalizedBin = normalizeBin(bin, undefined) ?? {}; const key = binKey(normalizedBin, field); - return model.getName("".concat(key, "_bins")); + return model.getName(`${key}_bins`); } function isBinTransform(t) { return 'as' in t; } @@ -15344,11 +15204,11 @@ function createBinComponent(t, bin, model) { let as; let span; if (isBinTransform(t)) { - as = vega.isString(t.as) ? [t.as, "".concat(t.as, "_end")] : [t.as[0], t.as[1]]; + as = vega.isString(t.as) ? [t.as, `${t.as}_end`] : [t.as[0], t.as[1]]; } else { as = [vgField(t, { forAs: true }), vgField(t, { binSuffix: 'end', @@ -15469,11 +15329,11 @@ dependentFields() { return new Set(vals(this.bins).map(c => c.field)); } hash() { - return "Bin ".concat(hash(this.bins)); + return `Bin ${hash(this.bins)}`; } assemble() { return vals(this.bins).flatMap(bin => { const transform = []; @@ -15492,11 +15352,11 @@ } : { extent: null }), ...(bin.span ? { span: { - signal: "span(".concat(bin.span, ")") + signal: `span(${bin.span})` } } : {}), ...params }; @@ -15576,14 +15436,12 @@ // when we merge a measure, we either have to add an aggregation operator or even a new field const ops = childMeasures[field]; for (const op of keys(ops)) { if (field in parentMeasures) { - var _parentMeasures$field; - // add operator to existing measure field - parentMeasures[field][op] = new Set([...((_parentMeasures$field = parentMeasures[field][op]) !== null && _parentMeasures$field !== void 0 ? _parentMeasures$field : []), ...ops[op]]); + parentMeasures[field][op] = new Set([...(parentMeasures[field][op] ?? []), ...ops[op]]); } else { parentMeasures[field] = { [op]: ops[op] }; } @@ -15632,43 +15490,35 @@ field } = fieldDef; if (aggregate) { if (aggregate === 'count') { - var _, _meas$_; - - (_meas$_ = meas[_ = '*']) !== null && _meas$_ !== void 0 ? _meas$_ : meas[_] = {}; + meas['*'] ??= {}; meas['*']['count'] = new Set([vgField(fieldDef, { forAs: true })]); } else { if (isArgminDef(aggregate) || isArgmaxDef(aggregate)) { - var _meas$argField; - const op = isArgminDef(aggregate) ? 'argmin' : 'argmax'; const argField = aggregate[op]; - (_meas$argField = meas[argField]) !== null && _meas$argField !== void 0 ? _meas$argField : meas[argField] = {}; + meas[argField] ??= {}; meas[argField][op] = new Set([vgField({ op, field: argField }, { forAs: true })]); } else { - var _meas$field; - - (_meas$field = meas[field]) !== null && _meas$field !== void 0 ? _meas$field : meas[field] = {}; + meas[field] ??= {}; meas[field][aggregate] = new Set([vgField(fieldDef, { forAs: true })]); } // For scale channel with domain === 'unaggregated', add min/max so we can use their union as unaggregated domain if (isScaleChannel(channel) && model.scaleDomain(channel) === 'unaggregated') { - var _meas$field2; - - (_meas$field2 = meas[field]) !== null && _meas$field2 !== void 0 ? _meas$field2 : meas[field] = {}; + meas[field] ??= {}; meas[field]['min'] = new Set([vgField({ field, aggregate: 'min' }, { forAs: true @@ -15704,30 +15554,24 @@ as } = s; if (op) { if (op === 'count') { - var _2, _meas$_2; - - (_meas$_2 = meas[_2 = '*']) !== null && _meas$_2 !== void 0 ? _meas$_2 : meas[_2] = {}; + meas['*'] ??= {}; meas['*']['count'] = new Set([as ? as : vgField(s, { forAs: true })]); } else { - var _meas$field3; - - (_meas$field3 = meas[field]) !== null && _meas$field3 !== void 0 ? _meas$field3 : meas[field] = {}; + meas[field] ??= {}; meas[field][op] = new Set([as ? as : vgField(s, { forAs: true })]); } } } - for (const s of (_t$groupby = t.groupby) !== null && _t$groupby !== void 0 ? _t$groupby : []) { - var _t$groupby; - + for (const s of t.groupby ?? []) { dims.add(s); } if (dims.size + keys(meas).length === 0) { return null; @@ -15760,25 +15604,25 @@ for (const field of keys(this.measures)) { for (const op of keys(this.measures[field])) { const m = this.measures[field][op]; if (m.size === 0) { - out.add("".concat(op, "_").concat(field)); + out.add(`${op}_${field}`); } else { m.forEach(out.add, out); } } } return out; } hash() { - return "Aggregate ".concat(hash({ - dimensions: this.dimensions, - measures: this.measures - })); + return `Aggregate ${hash({ + dimensions: this.dimensions, + measures: this.measures + })}`; } assemble() { const ops = []; const fields = []; @@ -15836,11 +15680,11 @@ const { bin, sort } = fieldDef; this[channel] = { - name: model.getName("".concat(channel, "_domain")), + name: model.getName(`${channel}_domain`), fields: [vgField(fieldDef), ...(isBinning(bin) ? [vgField(fieldDef, { binSuffix: 'end' })] : [])], ...(isSortField(sort) ? { sortField: sort @@ -15853,15 +15697,15 @@ this.childModel = model.child; } hash() { - let out = "Facet"; + let out = `Facet`; for (const channel of FACET_CHANNELS) { if (this[channel]) { - out += " ".concat(channel.charAt(0), ":").concat(hash(this[channel])); + out += ` ${channel.charAt(0)}:${hash(this[channel])}`; } } return out; } @@ -15948,20 +15792,20 @@ const as = []; if (childChannel && childIndependentFieldsWithStep && childIndependentFieldsWithStep[childChannel]) { if (crossedDataName) { // If there is a crossed data, calculate max - fields.push("distinct_".concat(childIndependentFieldsWithStep[childChannel])); + fields.push(`distinct_${childIndependentFieldsWithStep[childChannel]}`); ops.push('max'); } else { // If there is no crossed data, just calculate distinct fields.push(childIndependentFieldsWithStep[childChannel]); ops.push('distinct'); } // Although it is technically a max, just name it distinct so it's easier to refer to it - as.push("distinct_".concat(childIndependentFieldsWithStep[childChannel])); + as.push(`distinct_${childIndependentFieldsWithStep[childChannel]}`); } const { sortField, sortIndexField @@ -15984,11 +15828,11 @@ } return { name: this[channel].name, // Use data from the crossed one if it exist - source: crossedDataName !== null && crossedDataName !== void 0 ? crossedDataName : this.data, + source: crossedDataName ?? this.data, transform: [{ type: 'aggregate', groupby: this[channel].fields, ...(fields.length ? { fields, @@ -16009,14 +15853,12 @@ const data = []; const hasSharedAxis = {}; for (const headerChannel of HEADER_CHANNELS) { for (const headerType of HEADER_TYPES) { - var _ref; + const headers = (layoutHeaders[headerChannel] && layoutHeaders[headerChannel][headerType]) ?? []; - const headers = (_ref = layoutHeaders[headerChannel] && layoutHeaders[headerChannel][headerType]) !== null && _ref !== void 0 ? _ref : []; - for (const header of headers) { var _header$axes; if (((_header$axes = header.axes) === null || _header$axes === void 0 ? void 0 : _header$axes.length) > 0) { hasSharedAxis[headerChannel] = true; @@ -16024,20 +15866,20 @@ } } } if (hasSharedAxis[headerChannel]) { - const cardinality = "length(data(\"".concat(this.facet.name, "\"))"); + const cardinality = `length(data("${this.facet.name}"))`; const stop = headerChannel === 'row' ? columns ? { - signal: "ceil(".concat(cardinality, " / ").concat(columns, ")") + signal: `ceil(${cardinality} / ${columns})` } : 1 : columns ? { - signal: "min(".concat(cardinality, ", ").concat(columns, ")") + signal: `min(${cardinality}, ${columns})` } : { signal: cardinality }; data.push({ - name: "".concat(this.facet.name, "_").concat(headerChannel), + name: `${this.facet.name}_${headerChannel}`, transform: [{ type: 'sequence', start: 0, stop }] @@ -16066,15 +15908,13 @@ row, facet } = this; if (column && row && (childIndependentFieldsWithStep.x || childIndependentFieldsWithStep.y)) { - var _childIndependentFiel, _childIndependentFiel2; - // Need to create a cross dataset to correctly calculate cardinality - crossedDataName = "cross_".concat(this.column.name, "_").concat(this.row.name); - const fields = [].concat((_childIndependentFiel = childIndependentFieldsWithStep.x) !== null && _childIndependentFiel !== void 0 ? _childIndependentFiel : [], (_childIndependentFiel2 = childIndependentFieldsWithStep.y) !== null && _childIndependentFiel2 !== void 0 ? _childIndependentFiel2 : []); + crossedDataName = `cross_${this.column.name}_${this.row.name}`; + const fields = [].concat(childIndependentFieldsWithStep.x ?? [], childIndependentFieldsWithStep.y ?? []); const ops = fields.map(() => 'distinct'); data.push({ name: crossedDataName, source: this.data, transform: [{ @@ -16124,25 +15964,25 @@ function parseExpression(field, parse) { const f = accessPathWithDatum(field); if (parse === 'number') { - return "toNumber(".concat(f, ")"); + return `toNumber(${f})`; } else if (parse === 'boolean') { - return "toBoolean(".concat(f, ")"); + return `toBoolean(${f})`; } else if (parse === 'string') { - return "toString(".concat(f, ")"); + return `toString(${f})`; } else if (parse === 'date') { - return "toDate(".concat(f, ")"); + return `toDate(${f})`; } else if (parse === 'flatten') { return f; } else if (parse.startsWith('date:')) { const specifier = unquote(parse.slice(5, parse.length)); - return "timeParse(".concat(f, ",'").concat(specifier, "')"); + return `timeParse(${f},'${specifier}')`; } else if (parse.startsWith('utc:')) { const specifier = unquote(parse.slice(4, parse.length)); - return "utcParse(".concat(f, ",'").concat(specifier, "')"); + return `utcParse(${f},'${specifier}')`; } else { warn(unrecognizedParse(parse)); return null; } } @@ -16167,13 +16007,11 @@ } else if (isFieldGTEPredicate(filter)) { val = signalRefOrValue(filter.gte); } else if (isFieldRangePredicate(filter)) { val = filter.range[0]; } else if (isFieldOneOfPredicate(filter)) { - var _filter$oneOf; - - val = ((_filter$oneOf = filter.oneOf) !== null && _filter$oneOf !== void 0 ? _filter$oneOf : filter['in'])[0]; + val = (filter.oneOf ?? filter['in'])[0]; } // else -- for filter expression, we can't infer anything if (val) { if (isDateTime(val)) { @@ -16288,11 +16126,11 @@ this._parse = parse; } hash() { - return "Parse ".concat(hash(this._parse)); + return `Parse ${hash(this._parse)}`; } /** * Creates a parse node from a data.format.parse and updates ancestorParse. */ @@ -16470,11 +16308,11 @@ producedFields() { return undefined; // there should never be a node before graticule } hash() { - return "Graticule ".concat(hash(this.params)); + return `Graticule ${hash(this.params)}`; } assemble() { return { type: 'graticule', @@ -16497,17 +16335,15 @@ dependentFields() { return new Set(); } producedFields() { - var _this$params$as; - - return new Set([(_this$params$as = this.params.as) !== null && _this$params$as !== void 0 ? _this$params$as : 'data']); + return new Set([this.params.as ?? 'data']); } hash() { - return "Hash ".concat(hash(this.params)); + return `Hash ${hash(this.params)}`; } assemble() { return { type: 'sequence', @@ -16517,21 +16353,19 @@ } class SourceNode extends DataFlowNode { constructor(data) { - var _data; - super(null); // source cannot have parent _defineProperty(this, "_data", void 0); _defineProperty(this, "_name", void 0); _defineProperty(this, "_generator", void 0); - (_data = data) !== null && _data !== void 0 ? _data : data = { + data ??= { name: 'source' }; let format; if (!isGenerator(data)) { @@ -17161,17 +16995,15 @@ producedFields() { return new Set(this.transform.joinaggregate.map(this.getDefaultName)); } getDefaultName(joinAggregateFieldDef) { - var _joinAggregateFieldDe; - - return (_joinAggregateFieldDe = joinAggregateFieldDef.as) !== null && _joinAggregateFieldDe !== void 0 ? _joinAggregateFieldDe : vgField(joinAggregateFieldDef); + return joinAggregateFieldDef.as ?? vgField(joinAggregateFieldDef); } hash() { - return "JoinAggregateTransform ".concat(hash(this.transform)); + return `JoinAggregateTransform ${hash(this.transform)}`; } assemble() { const fields = []; const ops = []; @@ -17252,13 +17084,13 @@ let normalizedAs; if (isValidAsArray(as)) { normalizedAs = as; } else if (vega.isString(as)) { - normalizedAs = [as, "".concat(as, "_end")]; + normalizedAs = [as, `${as}_end`]; } else { - normalizedAs = ["".concat(stackTransform.stack, "_start"), "".concat(stackTransform.stack, "_end")]; + normalizedAs = [`${stackTransform.stack}_start`, `${stackTransform.stack}_end`]; } return new StackNode(parent, { dimensionFieldDefs: [], stackField: stack, @@ -17350,11 +17182,11 @@ producedFields() { return new Set(this._stack.as); } hash() { - return "Stack ".concat(hash(this._stack)); + return `Stack ${hash(this._stack)}`; } getGroupbyFields() { const { dimensionFieldDefs, @@ -17381,11 +17213,11 @@ return [vgField(dimensionFieldDef)]; }).flat(); } - return groupby !== null && groupby !== void 0 ? groupby : []; + return groupby ?? []; } assemble() { const transform = []; const { @@ -17416,11 +17248,11 @@ expr: 'datum', binSuffix: 'end' }); transform.push({ type: 'formula', - expr: "".concat(bandPosition, "*").concat(binStart, "+").concat(1 - bandPosition, "*").concat(binEnd), + expr: `${bandPosition}*${binStart}+${1 - bandPosition}*${binEnd}`, as: vgField(dimensionFieldDef, { binSuffix: 'mid', forAs: true }) }); @@ -17470,31 +17302,27 @@ addDimensions(fields) { this.transform.groupby = unique(this.transform.groupby.concat(fields), d => d); } dependentFields() { - var _this$transform$group, _this$transform$sort; - const out = new Set(); - ((_this$transform$group = this.transform.groupby) !== null && _this$transform$group !== void 0 ? _this$transform$group : []).forEach(out.add, out); - ((_this$transform$sort = this.transform.sort) !== null && _this$transform$sort !== void 0 ? _this$transform$sort : []).forEach(m => out.add(m.field)); + (this.transform.groupby ?? []).forEach(out.add, out); + (this.transform.sort ?? []).forEach(m => out.add(m.field)); this.transform.window.map(w => w.field).filter(f => f !== undefined).forEach(out.add, out); return out; } producedFields() { return new Set(this.transform.window.map(this.getDefaultName)); } getDefaultName(windowFieldDef) { - var _windowFieldDef$as; - - return (_windowFieldDef$as = windowFieldDef.as) !== null && _windowFieldDef$as !== void 0 ? _windowFieldDef$as : vgField(windowFieldDef); + return windowFieldDef.as ?? vgField(windowFieldDef); } hash() { - return "WindowTransform ".concat(hash(this.transform)); + return `WindowTransform ${hash(this.transform)}`; } assemble() { const fields = []; const ops = []; @@ -17527,14 +17355,12 @@ const sortFields = []; const sortOrder = []; if (this.transform.sort !== undefined) { for (const sortField of this.transform.sort) { - var _sortField$order; - sortFields.push(sortField.field); - sortOrder.push((_sortField$order = sortField.order) !== null && _sortField$order !== void 0 ? _sortField$order : 'ascending'); + sortOrder.push(sortField.order ?? 'ascending'); } } const sort = { field: sortFields, @@ -17736,11 +17562,11 @@ checkLinks(data.sources); if (Math.max(firstPassCounter, secondPassCounter) === MAX_OPTIMIZATION_RUNS) { - warn("Maximum optimization runs(".concat(MAX_OPTIMIZATION_RUNS, ") reached.")); + warn(`Maximum optimization runs(${MAX_OPTIMIZATION_RUNS}) reached.`); } } /** * A class that behaves like a SignalRef but lazily generates the signal. @@ -17908,11 +17734,11 @@ const data = valueExpr(v, { timeUnit, type }); return { - signal: "{data: ".concat(data, "}") + signal: `{data: ${data}}` }; }); } function convertDomainIfItIsDateTime(domain, type, timeUnit) { @@ -17939,11 +17765,11 @@ const timeUnit = fieldOrDatumDef['timeUnit']; if (isDomainUnionWith(domain)) { const defaultDomain = parseSingleChannelDomain(scaleType, undefined, model, channel); const unionWith = convertDomainIfItIsDateTime(domain.unionWith, type, timeUnit); - return makeExplicit([...defaultDomain.value, ...unionWith]); + return makeExplicit([...unionWith, ...defaultDomain.value]); } else if (isSignalRef(domain)) { return makeExplicit([domain]); } else if (domain && domain !== 'unaggregated' && !isParameterDomain(domain)) { return makeExplicit(convertDomainIfItIsDateTime(domain, type, timeUnit)); } @@ -18028,11 +17854,11 @@ if (isBinning(bin)) { const binSignal = getBinSignalName(model, fieldDef.field, bin); return makeImplicit([new SignalRefWrapper(() => { const signal = model.getSignalName(binSignal); - return "[".concat(signal, ".start, ").concat(signal, ".stop]"); + return `[${signal}.start, ${signal}.stop]`; })]); } else { return makeImplicit([{ data: model.requestDataName(DataSourceType.Main), field: model.vgField(channel, {}) @@ -18072,11 +17898,11 @@ field, order } = sort; return { // Apply default op - op: op !== null && op !== void 0 ? op : isStackedMeasure ? 'sum' : DEFAULT_SORT_OP, + op: op ?? (isStackedMeasure ? 'sum' : DEFAULT_SORT_OP), // flatten nested fields ...(field ? { field: replacePathInField(field) } : {}), ...(order ? { @@ -18096,11 +17922,11 @@ if (domain || extent) { // As scale parsing occurs before selection parsing, we cannot set // domainRaw directly. So instead, we store the selectionExtent on // the scale component, and then add domainRaw during scale assembly. - scale.set('selectionExtent', domain !== null && domain !== void 0 ? domain : extent, true); + scale.set('selectionExtent', domain ?? extent, true); } } function domainSort(model, channel, scaleType) { if (!hasDiscreteDomain(scaleType)) { @@ -18445,11 +18271,11 @@ if (isXorY(channel)) { if (isVgRangeStep(scaleRange)) { // For width/height step, use a signal created in layout assemble instead of a constant step. return { step: { - signal: "".concat(scaleName, "_step") + signal: `${scaleName}_step` } }; } } else if (vega.isObject(scaleRange) && isDataRefDomain(scaleRange)) { return { ...scaleRange, @@ -18520,20 +18346,20 @@ const sizeSignal = model.getName(sizeType); if (vega.isObject(bin) && bin.binned && bin.step !== undefined) { return new SignalRefWrapper(() => { const scaleName = model.scaleName(channel); - const binCount = "(domain(\"".concat(scaleName, "\")[1] - domain(\"").concat(scaleName, "\")[0]) / ").concat(bin.step); - return "".concat(model.getSignalName(sizeSignal), " / (").concat(binCount, ")"); + const binCount = `(domain("${scaleName}")[1] - domain("${scaleName}")[0]) / ${bin.step}`; + return `${model.getSignalName(sizeSignal)} / (${binCount})`; }); } else if (isBinning(bin)) { const binSignal = getBinSignalName(model, field, bin); // TODO: extract this to be range step signal return new SignalRefWrapper(() => { const updatedName = model.getSignalName(binSignal); - const binCount = "(".concat(updatedName, ".stop - ").concat(updatedName, ".start) / ").concat(updatedName, ".step"); - return "".concat(model.getSignalName(sizeSignal), " / (").concat(binCount, ")"); + const binCount = `(${updatedName}.stop - ${updatedName}.start) / ${updatedName}.step`; + return `${model.getSignalName(sizeSignal)} / (${binCount})`; }); } } return undefined; @@ -18640,11 +18466,11 @@ } = specifiedScale; const d = defaultRange(channel, model); if ((rangeMin !== undefined || rangeMax !== undefined) && // it's ok to check just rangeMin's compatibility since rangeMin/rangeMax are the same scaleTypeSupportProperty(scaleType, 'rangeMin') && vega.isArray(d) && d.length === 2) { - return makeExplicit([rangeMin !== null && rangeMin !== void 0 ? rangeMin : d[0], rangeMax !== null && rangeMax !== void 0 ? rangeMax : d[1]]); + return makeExplicit([rangeMin ?? d[0], rangeMax ?? d[1]]); } return makeImplicit(d); } @@ -18738,11 +18564,11 @@ { // max radius = half od min(width,height) return [0, new SignalRefWrapper(() => { const w = model.getSignalName('width'); const h = model.getSignalName('height'); - return "min(".concat(w, ",").concat(h, ")/2"); + return `min(${w},${h})/2`; })]; } case STROKEWIDTH: // TODO: support custom rangeMin, rangeMax @@ -18788,27 +18614,23 @@ step, offsetIsDiscrete: isFieldOrDatumDef(offsetDef) && isDiscrete$1(offsetDef.type) }); if (stepFor === 'offset' && channelHasFieldOrDatum(encoding, offsetChannel)) { - var _mergedScaleCmpt$get; - const offsetScaleCmpt = model.getScaleComponent(offsetChannel); const offsetScaleName = model.scaleName(offsetChannel); - let stepCount = "domain('".concat(offsetScaleName, "').length"); + let stepCount = `domain('${offsetScaleName}').length`; if (offsetScaleCmpt.get('type') === 'band') { - var _ref, _offsetScaleCmpt$get, _ref2, _offsetScaleCmpt$get2; - - const offsetPaddingInner = (_ref = (_offsetScaleCmpt$get = offsetScaleCmpt.get('paddingInner')) !== null && _offsetScaleCmpt$get !== void 0 ? _offsetScaleCmpt$get : offsetScaleCmpt.get('padding')) !== null && _ref !== void 0 ? _ref : 0; - const offsetPaddingOuter = (_ref2 = (_offsetScaleCmpt$get2 = offsetScaleCmpt.get('paddingOuter')) !== null && _offsetScaleCmpt$get2 !== void 0 ? _offsetScaleCmpt$get2 : offsetScaleCmpt.get('padding')) !== null && _ref2 !== void 0 ? _ref2 : 0; - stepCount = "bandspace(".concat(stepCount, ", ").concat(offsetPaddingInner, ", ").concat(offsetPaddingOuter, ")"); + const offsetPaddingInner = offsetScaleCmpt.get('paddingInner') ?? offsetScaleCmpt.get('padding') ?? 0; + const offsetPaddingOuter = offsetScaleCmpt.get('paddingOuter') ?? offsetScaleCmpt.get('padding') ?? 0; + stepCount = `bandspace(${stepCount}, ${offsetPaddingInner}, ${offsetPaddingOuter})`; } - const paddingInner = (_mergedScaleCmpt$get = mergedScaleCmpt.get('paddingInner')) !== null && _mergedScaleCmpt$get !== void 0 ? _mergedScaleCmpt$get : mergedScaleCmpt.get('padding'); + const paddingInner = mergedScaleCmpt.get('paddingInner') ?? mergedScaleCmpt.get('padding'); return { - signal: "".concat(step.step, " * ").concat(stepCount, " / (1-").concat(exprFromSignalRefOrValue(paddingInner), ")") + signal: `${step.step} * ${stepCount} / (1-${exprFromSignalRefOrValue(paddingInner)})` }; } else { return step.step; } } @@ -18846,15 +18668,15 @@ } } // otherwise use the position return [0, { - signal: "bandwidth('".concat(positionScaleName, "')") + signal: `bandwidth('${positionScaleName}')` }]; } else { // continuous scale - return never("Cannot use ".concat(channel, " scale if ").concat(positionChannel, " scale is not discrete.")); + return never(`Cannot use ${channel} scale if ${positionChannel} scale is not discrete.`); } } function getDiscretePositionSize(channel, size, viewConfig) { const sizeChannel = channel === X ? 'width' : 'height'; @@ -18897,12 +18719,12 @@ function interpolateRange(rangeMin, rangeMax, cardinality) { // always return a signal since it's better to compute the sequence in Vega later const f = () => { const rMax = signalOrStringValue(rangeMax); const rMin = signalOrStringValue(rangeMin); - const step = "(".concat(rMax, " - ").concat(rMin, ") / (").concat(cardinality, " - 1)"); - return "sequence(".concat(rMin, ", ").concat(rMax, " + ").concat(step, ", ").concat(step, ")"); + const step = `(${rMax} - ${rMin}) / (${cardinality} - 1)`; + return `sequence(${rMin}, ${rMax} + ${step}, ${step})`; }; if (isSignalRef(rangeMax)) { return new SignalRefWrapper(f); } else { @@ -18914,11 +18736,11 @@ function sizeRangeMin(mark, zero, config) { if (zero) { if (isSignalRef(zero)) { return { - signal: "".concat(zero.signal, " ? 0 : ").concat(sizeRangeMin(mark, false, config)) + signal: `${zero.signal} ? 0 : ${sizeRangeMin(mark, false, config)}` }; } else { return 0; } } @@ -18967,11 +18789,11 @@ const min = minXYStep(size, xyStepSignals, config.view); if (vega.isNumber(min)) { return min - 1; } else { - return new SignalRefWrapper(() => "".concat(min.signal, " - 1")); + return new SignalRefWrapper(() => `${min.signal} - 1`); } } case 'line': case 'trail': @@ -18992,11 +18814,11 @@ const pointStep = minXYStep(size, xyStepSignals, config.view); if (vega.isNumber(pointStep)) { return Math.pow(MAX_SIZE_RANGE_STEP_RATIO * pointStep, 2); } else { - return new SignalRefWrapper(() => "pow(".concat(MAX_SIZE_RANGE_STEP_RATIO, " * ").concat(pointStep.signal, ", 2)")); + return new SignalRefWrapper(() => `pow(${MAX_SIZE_RANGE_STEP_RATIO} * ${pointStep.signal}, 2)`); } } } /* istanbul ignore next: should never reach here */ // sizeRangeMax not implemented for the mark @@ -19014,11 +18836,11 @@ const heightStep = isStep(size.height) ? size.height.step : getViewConfigDiscreteStep(viewConfig, 'height'); if (xyStepSignals.x || xyStepSignals.y) { return new SignalRefWrapper(() => { const exprs = [xyStepSignals.x ? xyStepSignals.x.signal : widthStep, xyStepSignals.y ? xyStepSignals.y.signal : heightStep]; - return "min(".concat(exprs.join(', '), ")"); + return `min(${exprs.join(', ')})`; }); } return Math.min(widthStep, heightStep); } @@ -19098,11 +18920,12 @@ domain: specifiedScale.domain, domainMin: specifiedScale.domainMin, domainMax: specifiedScale.domainMax, markDef, config, - hasNestedOffsetScale: channelHasNestedOffsetScale(encoding, channel) + hasNestedOffsetScale: channelHasNestedOffsetScale(encoding, channel), + hasSecondaryRangeChannel: !!encoding[getSecondaryRangeChannel(channel)] }) : config.scale[property]; if (value !== undefined) { localScaleCmpt.set(property, value, false); } @@ -19183,13 +19006,15 @@ let { channel, fieldOrDatumDef, domain, markDef, - scaleType + scaleType, + config, + hasSecondaryRangeChannel } = _ref8; - return zero(channel, fieldOrDatumDef, domain, markDef, scaleType); + return zero(channel, fieldOrDatumDef, domain, markDef, scaleType, config.scale, hasSecondaryRangeChannel); } }; // This method is here rather than in range.ts to avoid circular dependency. function parseScaleRange(model) { if (isUnitModel(model)) { @@ -19353,11 +19178,11 @@ /* By default, paddingOuter is paddingInner / 2. The reason is that size (width/height) = step * (cardinality - paddingInner + 2 * paddingOuter). and we want the width/height to be integer by default. Note that step (by default) and cardinality are integers.) */ isSignalRef(paddingInnerValue) ? { - signal: "".concat(paddingInnerValue.signal, "/2") + signal: `${paddingInnerValue.signal}/2` } : paddingInnerValue / 2); } } else if (isXorYOffset(channel)) { if (scaleType === ScaleType.POINT) { return 0.5; // so the point positions align with centers of band scales. @@ -19371,11 +19196,11 @@ function reverse(scaleType, sort, channel, scaleConfig) { if (channel === 'x' && scaleConfig.xReverse !== undefined) { if (hasContinuousDomain(scaleType) && sort === 'descending') { if (isSignalRef(scaleConfig.xReverse)) { return { - signal: "!".concat(scaleConfig.xReverse.signal) + signal: `!${scaleConfig.xReverse.signal}` }; } else { return !scaleConfig.xReverse; } } @@ -19389,11 +19214,11 @@ return true; } return undefined; } - function zero(channel, fieldDef, specifiedDomain, markDef, scaleType) { + function zero(channel, fieldDef, specifiedDomain, markDef, scaleType, scaleConfig, hasSecondaryRangeChannel) { // If users explicitly provide a domain, we should not augment zero as that will be unexpected. const hasCustomDomain = !!specifiedDomain && specifiedDomain !== 'unaggregated'; if (hasCustomDomain) { if (hasContinuousDomain(scaleType)) { @@ -19407,21 +19232,22 @@ } } return false; } - } // If there is no custom domain, return true only for the following cases: + } // If there is no custom domain, return configZero value (=`true` as default) only for the following cases: // 1) using quantitative field with size // While this can be either ratio or interval fields, our assumption is that // ratio are more common. However, if the scaleType is discretizing scale, we want to return // false so that range doesn't start at zero if (channel === 'size' && fieldDef.type === 'quantitative' && !isContinuousToDiscrete(scaleType)) { return true; } // 2) non-binned, quantitative x-scale or y-scale // (For binning, we should not include zero by default because binning are calculated without zero.) + // (For area/bar charts with ratio scale chart, we should always include zero.) if (!(isFieldDef(fieldDef) && fieldDef.bin) && contains([...POSITION_SCALE_CHANNELS, ...POLAR_POSITION_SCALE_CHANNELS], channel)) { const { orient, @@ -19432,11 +19258,15 @@ if (orient === 'horizontal' && channel === 'y' || orient === 'vertical' && channel === 'x') { return false; } } - return true; + if (contains(['bar', 'area'], type) && !hasSecondaryRangeChannel) { + return true; + } + + return scaleConfig === null || scaleConfig === void 0 ? void 0 : scaleConfig.zero; } return false; } @@ -19618,16 +19448,14 @@ continue; } } if (fieldOrDatumDef && specifiedScale !== null && specifiedScale !== false) { - var _specifiedScale; - - (_specifiedScale = specifiedScale) !== null && _specifiedScale !== void 0 ? _specifiedScale : specifiedScale = {}; + specifiedScale ??= {}; const hasNestedOffsetScale = channelHasNestedOffsetScale(encoding, channel); const sType = scaleType(specifiedScale, channel, fieldOrDatumDef, markDef, hasNestedOffsetScale); - scaleComponents[channel] = new ScaleComponent(model.scaleName("".concat(channel), true), { + scaleComponents[channel] = new ScaleComponent(model.scaleName(`${channel}`, true), { value: sType, explicit: specifiedScale.type === sType }); } } @@ -19644,14 +19472,12 @@ for (const child of model.children) { parseScaleCore(child); // Instead of always merging right away -- check if it is compatible to merge first! for (const channel of keys(child.component.scales)) { - var _resolve$scale, _resolve$scale$channe; - // if resolve is undefined, set default first - (_resolve$scale$channe = (_resolve$scale = resolve.scale)[channel]) !== null && _resolve$scale$channe !== void 0 ? _resolve$scale$channe : _resolve$scale[channel] = defaultScaleResolve(channel, model); + resolve.scale[channel] ??= defaultScaleResolve(channel, model); if (resolve.scale[channel] === 'shared') { const explicitScaleType = scaleTypeWithExplicitIndex[channel]; const childScaleType = child.component.scales[channel].getWithExplicit('type'); @@ -19745,12 +19571,10 @@ /** Name map for projections, which can be renamed by a model's parent. */ /** Name map for signals, which can be renamed by a model's parent. */ constructor(spec, type, parent, parentGivenName, config, resolve, view) { - var _spec$name, _spec$transform; - this.type = type; this.parent = parent; this.config = config; _defineProperty(this, "name", void 0); @@ -19798,21 +19622,21 @@ this.parent = parent; this.config = config; this.view = replaceExprRef(view); // If name is not provided, always use parent's givenName to avoid name conflicts. - this.name = (_spec$name = spec.name) !== null && _spec$name !== void 0 ? _spec$name : parentGivenName; + this.name = spec.name ?? parentGivenName; this.title = isText(spec.title) ? { text: spec.title } : spec.title ? replaceExprRef(spec.title) : undefined; // Shared name maps this.scaleNameMap = parent ? parent.scaleNameMap : new NameMap(); this.projectionNameMap = parent ? parent.projectionNameMap : new NameMap(); this.signalNameMap = parent ? parent.signalNameMap : new NameMap(); this.data = spec.data; this.description = spec.description; - this.transforms = normalizeTransform((_spec$transform = spec.transform) !== null && _spec$transform !== void 0 ? _spec$transform : []); + this.transforms = normalizeTransform(spec.transform ?? []); this.layout = type === 'layer' || type === 'unit' ? {} : extractCompositionLayout(spec, type, config); this.component = { data: { sources: parent ? parent.component.data.sources : [], outputNodes: parent ? parent.component.data.outputNodes : {}, @@ -19925,16 +19749,14 @@ } // For top-level spec, we can set the global width and height signal to adjust the group size. // For other child specs, we have to manually set width and height in the encode entry. if (this.type === 'unit' || this.type === 'layer') { - var _encodeEntry; - return { width: this.getSizeSignalRef('width'), height: this.getSizeSignalRef('height'), - ...((_encodeEntry = encodeEntry) !== null && _encodeEntry !== void 0 ? _encodeEntry : {}) + ...(encodeEntry ?? {}) }; } } return isEmpty(encodeEntry) ? undefined : encodeEntry; @@ -19998,16 +19820,14 @@ assembleProjections() { return assembleProjections(this); } assembleTitle() { - var _this$title; - const { encoding, ...titleNoEncoding - } = (_this$title = this.title) !== null && _this$title !== void 0 ? _this$title : {}; + } = this.title ?? {}; const title = { ...extractTitleConfig(this.config.title).nonMarkTitleProperties, ...titleNoEncoding, ...(encoding ? { encode: { update: encoding @@ -20017,21 +19837,17 @@ if (title.text) { if (contains(['unit', 'layer'], this.type)) { // Unit/Layer if (contains(['middle', undefined], title.anchor)) { - var _title$frame; - - (_title$frame = title.frame) !== null && _title$frame !== void 0 ? _title$frame : title.frame = 'group'; + title.frame ??= 'group'; } } else { - var _title$anchor; - // composition with Vega layout // Set title = "start" by default for composition as "middle" does not look nice // https://github.com/vega/vega/issues/960#issuecomment-471360328 - (_title$anchor = title.anchor) !== null && _title$anchor !== void 0 ? _title$anchor : title.anchor = 'start'; + title.anchor ??= 'start'; } return isEmpty(title) ? undefined : title; } @@ -20080,11 +19896,11 @@ return group; } getName(text) { - return varName((this.name ? "".concat(this.name, "_") : '') + text); + return varName((this.name ? `${this.name}_` : '') + text); } getDataName(type) { return this.getName(DataSourceType[type].toLowerCase()); } @@ -20315,36 +20131,32 @@ clone() { return new DensityTransformNode(null, duplicate(this.transform)); } constructor(parent, transform) { - var _this$transform$as, _specifiedAs$, _specifiedAs$2; - super(parent); this.transform = transform; this.transform = duplicate(transform); // duplicate to prevent side effects - const specifiedAs = (_this$transform$as = this.transform.as) !== null && _this$transform$as !== void 0 ? _this$transform$as : [undefined, undefined]; - this.transform.as = [(_specifiedAs$ = specifiedAs[0]) !== null && _specifiedAs$ !== void 0 ? _specifiedAs$ : 'value', (_specifiedAs$2 = specifiedAs[1]) !== null && _specifiedAs$2 !== void 0 ? _specifiedAs$2 : 'density']; // set steps when we are grouping so that we get consitent sampling points for imputing and grouping + const specifiedAs = this.transform.as ?? [undefined, undefined]; + this.transform.as = [specifiedAs[0] ?? 'value', specifiedAs[1] ?? 'density']; // set steps when we are grouping so that we get consitent sampling points for imputing and grouping if (transform.groupby && transform.minsteps == null && transform.maxsteps == null && transform.steps == null) { this.transform.steps = 200; } } dependentFields() { - var _this$transform$group; - - return new Set([this.transform.density, ...((_this$transform$group = this.transform.groupby) !== null && _this$transform$group !== void 0 ? _this$transform$group : [])]); + return new Set([this.transform.density, ...(this.transform.groupby ?? [])]); } producedFields() { return new Set(this.transform.as); } hash() { - return "DensityTransform ".concat(hash(this.transform)); + return `DensityTransform ${hash(this.transform)}`; } assemble() { const { density, @@ -20413,11 +20225,11 @@ producedFields() { return new Set(); // filter does not produce any new fields } hash() { - return "FilterInvalid ".concat(hash(this.filter)); + return `FilterInvalid ${hash(this.filter)}`; } /** * Create the VgTransforms for each of the filtered fields. */ @@ -20429,14 +20241,14 @@ expr: 'datum' }); if (fieldDef !== null) { if (fieldDef.type === 'temporal') { - vegaFilters.push("(isDate(".concat(ref, ") || (isValid(").concat(ref, ") && isFinite(+").concat(ref, ")))")); + vegaFilters.push(`(isDate(${ref}) || (isValid(${ref}) && isFinite(+${ref})))`); } else if (fieldDef.type === 'quantitative') { - vegaFilters.push("isValid(".concat(ref, ")")); - vegaFilters.push("isFinite(+".concat(ref, ")")); + vegaFilters.push(`isValid(${ref})`); + vegaFilters.push(`isFinite(+${ref})`); } else ; } return vegaFilters; }, []); @@ -20464,15 +20276,11 @@ const { flatten, as = [] } = this.transform; - this.transform.as = flatten.map((f, i) => { - var _as$i; - - return (_as$i = as[i]) !== null && _as$i !== void 0 ? _as$i : f; - }); + this.transform.as = flatten.map((f, i) => as[i] ?? f); } dependentFields() { return new Set(this.transform.flatten); } @@ -20480,11 +20288,11 @@ producedFields() { return new Set(this.transform.as); } hash() { - return "FlattenTransform ".concat(hash(this.transform)); + return `FlattenTransform ${hash(this.transform)}`; } assemble() { const { flatten: fields, @@ -20508,18 +20316,16 @@ clone() { return new FoldTransformNode(null, duplicate(this.transform)); } constructor(parent, transform) { - var _this$transform$as, _specifiedAs$, _specifiedAs$2; - super(parent); this.transform = transform; this.transform = duplicate(transform); // duplicate to prevent side effects - const specifiedAs = (_this$transform$as = this.transform.as) !== null && _this$transform$as !== void 0 ? _this$transform$as : [undefined, undefined]; - this.transform.as = [(_specifiedAs$ = specifiedAs[0]) !== null && _specifiedAs$ !== void 0 ? _specifiedAs$ : 'key', (_specifiedAs$2 = specifiedAs[1]) !== null && _specifiedAs$2 !== void 0 ? _specifiedAs$2 : 'value']; + const specifiedAs = this.transform.as ?? [undefined, undefined]; + this.transform.as = [specifiedAs[0] ?? 'key', specifiedAs[1] ?? 'value']; } dependentFields() { return new Set(this.transform.fold); } @@ -20527,11 +20333,11 @@ producedFields() { return new Set(this.transform.as); } hash() { - return "FoldTransform ".concat(hash(this.transform)); + return `FoldTransform ${hash(this.transform)}`; } assemble() { const { fold, @@ -20561,26 +20367,26 @@ for (const coordinates of [[LONGITUDE, LATITUDE], [LONGITUDE2, LATITUDE2]]) { const pair = coordinates.map(channel => { const def = getFieldOrDatumDef(model.encoding[channel]); return isFieldDef(def) ? def.field : isDatumDef(def) ? { - expr: "".concat(def.datum) + expr: `${def.datum}` } : isValueDef(def) ? { - expr: "".concat(def['value']) + expr: `${def['value']}` } : undefined; }); if (pair[0] || pair[1]) { - parent = new GeoJSONNode(parent, pair, null, model.getName("geojson_".concat(geoJsonCounter++))); + parent = new GeoJSONNode(parent, pair, null, model.getName(`geojson_${geoJsonCounter++}`)); } } if (model.channelHasField(SHAPE)) { const fieldDef = model.typedFieldDef(SHAPE); if (fieldDef.type === GEOJSON) { - parent = new GeoJSONNode(parent, null, fieldDef.field, model.getName("geojson_".concat(geoJsonCounter++))); + parent = new GeoJSONNode(parent, null, fieldDef.field, model.getName(`geojson_${geoJsonCounter++}`)); } } return parent; } @@ -20591,28 +20397,26 @@ this.geojson = geojson; this.signal = signal; } dependentFields() { - var _this$fields; - - const fields = ((_this$fields = this.fields) !== null && _this$fields !== void 0 ? _this$fields : []).filter(vega.isString); + const fields = (this.fields ?? []).filter(vega.isString); return new Set([...(this.geojson ? [this.geojson] : []), ...fields]); } producedFields() { return new Set(); } hash() { - return "GeoJSON ".concat(this.geojson, " ").concat(this.signal, " ").concat(hash(this.fields)); + return `GeoJSON ${this.geojson} ${this.signal} ${hash(this.fields)}`; } assemble() { return [...(this.geojson ? [{ type: 'filter', - expr: "isValid(datum[\"".concat(this.geojson, "\"])") + expr: `isValid(datum["${this.geojson}"])` }] : []), { type: 'geojson', ...(this.fields ? { fields: this.fields } : {}), @@ -20644,19 +20448,19 @@ for (const coordinates of [[LONGITUDE, LATITUDE], [LONGITUDE2, LATITUDE2]]) { const pair = coordinates.map(channel => { const def = getFieldOrDatumDef(model.encoding[channel]); return isFieldDef(def) ? def.field : isDatumDef(def) ? { - expr: "".concat(def.datum) + expr: `${def.datum}` } : isValueDef(def) ? { - expr: "".concat(def['value']) + expr: `${def['value']}` } : undefined; }); const suffix = coordinates[0] === LONGITUDE2 ? '2' : ''; if (pair[0] || pair[1]) { - parent = new GeoPointNode(parent, model.projectionName(), pair, [model.getName("x".concat(suffix)), model.getName("y".concat(suffix))]); + parent = new GeoPointNode(parent, model.projectionName(), pair, [model.getName(`x${suffix}`), model.getName(`y${suffix}`)]); } } return parent; } @@ -20668,11 +20472,11 @@ producedFields() { return new Set(this.as); } hash() { - return "Geopoint ".concat(this.projection, " ").concat(hash(this.fields), " ").concat(hash(this.as)); + return `Geopoint ${this.projection} ${hash(this.fields)} ${hash(this.as)}`; } assemble() { return { type: 'geopoint', @@ -20693,13 +20497,11 @@ super(parent); this.transform = transform; } dependentFields() { - var _this$transform$group; - - return new Set([this.transform.impute, this.transform.key, ...((_this$transform$group = this.transform.groupby) !== null && _this$transform$group !== void 0 ? _this$transform$group : [])]); + return new Set([this.transform.impute, this.transform.key, ...(this.transform.groupby ?? [])]); } producedFields() { return new Set([this.transform.impute]); } @@ -20710,11 +20512,11 @@ stop, step } = keyvals; const result = [start, stop, ...(step ? [step] : [])].join(','); return { - signal: "sequence(".concat(result, ")") + signal: `sequence(${result})` }; } static makeFromTransform(parent, imputeTransform) { return new ImputeNode(parent, imputeTransform); @@ -20763,11 +20565,11 @@ return null; } hash() { - return "Impute ".concat(hash(this.transform)); + return `Impute ${hash(this.transform)}`; } assemble() { const { impute, @@ -20793,22 +20595,22 @@ }; if (method && method !== 'value') { const deriveNewField = { type: 'window', - as: ["imputed_".concat(impute, "_value")], + as: [`imputed_${impute}_value`], ops: [method], fields: [impute], frame, ignorePeers: false, ...(groupby ? { groupby } : {}) }; const replaceOriginal = { type: 'formula', - expr: "datum.".concat(impute, " === null ? datum.imputed_").concat(impute, "_value : datum.").concat(impute), + expr: `datum.${impute} === null ? datum.imputed_${impute}_value : datum.${impute}`, as: impute }; return [imputeTransform, deriveNewField, replaceOriginal]; } else { return [imputeTransform]; @@ -20825,32 +20627,28 @@ clone() { return new LoessTransformNode(null, duplicate(this.transform)); } constructor(parent, transform) { - var _this$transform$as, _specifiedAs$, _specifiedAs$2; - super(parent); this.transform = transform; this.transform = duplicate(transform); // duplicate to prevent side effects - const specifiedAs = (_this$transform$as = this.transform.as) !== null && _this$transform$as !== void 0 ? _this$transform$as : [undefined, undefined]; - this.transform.as = [(_specifiedAs$ = specifiedAs[0]) !== null && _specifiedAs$ !== void 0 ? _specifiedAs$ : transform.on, (_specifiedAs$2 = specifiedAs[1]) !== null && _specifiedAs$2 !== void 0 ? _specifiedAs$2 : transform.loess]; + const specifiedAs = this.transform.as ?? [undefined, undefined]; + this.transform.as = [specifiedAs[0] ?? transform.on, specifiedAs[1] ?? transform.loess]; } dependentFields() { - var _this$transform$group; - - return new Set([this.transform.loess, this.transform.on, ...((_this$transform$group = this.transform.groupby) !== null && _this$transform$group !== void 0 ? _this$transform$group : [])]); + return new Set([this.transform.loess, this.transform.on, ...(this.transform.groupby ?? [])]); } producedFields() { return new Set(this.transform.as); } hash() { - return "LoessTransform ".concat(hash(this.transform)); + return `LoessTransform ${hash(this.transform)}`; } assemble() { const { loess, @@ -20892,11 +20690,11 @@ if (!fromSource) { fromSource = new SourceNode(from.data); sources.push(fromSource); } - const fromOutputName = model.getName("lookup_".concat(counter)); + const fromOutputName = model.getName(`lookup_${counter}`); fromOutputNode = new OutputNode(fromSource, fromOutputName, DataSourceType.Lookup, model.component.data.outputNodeRefCounts); model.component.data.outputNodes[fromOutputName] = fromOutputNode; } else if (isLookupSelection(from)) { const selName = from.param; transform = { @@ -20928,14 +20726,14 @@ producedFields() { return new Set(this.transform.as ? vega.array(this.transform.as) : this.transform.from.fields); } hash() { - return "Lookup ".concat(hash({ - transform: this.transform, - secondary: this.secondary - })); + return `Lookup ${hash({ + transform: this.transform, + secondary: this.secondary + })}`; } assemble() { let foreign; @@ -20983,32 +20781,28 @@ clone() { return new QuantileTransformNode(null, duplicate(this.transform)); } constructor(parent, transform) { - var _this$transform$as, _specifiedAs$, _specifiedAs$2; - super(parent); this.transform = transform; this.transform = duplicate(transform); // duplicate to prevent side effects - const specifiedAs = (_this$transform$as = this.transform.as) !== null && _this$transform$as !== void 0 ? _this$transform$as : [undefined, undefined]; - this.transform.as = [(_specifiedAs$ = specifiedAs[0]) !== null && _specifiedAs$ !== void 0 ? _specifiedAs$ : 'prob', (_specifiedAs$2 = specifiedAs[1]) !== null && _specifiedAs$2 !== void 0 ? _specifiedAs$2 : 'value']; + const specifiedAs = this.transform.as ?? [undefined, undefined]; + this.transform.as = [specifiedAs[0] ?? 'prob', specifiedAs[1] ?? 'value']; } dependentFields() { - var _this$transform$group; - - return new Set([this.transform.quantile, ...((_this$transform$group = this.transform.groupby) !== null && _this$transform$group !== void 0 ? _this$transform$group : [])]); + return new Set([this.transform.quantile, ...(this.transform.groupby ?? [])]); } producedFields() { return new Set(this.transform.as); } hash() { - return "QuantileTransform ".concat(hash(this.transform)); + return `QuantileTransform ${hash(this.transform)}`; } assemble() { const { quantile, @@ -21032,32 +20826,28 @@ clone() { return new RegressionTransformNode(null, duplicate(this.transform)); } constructor(parent, transform) { - var _this$transform$as, _specifiedAs$, _specifiedAs$2; - super(parent); this.transform = transform; this.transform = duplicate(transform); // duplicate to prevent side effects - const specifiedAs = (_this$transform$as = this.transform.as) !== null && _this$transform$as !== void 0 ? _this$transform$as : [undefined, undefined]; - this.transform.as = [(_specifiedAs$ = specifiedAs[0]) !== null && _specifiedAs$ !== void 0 ? _specifiedAs$ : transform.on, (_specifiedAs$2 = specifiedAs[1]) !== null && _specifiedAs$2 !== void 0 ? _specifiedAs$2 : transform.regression]; + const specifiedAs = this.transform.as ?? [undefined, undefined]; + this.transform.as = [specifiedAs[0] ?? transform.on, specifiedAs[1] ?? transform.regression]; } dependentFields() { - var _this$transform$group; - - return new Set([this.transform.regression, this.transform.on, ...((_this$transform$group = this.transform.groupby) !== null && _this$transform$group !== void 0 ? _this$transform$group : [])]); + return new Set([this.transform.regression, this.transform.on, ...(this.transform.groupby ?? [])]); } producedFields() { return new Set(this.transform.as); } hash() { - return "RegressionTransform ".concat(hash(this.transform)); + return `RegressionTransform ${hash(this.transform)}`; } assemble() { const { regression, @@ -21088,27 +20878,23 @@ super(parent); this.transform = transform; } addDimensions(fields) { - var _this$transform$group; - - this.transform.groupby = unique(((_this$transform$group = this.transform.groupby) !== null && _this$transform$group !== void 0 ? _this$transform$group : []).concat(fields), d => d); + this.transform.groupby = unique((this.transform.groupby ?? []).concat(fields), d => d); } producedFields() { return undefined; // return undefined so that potentially everything can depend on the pivot } dependentFields() { - var _this$transform$group2; - - return new Set([this.transform.pivot, this.transform.value, ...((_this$transform$group2 = this.transform.groupby) !== null && _this$transform$group2 !== void 0 ? _this$transform$group2 : [])]); + return new Set([this.transform.pivot, this.transform.value, ...(this.transform.groupby ?? [])]); } hash() { - return "PivotTransform ".concat(hash(this.transform)); + return `PivotTransform ${hash(this.transform)}`; } assemble() { const { pivot, @@ -21156,11 +20942,11 @@ producedFields() { return new Set(); } hash() { - return "SampleTransform ".concat(hash(this.transform)); + return `SampleTransform ${hash(this.transform)}`; } assemble() { return { type: 'sample', @@ -21192,14 +20978,12 @@ } } if (node instanceof ParseNode) { if (node.parent instanceof SourceNode && !dataSource.source) { - var _dataSource$format; - // If node's parent is a root source and the data source does not refer to another data source, use normal format parse - dataSource.format = { ...((_dataSource$format = dataSource.format) !== null && _dataSource$format !== void 0 ? _dataSource$format : {}), + dataSource.format = { ...(dataSource.format ?? {}), parse: node.assembleFormatParse() }; // add calculates for all nested fields dataSource.transform.push(...node.assembleTransforms(true)); } else { @@ -21208,11 +20992,11 @@ } } if (node instanceof FacetNode) { if (!dataSource.name) { - dataSource.name = "data_".concat(datasetIndex++); + dataSource.name = `data_${datasetIndex++}`; } if (!dataSource.source || dataSource.transform.length > 0) { data.push(dataSource); node.data = dataSource.name; @@ -21240,11 +21024,11 @@ // Note that an output node may be required but we still do not assemble a // separate data source for it. node.setSource(dataSource.name); } else { if (!dataSource.name) { - dataSource.name = "data_".concat(datasetIndex++); + dataSource.name = `data_${datasetIndex++}`; } // Here we set the name of the datasource we generated. From now on // other assemblers can use it. node.setSource(dataSource.name); // if this node has more than one child, we will add a datasource automatically @@ -21276,11 +21060,11 @@ break; default: { if (!dataSource.name) { - dataSource.name = "data_".concat(datasetIndex++); + dataSource.name = `data_${datasetIndex++}`; } let source = dataSource.name; if (!dataSource.source || dataSource.transform.length > 0) { @@ -21340,11 +21124,11 @@ let sourceIndex = 0; for (const root of dataComponent.sources) { // assign a name if the source does not have a name yet if (!root.hasName()) { - root.dataName = "source_".concat(sourceIndex++); + root.dataName = `source_${sourceIndex++}`; } const newData = root.assemble(); walkTree(root, newData); } // remove empty transform arrays for cleaner output @@ -21358,22 +21142,18 @@ let whereTo = 0; for (const [i, d] of data.entries()) { - var _d$transform; - - if (((_d$transform = d.transform) !== null && _d$transform !== void 0 ? _d$transform : []).length === 0 && !d.source) { + if ((d.transform ?? []).length === 0 && !d.source) { data.splice(whereTo++, 0, data.splice(i, 1)[0]); } } // now fix the from references in lookup transforms for (const d of data) { - for (const t of (_d$transform2 = d.transform) !== null && _d$transform2 !== void 0 ? _d$transform2 : []) { - var _d$transform2; - + for (const t of d.transform ?? []) { if (t.type === 'lookup') { t.from = dataComponent.outputNodes[t.from].getSource(); } } } // inline values for datasets that are in the datastore @@ -21425,11 +21205,11 @@ if (child.component.layoutHeaders[channel].title) { // TODO: better handle multiline titles title$1 = vega.isArray(title$1) ? title$1.join(', ') : title$1; // merge title with child to produce "Title / Subtitle / Sub-subtitle" - title$1 += " / ".concat(child.component.layoutHeaders[channel].title); + title$1 += ` / ${child.component.layoutHeaders[channel].title}`; child.component.layoutHeaders[channel].title = null; } const labelOrient = getHeaderProperty('labelOrient', fieldDef.header, config, channel); const labels = fieldDef.header !== null ? getFirstDefined((_fieldDef$header = fieldDef.header) === null || _fieldDef$header === void 0 ? void 0 : _fieldDef$header.labels, config.header.labels, true) : false; @@ -21467,14 +21247,12 @@ // For shared axis, move the axes to facet's header or footer const headerChannel = channel === 'x' ? 'column' : 'row'; const layoutHeader = layoutHeaders[headerChannel]; for (const axisComponent of child.component.axes[channel]) { - var _layoutHeader$headerT; - const headerType = getHeaderType(axisComponent.get('orient')); - (_layoutHeader$headerT = layoutHeader[headerType]) !== null && _layoutHeader$headerT !== void 0 ? _layoutHeader$headerT : layoutHeader[headerType] = [makeHeaderComponent(model, headerChannel, false)]; // FIXME: assemble shouldn't be called here, but we do it this way so we only extract the main part of the axes + layoutHeader[headerType] ??= [makeHeaderComponent(model, headerChannel, false)]; // FIXME: assemble shouldn't be called here, but we do it this way so we only extract the main part of the axes const mainAxis = assembleAxis(axisComponent, 'main', model.config, { header: true }); @@ -21525,14 +21303,12 @@ const resolve = model.component.resolve; const layoutSizeCmpt = model.component.layoutSize; let mergedSize; // Try to merge layout size for (const child of model.children) { - var _resolve$scale$channe; - const childSize = child.component.layoutSize.getWithExplicit(sizeType); - const scaleResolve = (_resolve$scale$channe = resolve.scale[channel]) !== null && _resolve$scale$channe !== void 0 ? _resolve$scale$channe : defaultScaleResolve(channel, model); + const scaleResolve = resolve.scale[channel] ?? defaultScaleResolve(channel, model); if (scaleResolve === 'independent' && childSize.value === 'step') { // Do not merge independent scales with range-step as their size depends // on the scale domains, which can be different between scales. mergedSize = undefined; @@ -21618,12 +21394,12 @@ } } function facetSortFieldName(fieldDef, sort, opt) { return vgField(sort, { - suffix: "by_".concat(vgField(fieldDef)), - ...(opt !== null && opt !== void 0 ? opt : {}) + suffix: `by_${vgField(fieldDef)}`, + ...(opt ?? {}) }); } class FacetModel extends ModelWithField { constructor(spec, parent, parentGivenName, config) { super(spec, 'facet', parent, parentGivenName, config, spec.resolve); @@ -21744,35 +21520,29 @@ if (facetFieldDef) { const titleOrient = getHeaderProperty('titleOrient', facetFieldDef.header, this.config, channel); if (['right', 'bottom'].includes(titleOrient)) { - var _layoutMixins$titleAn; - const headerChannel = getHeaderChannel(channel, titleOrient); - (_layoutMixins$titleAn = layoutMixins.titleAnchor) !== null && _layoutMixins$titleAn !== void 0 ? _layoutMixins$titleAn : layoutMixins.titleAnchor = {}; + layoutMixins.titleAnchor ??= {}; layoutMixins.titleAnchor[headerChannel] = 'end'; } } if (headerComponent !== null && headerComponent !== void 0 && headerComponent[0]) { // set header/footerBand const sizeType = channel === 'row' ? 'height' : 'width'; const bandType = headerType === 'header' ? 'headerBand' : 'footerBand'; if (channel !== 'facet' && !this.child.component.layoutSize.get(sizeType)) { - var _layoutMixins$bandTyp; - // If facet child does not have size signal, then apply headerBand - (_layoutMixins$bandTyp = layoutMixins[bandType]) !== null && _layoutMixins$bandTyp !== void 0 ? _layoutMixins$bandTyp : layoutMixins[bandType] = {}; + layoutMixins[bandType] ??= {}; layoutMixins[bandType][channel] = 0.5; } if (layoutHeaderComponent.title) { - var _layoutMixins$offset; - - (_layoutMixins$offset = layoutMixins.offset) !== null && _layoutMixins$offset !== void 0 ? _layoutMixins$offset : layoutMixins.offset = {}; + layoutMixins.offset ??= {}; layoutMixins.offset[channel === 'row' ? 'rowTitle' : 'columnTitle'] = 10; } } } } @@ -21817,11 +21587,11 @@ return undefined; } else { // In facetNode.assemble(), the name is always this.getName('column') + '_layout'. const facetLayoutDataName = this.getName('column_domain'); return { - signal: "length(data('".concat(facetLayoutDataName, "'))") + signal: `length(data('${facetLayoutDataName}'))` }; } } assembleGroupStyle() { @@ -21865,11 +21635,11 @@ if (this.child instanceof FacetModel) { if (this.child.channelHasField('column')) { const field = vgField(this.child.facet.column); fields.push(field); ops.push('distinct'); - as.push("distinct_".concat(field)); + as.push(`distinct_${field}`); } } else { for (const channel of POSITION_SCALE_CHANNELS) { const childScaleComponent = this.child.component.scales[channel]; @@ -21882,11 +21652,11 @@ const field = getFieldFromDomain(domain); if (field) { fields.push(field); ops.push('distinct'); - as.push("distinct_".concat(field)); + as.push(`distinct_${field}`); } else { warn(unknownField(channel)); } } } @@ -22231,14 +22001,12 @@ if (isCalculate(t)) { transformNode = head = new CalculateNode(head, t); derivedType = 'derived'; } else if (isFilter(t)) { - var _ParseNode$makeWithAn; - const implicit = getImplicitFromFilterTransform(t); - transformNode = head = (_ParseNode$makeWithAn = ParseNode.makeWithAncestors(head, {}, implicit, ancestorParse)) !== null && _ParseNode$makeWithAn !== void 0 ? _ParseNode$makeWithAn : head; + transformNode = head = ParseNode.makeWithAncestors(head, {}, implicit, ancestorParse) ?? head; head = new FilterNode(head, model, t.filter); } else if (isBin(t)) { transformNode = head = BinNode.makeFromTransform(head, t, model); derivedType = 'number'; } else if (isTimeUnit(t)) { @@ -22302,13 +22070,11 @@ warn(invalidTransformIgnored(t)); continue; } if (transformNode && derivedType !== undefined) { - for (const field of (_transformNode$produc = transformNode.producedFields()) !== null && _transformNode$produc !== void 0 ? _transformNode$produc : []) { - var _transformNode$produc; - + for (const field of transformNode.producedFields() ?? []) { ancestorParse.set(field, derivedType, false); } } } @@ -22368,11 +22134,11 @@ v ...Child data... */ function parseData(model) { - var _data$format3, _ParseNode$makeExplic, _ParseNode$makeWithAn2; + var _data$format3; let head = parseRoot(model, model.component.data.sources); const { outputNodes, outputNodeRefCounts @@ -22394,11 +22160,11 @@ } else if ((data === null || data === void 0 ? void 0 : (_data$format3 = data.format) === null || _data$format3 === void 0 ? void 0 : _data$format3.parse) === null) { // format.parse: null means disable parsing ancestorParse.parseNothing = true; } - head = (_ParseNode$makeExplic = ParseNode.makeExplicit(head, model, ancestorParse)) !== null && _ParseNode$makeExplic !== void 0 ? _ParseNode$makeExplic : head; // Default discrete selections require an identifer transform to + head = ParseNode.makeExplicit(head, model, ancestorParse) ?? head; // Default discrete selections require an identifer transform to // uniquely identify data points. Add this transform at the head of // the pipeline such that the identifier field is available for all // subsequent datasets. During optimization, we will remove this // transform if it proves to be unnecessary. Additional identifier // transforms will be necessary when new tuples are constructed @@ -22409,72 +22175,62 @@ const parentIsLayer = model.parent && isLayerModel(model.parent); if (isUnitModel(model) || isFacetModel(model)) { if (parentIsLayer) { - var _BinNode$makeFromEnco; - - head = (_BinNode$makeFromEnco = BinNode.makeFromEncoding(head, model)) !== null && _BinNode$makeFromEnco !== void 0 ? _BinNode$makeFromEnco : head; + head = BinNode.makeFromEncoding(head, model) ?? head; } } if (model.transforms.length > 0) { head = parseTransformArray(head, model, ancestorParse); } // create parse nodes for fields that need to be parsed (or flattened) implicitly const implicitSelection = getImplicitFromSelection(model); const implicitEncoding = getImplicitFromEncoding(model); - head = (_ParseNode$makeWithAn2 = ParseNode.makeWithAncestors(head, {}, { ...implicitSelection, + head = ParseNode.makeWithAncestors(head, {}, { ...implicitSelection, ...implicitEncoding - }, ancestorParse)) !== null && _ParseNode$makeWithAn2 !== void 0 ? _ParseNode$makeWithAn2 : head; + }, ancestorParse) ?? head; if (isUnitModel(model)) { head = GeoJSONNode.parseAll(head, model); head = GeoPointNode.parseAll(head, model); } if (isUnitModel(model) || isFacetModel(model)) { - var _TimeUnitNode$makeFro; - if (!parentIsLayer) { - var _BinNode$makeFromEnco2; - - head = (_BinNode$makeFromEnco2 = BinNode.makeFromEncoding(head, model)) !== null && _BinNode$makeFromEnco2 !== void 0 ? _BinNode$makeFromEnco2 : head; + head = BinNode.makeFromEncoding(head, model) ?? head; } - head = (_TimeUnitNode$makeFro = TimeUnitNode.makeFromEncoding(head, model)) !== null && _TimeUnitNode$makeFro !== void 0 ? _TimeUnitNode$makeFro : head; + head = TimeUnitNode.makeFromEncoding(head, model) ?? head; head = CalculateNode.parseAllForSortIndex(head, model); } // add an output node pre aggregation const rawName = model.getDataName(DataSourceType.Raw); const raw = new OutputNode(head, rawName, DataSourceType.Raw, outputNodeRefCounts); outputNodes[rawName] = raw; head = raw; if (isUnitModel(model)) { - var _ImputeNode$makeFromE, _StackNode$makeFromEn; - const agg = AggregateNode.makeFromEncoding(head, model); if (agg) { head = agg; if (requiresSelectionId(model)) { head = new IdentifierNode(head); } } - head = (_ImputeNode$makeFromE = ImputeNode.makeFromEncoding(head, model)) !== null && _ImputeNode$makeFromE !== void 0 ? _ImputeNode$makeFromE : head; - head = (_StackNode$makeFromEn = StackNode.makeFromEncoding(head, model)) !== null && _StackNode$makeFromEn !== void 0 ? _StackNode$makeFromEn : head; + head = ImputeNode.makeFromEncoding(head, model) ?? head; + head = StackNode.makeFromEncoding(head, model) ?? head; } if (isUnitModel(model)) { - var _FilterInvalidNode$ma; - - head = (_FilterInvalidNode$ma = FilterInvalidNode.make(head, model)) !== null && _FilterInvalidNode$ma !== void 0 ? _FilterInvalidNode$ma : head; + head = FilterInvalidNode.make(head, model) ?? head; } // output node for marks const mainName = model.getDataName(DataSourceType.Main); const main = new OutputNode(head, mainName, DataSourceType.Main, outputNodeRefCounts); @@ -22487,16 +22243,14 @@ let facetRoot = null; if (isFacetModel(model)) { - var _makeJoinAggregateFro; - const facetName = model.getName('facet'); // Derive new aggregate for facet's sort field // augment data source with new fields for crossed facet - head = (_makeJoinAggregateFro = makeJoinAggregateFromFacet(head, model.facet)) !== null && _makeJoinAggregateFro !== void 0 ? _makeJoinAggregateFro : head; + head = makeJoinAggregateFromFacet(head, model.facet) ?? head; facetRoot = new FacetNode(head, model, facetName, main.getSource()); outputNodes[facetName] = facetRoot; } return { ...model.component.data, @@ -22520,11 +22274,11 @@ if (((_spec$resolve = spec.resolve) === null || _spec$resolve === void 0 ? void 0 : (_spec$resolve$axis = _spec$resolve.axis) === null || _spec$resolve$axis === void 0 ? void 0 : _spec$resolve$axis.x) === 'shared' || ((_spec$resolve2 = spec.resolve) === null || _spec$resolve2 === void 0 ? void 0 : (_spec$resolve2$axis = _spec$resolve2.axis) === null || _spec$resolve2$axis === void 0 ? void 0 : _spec$resolve2$axis.y) === 'shared') { warn(CONCAT_CANNOT_SHARE_AXIS); } this.children = this.getChildren(spec).map((child, i) => { - return buildModel(child, this, this.getName("concat_".concat(i)), undefined, config); + return buildModel(child, this, this.getName(`concat_${i}`), undefined, config); }); } parseData() { this.component.data = parseData(this); @@ -22693,17 +22447,15 @@ } } function labels(model, channel, specifiedLabelsSpec) { - var _getFieldOrDatumDef; - const { encoding, config } = model; - const fieldOrDatumDef = (_getFieldOrDatumDef = getFieldOrDatumDef(encoding[channel])) !== null && _getFieldOrDatumDef !== void 0 ? _getFieldOrDatumDef : getFieldOrDatumDef(encoding[getSecondaryRangeChannel(channel)]); + const fieldOrDatumDef = getFieldOrDatumDef(encoding[channel]) ?? getFieldOrDatumDef(encoding[getSecondaryRangeChannel(channel)]); const axis = model.axis(channel) || {}; const { format, formatType } = axis; @@ -22818,14 +22570,12 @@ // skip if the child does not have a particular axis continue; } if (resolve.axis[channel] === 'independent') { - var _axes$channel; - // If axes are independent, concat the axisComponent array. - axes[channel] = ((_axes$channel = axes[channel]) !== null && _axes$channel !== void 0 ? _axes$channel : []).concat(child.component.axes[channel]); // Automatically adjust orient + axes[channel] = (axes[channel] ?? []).concat(child.component.axes[channel]); // Automatically adjust orient for (const axisComponent of child.component.axes[channel]) { const { value: orient, explicit @@ -22963,11 +22713,11 @@ 'translate', // translate has dependent logic for bar's bin position and it's 0.5 by default in Vega. If a config overrides this value, we need to know. // the rest are not axis configs in Vega, but are in VL, so we need to set too. 'format', 'formatType', 'orient', 'labelExpr', 'tickCount', 'position', 'tickMinStep']); function parseAxis(channel, model) { - var _axis, _config, _config$axis, _axis2, _axis$encoding; + var _axis, _config, _config$axis, _axis2; let axis = model.axis(channel); const axisComponent = new AxisComponent(); const fieldOrDatumDef = getFieldOrDatumDef(model.encoding[channel]); const { @@ -23025,20 +22775,18 @@ } } } // 2) Add guide encode definition groups - const axisEncoding = (_axis$encoding = axis.encoding) !== null && _axis$encoding !== void 0 ? _axis$encoding : {}; + const axisEncoding = axis.encoding ?? {}; const axisEncode = AXIS_PARTS.reduce((e, part) => { - var _axisEncoding$part; - if (!axisComponent.hasAxisPart(part)) { // No need to create encode for a disabled part. return e; } - const axisEncodingPart = guideEncodeEntry((_axisEncoding$part = axisEncoding[part]) !== null && _axisEncoding$part !== void 0 ? _axisEncoding$part : {}, model); + const axisEncodingPart = guideEncodeEntry(axisEncoding[part] ?? {}, model); const value = part === 'labels' ? labels(model, channel, axisEncodingPart) : axisEncodingPart; if (value !== undefined && !isEmpty(value)) { e[part] = { update: value @@ -23183,24 +22931,32 @@ if (y2 || x2) { // Ranged bar does not always have clear orientation, so we allow overriding if (specifiedOrient) { return specifiedOrient; - } // If y is range and x is non-range, non-bin Q, y is likely a prebinned field + } // If y is range and x is non-range, non-bin Q if (!x2) { if (isFieldDef(x) && x.type === QUANTITATIVE && !isBinning(x.bin) || isNumericDataDef(x)) { - return 'horizontal'; + if (isFieldDef(y) && isBinned(y.bin)) { + return 'horizontal'; + } } - } // If x is range and y is non-range, non-bin Q, x is likely a prebinned field + return 'vertical'; + } // If x is range and y is non-range, non-bin Q + if (!y2) { if (isFieldDef(y) && y.type === QUANTITATIVE && !isBinning(y.bin) || isNumericDataDef(y)) { - return 'vertical'; + if (isFieldDef(x) && isBinned(x.bin)) { + return 'vertical'; + } } + + return 'horizontal'; } } // falls through @@ -23652,24 +23408,22 @@ }; } }; function defaultSize(model) { - var _getMarkPropOrConfig; - const { config, markDef } = model; const { orient } = markDef; const vgSizeChannel = orient === 'horizontal' ? 'width' : 'height'; const scale = model.getScaleComponent(orient === 'horizontal' ? 'x' : 'y'); - const markPropOrConfig = (_getMarkPropOrConfig = getMarkPropOrConfig('size', markDef, config, { + const markPropOrConfig = getMarkPropOrConfig('size', markDef, config, { vgChannel: vgSizeChannel - })) !== null && _getMarkPropOrConfig !== void 0 ? _getMarkPropOrConfig : config.tick.bandSize; + }) ?? config.tick.bandSize; if (markPropOrConfig !== undefined) { return markPropOrConfig; } else { const scaleRange = scale ? scale.get('range') : undefined; @@ -23791,11 +23545,11 @@ }), stackField({ prefix: 'max', suffix: 'end', expr })]; - return "".concat(func, "(").concat(vgFieldMinMax.map(field => "scale('".concat(fieldScale, "',").concat(field, ")")).join(','), ")"); + return `${func}(${vgFieldMinMax.map(field => `scale('${fieldScale}',${field})`).join(',')})`; }; let groupUpdate; let innerGroupUpdate; // Build the encoding for group and an inner group @@ -24139,12 +23893,10 @@ * Internal model of Vega-Lite specification for the compiler. */ class UnitModel extends ModelWithField { constructor(spec, parent, parentGivenName) { - var _spec$params; - let parentGivenSize = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; let config = arguments.length > 4 ? arguments[4] : undefined; super(spec, 'unit', parent, parentGivenName, config, undefined, isFrameMixins(spec) ? spec.view : undefined); _defineProperty(this, "markDef", void 0); @@ -24195,11 +23947,11 @@ this.specifiedScales = this.initScales(mark, encoding); this.specifiedAxes = this.initAxes(encoding); this.specifiedLegends = this.initLegends(encoding); this.specifiedProjection = spec.projection; // Selections will be initialized upon parse. - this.selection = ((_spec$params = spec.params) !== null && _spec$params !== void 0 ? _spec$params : []).filter(p => isSelectionParameter(p)); + this.selection = (spec.params ?? []).filter(p => isSelectionParameter(p)); } get hasProjection() { const { encoding @@ -24230,13 +23982,11 @@ initScales(mark, encoding) { return SCALE_CHANNELS.reduce((scales, channel) => { const fieldOrDatumDef = getFieldOrDatumDef(encoding[channel]); if (fieldOrDatumDef) { - var _fieldOrDatumDef$scal; - - scales[channel] = this.initScale((_fieldOrDatumDef$scal = fieldOrDatumDef.scale) !== null && _fieldOrDatumDef$scal !== void 0 ? _fieldOrDatumDef$scal : {}); + scales[channel] = this.initScale(fieldOrDatumDef.scale ?? {}); } return scales; }, {}); } @@ -24342,13 +24092,11 @@ assembleLayoutSignals() { return assembleLayoutSignals(this); } assembleMarks() { - var _this$component$mark; - - let marks = (_this$component$mark = this.component.mark) !== null && _this$component$mark !== void 0 ? _this$component$mark : []; // If this unit is part of a layer, selections should augment + let marks = this.component.mark ?? []; // If this unit is part of a layer, selections should augment // all in concert rather than each unit individually. This // ensures correct interleaving of clipping and brushed marks. if (!this.parent || !isLayerModel(this.parent)) { marks = assembleUnitSelectionMarks(this, marks); @@ -24418,12 +24166,12 @@ height: spec.height } : {}) }; this.children = spec.layer.map((layer, i) => { if (isLayerSpec(layer)) { - return new LayerModel(layer, this, this.getName("layer_".concat(i)), layoutSize, config); + return new LayerModel(layer, this, this.getName(`layer_${i}`), layoutSize, config); } else if (isUnitSpec(layer)) { - return new UnitModel(layer, this, this.getName("layer_".concat(i)), layoutSize, config); + return new UnitModel(layer, this, this.getName(`layer_${i}`), layoutSize, config); } throw new Error(invalidSpec(layer)); }); }