@uwdata/mosaic-spec 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12816,8 +12816,7 @@ var castInteger = (expr) => cast(expr, "INTEGER");
12816
12816
 
12817
12817
  // ../sql/src/datetime.js
12818
12818
  var epoch_ms = (expr) => {
12819
- const d = asColumn(expr);
12820
- return sql`(1000 * (epoch(${d}) - second(${d})) + millisecond(${d}))::DOUBLE`;
12819
+ return sql`epoch_ms(${asColumn(expr)})`;
12821
12820
  };
12822
12821
  var dateMonth = (expr) => {
12823
12822
  const d = asColumn(expr);
@@ -13238,6 +13237,89 @@ function isDoubleQuoted(s2) {
13238
13237
  return s2[0] === '"' && s2[s2.length - 1] === '"';
13239
13238
  }
13240
13239
 
13240
+ // ../sql/src/scales.js
13241
+ var identity = (x3) => x3;
13242
+ function scaleLinear() {
13243
+ return {
13244
+ apply: identity,
13245
+ invert: identity,
13246
+ sqlApply: asColumn,
13247
+ sqlInvert: identity
13248
+ };
13249
+ }
13250
+ function scaleLog({ base } = {}) {
13251
+ if (base == null || base === Math.E) {
13252
+ return {
13253
+ apply: Math.log,
13254
+ invert: Math.exp,
13255
+ sqlApply: (c4) => sql`LN(${asColumn(c4)})`,
13256
+ sqlInvert: (c4) => sql`EXP(${c4})`
13257
+ };
13258
+ } else if (base === 10) {
13259
+ return {
13260
+ apply: Math.log10,
13261
+ invert: (x3) => Math.pow(10, x3),
13262
+ sqlApply: (c4) => sql`LOG(${asColumn(c4)})`,
13263
+ sqlInvert: (c4) => sql`POW(10, ${c4})`
13264
+ };
13265
+ } else {
13266
+ const b = +base;
13267
+ return {
13268
+ apply: (x3) => Math.log(x3) / Math.log(b),
13269
+ invert: (x3) => Math.pow(b, x3),
13270
+ sqlApply: (c4) => sql`LN(${asColumn(c4)}) / LN(${b})`,
13271
+ sqlInvert: (c4) => sql`POW(${b}, ${c4})`
13272
+ };
13273
+ }
13274
+ }
13275
+ function scaleSymlog({ constant: constant2 = 1 } = {}) {
13276
+ const _ = +constant2;
13277
+ return {
13278
+ apply: (x3) => Math.sign(x3) * Math.log1p(Math.abs(x3)),
13279
+ invert: (x3) => Math.sign(x3) * Math.exp(Math.abs(x3) - _),
13280
+ sqlApply: (c4) => (c4 = asColumn(c4), sql`SIGN(${c4}) * LN(${_} + ABS(${c4}))`),
13281
+ sqlInvert: (c4) => sql`SIGN(${c4}) * (EXP(ABS(${c4})) - ${_})`
13282
+ };
13283
+ }
13284
+ function scaleSqrt() {
13285
+ return {
13286
+ apply: (x3) => Math.sign(x3) * Math.sqrt(Math.abs(x3)),
13287
+ invert: (x3) => Math.sign(x3) * x3 * x3,
13288
+ sqlApply: (c4) => (c4 = asColumn(c4), sql`SIGN(${c4}) * SQRT(ABS(${c4}))`),
13289
+ sqlInvert: (c4) => sql`SIGN(${c4}) * (${c4}) ** 2`
13290
+ };
13291
+ }
13292
+ function scalePow({ exponent = 1 } = {}) {
13293
+ const e = +exponent;
13294
+ return {
13295
+ apply: (x3) => Math.sign(x3) * Math.pow(Math.abs(x3), e),
13296
+ invert: (x3) => Math.sign(x3) * Math.pow(Math.abs(x3), 1 / e),
13297
+ sqlApply: (c4) => (c4 = asColumn(c4), sql`SIGN(${c4}) * POW(ABS(${c4}), ${e})`),
13298
+ sqlInvert: (c4) => sql`SIGN(${c4}) * POW(ABS(${c4}), 1/${e})`
13299
+ };
13300
+ }
13301
+ function scaleTime() {
13302
+ return {
13303
+ apply: (x3) => +x3,
13304
+ invert: (x3) => new Date(x3),
13305
+ sqlApply: (c4) => c4 instanceof Date ? +c4 : epoch_ms(asColumn(c4)),
13306
+ sqlInvert: identity
13307
+ };
13308
+ }
13309
+ var scales = {
13310
+ linear: scaleLinear,
13311
+ log: scaleLog,
13312
+ symlog: scaleSymlog,
13313
+ sqrt: scaleSqrt,
13314
+ pow: scalePow,
13315
+ time: scaleTime,
13316
+ utc: scaleTime
13317
+ };
13318
+ function scaleTransform(options) {
13319
+ const scale3 = scales[options.type];
13320
+ return scale3 ? { ...options, ...scale3(options) } : null;
13321
+ }
13322
+
13241
13323
  // ../sql/src/load/create.js
13242
13324
  function create(name2, query, {
13243
13325
  replace = false,
@@ -13479,7 +13561,6 @@ function fnv_mix(a2) {
13479
13561
  }
13480
13562
 
13481
13563
  // ../core/src/DataCubeIndexer.js
13482
- var identity = (x3) => x3;
13483
13564
  var DataCubeIndexer = class {
13484
13565
  /**
13485
13566
  *
@@ -13572,10 +13653,10 @@ function getActiveView(clause) {
13572
13653
  let columns = clause.predicate?.columns;
13573
13654
  if (!schema || !columns)
13574
13655
  return null;
13575
- const { type: type2, scales, pixelSize = 1 } = schema;
13656
+ const { type: type2, scales: scales2, pixelSize = 1 } = schema;
13576
13657
  let predicate;
13577
- if (type2 === "interval" && scales) {
13578
- const bins2 = scales.map((s2) => binInterval(s2, pixelSize));
13658
+ if (type2 === "interval" && scales2) {
13659
+ const bins2 = scales2.map((s2) => binInterval(s2, pixelSize));
13579
13660
  if (bins2.some((b) => b == null))
13580
13661
  return null;
13581
13662
  if (bins2.length === 1) {
@@ -13588,7 +13669,7 @@ function getActiveView(clause) {
13588
13669
  );
13589
13670
  }
13590
13671
  } else if (type2 === "point") {
13591
- predicate = identity;
13672
+ predicate = (x3) => x3;
13592
13673
  columns = Object.fromEntries(columns.map((col) => [col.toString(), col]));
13593
13674
  } else {
13594
13675
  return null;
@@ -13596,39 +13677,15 @@ function getActiveView(clause) {
13596
13677
  return { source, columns, predicate };
13597
13678
  }
13598
13679
  function binInterval(scale3, pixelSize) {
13599
- const { type: type2, domain, range: range3 } = scale3;
13600
- let lift, toSql;
13601
- switch (type2) {
13602
- case "linear":
13603
- lift = identity;
13604
- toSql = asColumn;
13605
- break;
13606
- case "log":
13607
- lift = Math.log;
13608
- toSql = (c4) => sql`LN(${asColumn(c4)})`;
13609
- break;
13610
- case "symlog":
13611
- lift = (x3) => Math.sign(x3) * Math.log1p(Math.abs(x3));
13612
- toSql = (c4) => (c4 = asColumn(c4), sql`SIGN(${c4}) * LN(1 + ABS(${c4}))`);
13613
- break;
13614
- case "sqrt":
13615
- lift = Math.sqrt;
13616
- toSql = (c4) => sql`SQRT(${asColumn(c4)})`;
13617
- break;
13618
- case "utc":
13619
- case "time":
13620
- lift = (x3) => +x3;
13621
- toSql = (c4) => c4 instanceof Date ? +c4 : epoch_ms(asColumn(c4));
13622
- break;
13680
+ const { apply: apply2, sqlApply } = scaleTransform(scale3);
13681
+ if (apply2) {
13682
+ const { domain, range: range3 } = scale3;
13683
+ const lo = apply2(Math.min(...domain));
13684
+ const hi = apply2(Math.max(...domain));
13685
+ const a2 = Math.abs(range3[1] - range3[0]) / (hi - lo) / pixelSize;
13686
+ const s2 = pixelSize === 1 ? "" : `${pixelSize}::INTEGER * `;
13687
+ return (value) => sql`${s2}FLOOR(${a2}::DOUBLE * (${sqlApply(value)} - ${lo}::DOUBLE))::INTEGER`;
13623
13688
  }
13624
- return lift ? binFunction(domain, range3, pixelSize, lift, toSql) : null;
13625
- }
13626
- function binFunction(domain, range3, pixelSize, lift, toSql) {
13627
- const lo = lift(Math.min(domain[0], domain[1]));
13628
- const hi = lift(Math.max(domain[0], domain[1]));
13629
- const a2 = Math.abs(lift(range3[1]) - lift(range3[0])) / (hi - lo) / pixelSize;
13630
- const s2 = pixelSize === 1 ? "" : `${pixelSize}::INTEGER * `;
13631
- return (value) => sql`${s2}FLOOR(${a2}::DOUBLE * (${toSql(value)} - ${lo}::DOUBLE))::INTEGER`;
13632
13689
  }
13633
13690
  var NO_INDEX = { from: NaN };
13634
13691
  function getIndexColumns(client) {
@@ -14883,8 +14940,11 @@ __export(api_exports, {
14883
14940
  centroidX: () => centroidX,
14884
14941
  centroidY: () => centroidY,
14885
14942
  circle: () => circle2,
14943
+ colorBase: () => colorBase,
14886
14944
  colorClamp: () => colorClamp,
14945
+ colorConstant: () => colorConstant2,
14887
14946
  colorDomain: () => colorDomain,
14947
+ colorExponent: () => colorExponent,
14888
14948
  colorInterpolate: () => colorInterpolate,
14889
14949
  colorLabel: () => colorLabel,
14890
14950
  colorLegend: () => colorLegend,
@@ -14893,8 +14953,8 @@ __export(api_exports, {
14893
14953
  colorPivot: () => colorPivot,
14894
14954
  colorRange: () => colorRange,
14895
14955
  colorReverse: () => colorReverse,
14896
- colorScale: () => colorScale,
14897
- colorScheme: () => colorScheme,
14956
+ colorScale: () => colorScale2,
14957
+ colorScheme: () => colorScheme2,
14898
14958
  colorSymmetric: () => colorSymmetric,
14899
14959
  colorTickFormat: () => colorTickFormat,
14900
14960
  colorZero: () => colorZero,
@@ -14928,6 +14988,7 @@ __export(api_exports, {
14928
14988
  facetMarginLeft: () => facetMarginLeft,
14929
14989
  facetMarginRight: () => facetMarginRight,
14930
14990
  facetMarginTop: () => facetMarginTop,
14991
+ first: () => first,
14931
14992
  first_value: () => first_value,
14932
14993
  frame: () => frame3,
14933
14994
  from: () => from,
@@ -14996,6 +15057,7 @@ __export(api_exports, {
14996
15057
  gt: () => gt,
14997
15058
  gte: () => gte,
14998
15059
  hconcat: () => hconcat,
15060
+ heatmap: () => heatmap,
14999
15061
  height: () => height,
15000
15062
  hexagon: () => hexagon2,
15001
15063
  hexbin: () => hexbin2,
@@ -15020,8 +15082,11 @@ __export(api_exports, {
15020
15082
  last: () => last,
15021
15083
  last_value: () => last_value,
15022
15084
  lead: () => lead,
15085
+ lengthBase: () => lengthBase,
15023
15086
  lengthClamp: () => lengthClamp,
15087
+ lengthConstant: () => lengthConstant,
15024
15088
  lengthDomain: () => lengthDomain,
15089
+ lengthExponent: () => lengthExponent,
15025
15090
  lengthNice: () => lengthNice,
15026
15091
  lengthRange: () => lengthRange,
15027
15092
  lengthScale: () => lengthScale,
@@ -15058,8 +15123,11 @@ __export(api_exports, {
15058
15123
  not: () => not,
15059
15124
  nth_value: () => nth_value,
15060
15125
  ntile: () => ntile,
15126
+ opacityBase: () => opacityBase,
15061
15127
  opacityClamp: () => opacityClamp,
15128
+ opacityConstant: () => opacityConstant,
15062
15129
  opacityDomain: () => opacityDomain,
15130
+ opacityExponent: () => opacityExponent,
15063
15131
  opacityLabel: () => opacityLabel,
15064
15132
  opacityLegend: () => opacityLegend,
15065
15133
  opacityNice: () => opacityNice,
@@ -15091,14 +15159,17 @@ __export(api_exports, {
15091
15159
  projectionRotate: () => projectionRotate,
15092
15160
  projectionType: () => projectionType,
15093
15161
  quantile: () => quantile,
15162
+ rBase: () => rBase,
15094
15163
  rClamp: () => rClamp,
15164
+ rConstant: () => rConstant,
15095
15165
  rDomain: () => rDomain,
15166
+ rExponent: () => rExponent,
15096
15167
  rNice: () => rNice,
15097
15168
  rRange: () => rRange,
15098
15169
  rScale: () => rScale,
15099
15170
  rZero: () => rZero,
15100
15171
  rank: () => rank,
15101
- raster: () => raster3,
15172
+ raster: () => raster2,
15102
15173
  rasterTile: () => rasterTile,
15103
15174
  rect: () => rect2,
15104
15175
  rectX: () => rectX2,
@@ -15144,8 +15215,11 @@ __export(api_exports, {
15144
15215
  xAriaDescription: () => xAriaDescription,
15145
15216
  xAriaLabel: () => xAriaLabel,
15146
15217
  xAxis: () => xAxis,
15218
+ xBase: () => xBase,
15147
15219
  xClamp: () => xClamp,
15220
+ xConstant: () => xConstant,
15148
15221
  xDomain: () => xDomain,
15222
+ xExponent: () => xExponent,
15149
15223
  xFontVariant: () => xFontVariant,
15150
15224
  xGrid: () => xGrid,
15151
15225
  xInset: () => xInset,
@@ -15175,8 +15249,11 @@ __export(api_exports, {
15175
15249
  yAriaDescription: () => yAriaDescription,
15176
15250
  yAriaLabel: () => yAriaLabel,
15177
15251
  yAxis: () => yAxis,
15252
+ yBase: () => yBase,
15178
15253
  yClamp: () => yClamp,
15254
+ yConstant: () => yConstant,
15179
15255
  yDomain: () => yDomain,
15256
+ yExponent: () => yExponent,
15180
15257
  yFontVariant: () => yFontVariant,
15181
15258
  yGrid: () => yGrid,
15182
15259
  yInset: () => yInset,
@@ -29735,10 +29812,10 @@ function createChannels(channels, data) {
29735
29812
  Object.entries(channels).map(([name2, channel]) => [name2, createChannel(data, channel, name2)])
29736
29813
  );
29737
29814
  }
29738
- function valueObject(channels, scales) {
29815
+ function valueObject(channels, scales2) {
29739
29816
  const values2 = Object.fromEntries(
29740
29817
  Object.entries(channels).map(([name2, { scale: scaleName, value }]) => {
29741
- const scale3 = scaleName == null ? null : scales[scaleName];
29818
+ const scale3 = scaleName == null ? null : scales2[scaleName];
29742
29819
  return [name2, scale3 == null ? value : map2(value, scale3)];
29743
29820
  })
29744
29821
  );
@@ -30540,14 +30617,14 @@ function projectionAspectRatio(projection3) {
30540
30617
  }
30541
30618
  return defaultAspectRatio;
30542
30619
  }
30543
- function applyPosition(channels, scales, { projection: projection3 }) {
30620
+ function applyPosition(channels, scales2, { projection: projection3 }) {
30544
30621
  const { x: x3, y: y3 } = channels;
30545
30622
  let position3 = {};
30546
30623
  if (x3)
30547
30624
  position3.x = x3;
30548
30625
  if (y3)
30549
30626
  position3.y = y3;
30550
- position3 = valueObject(position3, scales);
30627
+ position3 = valueObject(position3, scales2);
30551
30628
  if (projection3 && x3?.scale === "x" && y3?.scale === "y")
30552
30629
  project("x", "y", position3, projection3);
30553
30630
  if (x3)
@@ -31285,7 +31362,7 @@ function createScales(channelsByScale, {
31285
31362
  facet: { label: facetLabel2 = globalLabel } = {},
31286
31363
  ...options
31287
31364
  } = {}) {
31288
- const scales = {};
31365
+ const scales2 = {};
31289
31366
  for (const [key, channels] of channelsByScale) {
31290
31367
  const scaleOptions = options[key];
31291
31368
  const scale3 = createScale(key, channels, {
@@ -31328,17 +31405,17 @@ function createScales(channelsByScale, {
31328
31405
  scale3.insetTop = +insetTop;
31329
31406
  scale3.insetBottom = +insetBottom;
31330
31407
  }
31331
- scales[key] = scale3;
31408
+ scales2[key] = scale3;
31332
31409
  }
31333
31410
  }
31334
- return scales;
31411
+ return scales2;
31335
31412
  }
31336
31413
  function createScaleFunctions(descriptors) {
31337
- const scales = {};
31338
- const scaleFunctions = { scales };
31414
+ const scales2 = {};
31415
+ const scaleFunctions = { scales: scales2 };
31339
31416
  for (const [key, descriptor] of Object.entries(descriptors)) {
31340
31417
  const { scale: scale3, type: type2, interval: interval2, label: label2 } = descriptor;
31341
- scales[key] = exposeScale(descriptor);
31418
+ scales2[key] = exposeScale(descriptor);
31342
31419
  scaleFunctions[key] = scale3;
31343
31420
  scale3.type = type2;
31344
31421
  if (interval2 != null)
@@ -31348,14 +31425,14 @@ function createScaleFunctions(descriptors) {
31348
31425
  }
31349
31426
  return scaleFunctions;
31350
31427
  }
31351
- function autoScaleRange(scales, dimensions) {
31352
- const { x: x3, y: y3, fx, fy } = scales;
31428
+ function autoScaleRange(scales2, dimensions) {
31429
+ const { x: x3, y: y3, fx, fy } = scales2;
31353
31430
  const superdimensions = fx || fy ? outerDimensions(dimensions) : dimensions;
31354
31431
  if (fx)
31355
31432
  autoScaleRangeX(fx, superdimensions);
31356
31433
  if (fy)
31357
31434
  autoScaleRangeY(fy, superdimensions);
31358
- const subdimensions = fx || fy ? innerDimensions(scales, dimensions) : dimensions;
31435
+ const subdimensions = fx || fy ? innerDimensions(scales2, dimensions) : dimensions;
31359
31436
  if (x3)
31360
31437
  autoScaleRangeX(x3, subdimensions);
31361
31438
  if (y3)
@@ -31698,11 +31775,11 @@ function scale2(options = {}) {
31698
31775
  throw new Error("invalid scale definition; no scale found");
31699
31776
  return scale3;
31700
31777
  }
31701
- function exposeScales(scales) {
31778
+ function exposeScales(scales2) {
31702
31779
  return (key) => {
31703
31780
  if (!registry.has(key = `${key}`))
31704
31781
  throw new Error(`unknown scale: ${key}`);
31705
- return scales[key];
31782
+ return scales2[key];
31706
31783
  };
31707
31784
  }
31708
31785
  function exposeScale({ scale: scale3, type: type2, domain, range: range3, interpolate, interval: interval2, transform: transform3, percent, pivot }) {
@@ -31742,7 +31819,7 @@ function exposeScale({ scale: scale3, type: type2, domain, range: range3, interp
31742
31819
  }
31743
31820
 
31744
31821
  // ../../node_modules/@observablehq/plot/src/dimensions.js
31745
- function createDimensions(scales, marks2, options = {}) {
31822
+ function createDimensions(scales2, marks2, options = {}) {
31746
31823
  let marginTopDefault = 0.5 - offset, marginRightDefault = 0.5 + offset, marginBottomDefault = 0.5 + offset, marginLeftDefault = 0.5 - offset;
31747
31824
  for (const { marginTop: marginTop3, marginRight: marginRight3, marginBottom: marginBottom3, marginLeft: marginLeft3 } of marks2) {
31748
31825
  if (marginTop3 > marginTopDefault)
@@ -31767,7 +31844,7 @@ function createDimensions(scales, marks2, options = {}) {
31767
31844
  marginLeft2 = +marginLeft2;
31768
31845
  let {
31769
31846
  width: width2 = 640,
31770
- height: height2 = autoHeight(scales, options, {
31847
+ height: height2 = autoHeight(scales2, options, {
31771
31848
  width: width2,
31772
31849
  marginTopDefault,
31773
31850
  marginRightDefault,
@@ -31785,7 +31862,7 @@ function createDimensions(scales, marks2, options = {}) {
31785
31862
  marginBottom: marginBottom2,
31786
31863
  marginLeft: marginLeft2
31787
31864
  };
31788
- if (scales.fx || scales.fy) {
31865
+ if (scales2.fx || scales2.fy) {
31789
31866
  let {
31790
31867
  margin: facetMargin2,
31791
31868
  marginTop: facetMarginTop2 = facetMargin2 !== void 0 ? facetMargin2 : marginTop2,
@@ -32131,8 +32208,8 @@ var Mark = class {
32131
32208
  }
32132
32209
  }
32133
32210
  }
32134
- scale(channels, scales, context) {
32135
- const values2 = valueObject(channels, scales);
32211
+ scale(channels, scales2, context) {
32212
+ const values2 = valueObject(channels, scales2);
32136
32213
  if (context.projection)
32137
32214
  this.project(channels, values2, context);
32138
32215
  return values2;
@@ -32190,7 +32267,7 @@ function pointerK(kx2, ky2, { x: x3, y: y3, px, py, maxRadius = 40, channels, re
32190
32267
  // Unlike other composed transforms, the render transform must be the
32191
32268
  // outermost render function because it will re-render dynamically in
32192
32269
  // response to pointer events.
32193
- render: composeRender(function(index2, scales, values2, dimensions, context, next) {
32270
+ render: composeRender(function(index2, scales2, values2, dimensions, context, next) {
32194
32271
  context = { ...context, pointerSticky: false };
32195
32272
  const svg = context.ownerSVGElement;
32196
32273
  const { data } = context.getMarkState(this);
@@ -32198,7 +32275,7 @@ function pointerK(kx2, ky2, { x: x3, y: y3, px, py, maxRadius = 40, channels, re
32198
32275
  if (!state)
32199
32276
  states.set(svg, state = { sticky: false, roots: [], renders: [] });
32200
32277
  let renderIndex = state.renders.push(render2) - 1;
32201
- const { x: x4, y: y4, fx, fy } = scales;
32278
+ const { x: x4, y: y4, fx, fy } = scales2;
32202
32279
  let tx = fx ? fx(index2.fx) - dimensions.marginLeft : 0;
32203
32280
  let ty = fy ? fy(index2.fy) - dimensions.marginTop : 0;
32204
32281
  if (x4?.bandwidth)
@@ -32254,7 +32331,7 @@ function pointerK(kx2, ky2, { x: x3, y: y3, px, py, maxRadius = 40, channels, re
32254
32331
  const I = i == null ? [] : [i];
32255
32332
  if (faceted)
32256
32333
  I.fx = index2.fx, I.fy = index2.fy, I.fi = index2.fi;
32257
- const r = next(I, scales, values2, dimensions, context);
32334
+ const r = next(I, scales2, values2, dimensions, context);
32258
32335
  if (g) {
32259
32336
  if (faceted) {
32260
32337
  const p = g.parentNode;
@@ -32626,8 +32703,8 @@ var RuleX = class extends Mark {
32626
32703
  this.insetBottom = number5(insetBottom);
32627
32704
  markers(this, options);
32628
32705
  }
32629
- render(index2, scales, channels, dimensions, context) {
32630
- const { x: x3, y: y3 } = scales;
32706
+ render(index2, scales2, channels, dimensions, context) {
32707
+ const { x: x3, y: y3 } = scales2;
32631
32708
  const { x: X3, y1: Y13, y2: Y23 } = channels;
32632
32709
  const { width: width2, height: height2, marginTop: marginTop2, marginRight: marginRight2, marginLeft: marginLeft2, marginBottom: marginBottom2 } = dimensions;
32633
32710
  const { insetTop, insetBottom } = this;
@@ -32656,8 +32733,8 @@ var RuleY = class extends Mark {
32656
32733
  this.insetLeft = number5(insetLeft);
32657
32734
  markers(this, options);
32658
32735
  }
32659
- render(index2, scales, channels, dimensions, context) {
32660
- const { x: x3, y: y3 } = scales;
32736
+ render(index2, scales2, channels, dimensions, context) {
32737
+ const { x: x3, y: y3 } = scales2;
32661
32738
  const { y: Y3, x1: X13, x2: X23 } = channels;
32662
32739
  const { width: width2, height: height2, marginTop: marginTop2, marginRight: marginRight2, marginLeft: marginLeft2, marginBottom: marginBottom2 } = dimensions;
32663
32740
  const { insetLeft, insetRight } = this;
@@ -32779,8 +32856,8 @@ var Text = class extends Mark {
32779
32856
  this.splitLines = splitter2(this);
32780
32857
  this.clipLine = clipper(this);
32781
32858
  }
32782
- render(index2, scales, channels, dimensions, context) {
32783
- const { x: x3, y: y3 } = scales;
32859
+ render(index2, scales2, channels, dimensions, context) {
32860
+ const { x: x3, y: y3 } = scales2;
32784
32861
  const { x: X3, y: Y3, rotate: R, text: T, title: TL, fontSize: FS } = channels;
32785
32862
  const { rotate } = this;
32786
32863
  const [cx, cy] = applyFrameAnchor(this, dimensions);
@@ -33203,8 +33280,8 @@ var Vector2 = class extends Mark {
33203
33280
  this.anchor = keyword(anchor, "anchor", ["start", "middle", "end"]);
33204
33281
  this.frameAnchor = maybeFrameAnchor(frameAnchor);
33205
33282
  }
33206
- render(index2, scales, channels, dimensions, context) {
33207
- const { x: x3, y: y3 } = scales;
33283
+ render(index2, scales2, channels, dimensions, context) {
33284
+ const { x: x3, y: y3 } = scales2;
33208
33285
  const { x: X3, y: Y3, length: L, rotate: A5 } = channels;
33209
33286
  const { length: length4, rotate, anchor, shape, r } = this;
33210
33287
  const [cx, cy] = applyFrameAnchor(this, dimensions);
@@ -33356,8 +33433,8 @@ function axisKy(k2, anchor, data, {
33356
33433
  }) : null,
33357
33434
  !isNoneish(fill) && label2 !== null ? text(
33358
33435
  [],
33359
- labelOptions({ fill, fillOpacity, ...options }, function(data2, facets, channels, scales, dimensions) {
33360
- const scale3 = scales[k2];
33436
+ labelOptions({ fill, fillOpacity, ...options }, function(data2, facets, channels, scales2, dimensions) {
33437
+ const scale3 = scales2[k2];
33361
33438
  const { marginTop: marginTop3, marginRight: marginRight3, marginBottom: marginBottom3, marginLeft: marginLeft3 } = k2 === "y" && dimensions.inset || dimensions;
33362
33439
  const cla = labelAnchor ?? (scale3.bandwidth ? "center" : "top");
33363
33440
  const clo = labelOffset ?? (anchor === "right" ? marginRight3 : marginLeft3) - 3;
@@ -33446,8 +33523,8 @@ function axisKx(k2, anchor, data, {
33446
33523
  }) : null,
33447
33524
  !isNoneish(fill) && label2 !== null ? text(
33448
33525
  [],
33449
- labelOptions({ fill, fillOpacity, ...options }, function(data2, facets, channels, scales, dimensions) {
33450
- const scale3 = scales[k2];
33526
+ labelOptions({ fill, fillOpacity, ...options }, function(data2, facets, channels, scales2, dimensions) {
33527
+ const scale3 = scales2[k2];
33451
33528
  const { marginTop: marginTop3, marginRight: marginRight3, marginBottom: marginBottom3, marginLeft: marginLeft3 } = k2 === "x" && dimensions.inset || dimensions;
33452
33529
  const cla = labelAnchor ?? (scale3.bandwidth ? "center" : "right");
33453
33530
  const clo = labelOffset ?? (anchor === "top" ? marginTop3 : marginBottom3) - 3;
@@ -33691,9 +33768,9 @@ function labelOptions({
33691
33768
  }
33692
33769
  function axisMark(mark2, k2, anchor, ariaLabel, data, options, initialize) {
33693
33770
  let channels;
33694
- function axisInitializer(data2, facets, _channels, scales, dimensions, context) {
33771
+ function axisInitializer(data2, facets, _channels, scales2, dimensions, context) {
33695
33772
  const initializeFacets = data2 == null && (k2 === "fx" || k2 === "fy");
33696
- const { [k2]: scale3 } = scales;
33773
+ const { [k2]: scale3 } = scales2;
33697
33774
  if (!scale3)
33698
33775
  throw new Error(`missing scale: ${k2}`);
33699
33776
  const domain = scale3.domain();
@@ -33980,13 +34057,13 @@ function legend(options = {}) {
33980
34057
  }
33981
34058
  throw new Error("unknown legend type; no scale found");
33982
34059
  }
33983
- function exposeLegends(scales, context, defaults23 = {}) {
34060
+ function exposeLegends(scales2, context, defaults23 = {}) {
33984
34061
  return (key, options) => {
33985
34062
  if (!legendRegistry.has(key))
33986
34063
  throw new Error(`unknown legend type: ${key}`);
33987
- if (!(key in scales))
34064
+ if (!(key in scales2))
33988
34065
  return;
33989
- return legendRegistry.get(key)(scales[key], legendOptions(context, defaults23[key], options), (key2) => scales[key2]);
34066
+ return legendRegistry.get(key)(scales2[key], legendOptions(context, defaults23[key], options), (key2) => scales2[key2]);
33990
34067
  };
33991
34068
  }
33992
34069
  function legendOptions({ className, ...context }, { label: label2, ticks: ticks2, tickFormat: tickFormat2 } = {}, options) {
@@ -34019,12 +34096,12 @@ function interpolateOpacity(color3) {
34019
34096
  const { r, g, b } = rgb(color3) || rgb(0, 0, 0);
34020
34097
  return (t) => `rgba(${r},${g},${b},${t})`;
34021
34098
  }
34022
- function createLegends(scales, context, options) {
34099
+ function createLegends(scales2, context, options) {
34023
34100
  const legends = [];
34024
34101
  for (const [key, value] of legendRegistry) {
34025
34102
  const o = options[key];
34026
- if (o?.legend && key in scales) {
34027
- const legend3 = value(scales[key], legendOptions(context, scales[key], o), (key2) => scales[key2]);
34103
+ if (o?.legend && key in scales2) {
34104
+ const legend3 = value(scales2[key], legendOptions(context, scales2[key], o), (key2) => scales2[key2]);
34028
34105
  if (legend3 != null)
34029
34106
  legends.push(legend3);
34030
34107
  }
@@ -34067,7 +34144,7 @@ var Frame = class extends Mark {
34067
34144
  this.rx = number5(rx);
34068
34145
  this.ry = number5(ry);
34069
34146
  }
34070
- render(index2, scales, channels, dimensions, context) {
34147
+ render(index2, scales2, channels, dimensions, context) {
34071
34148
  const { marginTop: marginTop2, marginRight: marginRight2, marginBottom: marginBottom2, marginLeft: marginLeft2, width: width2, height: height2 } = dimensions;
34072
34149
  const { anchor, insetTop, insetRight, insetBottom, insetLeft, rx, ry } = this;
34073
34150
  const x12 = marginLeft2 + insetLeft;
@@ -34162,9 +34239,9 @@ var Tip = class extends Mark {
34162
34239
  this.clipLine = clipper(this);
34163
34240
  this.format = { ...format3 };
34164
34241
  }
34165
- render(index2, scales, values2, dimensions, context) {
34242
+ render(index2, scales2, values2, dimensions, context) {
34166
34243
  const mark2 = this;
34167
- const { x: x3, y: y3, fx, fy } = scales;
34244
+ const { x: x3, y: y3, fx, fy } = scales2;
34168
34245
  const { ownerSVGElement: svg, document: document2 } = context;
34169
34246
  const { anchor, monospace, lineHeight, lineWidth } = this;
34170
34247
  const { textPadding: r, pointerSize: m, pathFilter } = this;
@@ -34182,7 +34259,7 @@ var Tip = class extends Mark {
34182
34259
  sources = values2.channels;
34183
34260
  format3 = formatTitle;
34184
34261
  } else {
34185
- sources = getSourceChannels.call(this, values2, scales);
34262
+ sources = getSourceChannels.call(this, values2, scales2);
34186
34263
  format3 = formatChannels;
34187
34264
  }
34188
34265
  const g = create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(applyIndirectTextStyles, this).call(applyTransform, this, { x: X3 && x3, y: Y3 && y3 }).call(
@@ -34192,7 +34269,7 @@ var Tip = class extends Mark {
34192
34269
  this.setAttribute("fill", "currentColor");
34193
34270
  this.setAttribute("fill-opacity", 1);
34194
34271
  this.setAttribute("stroke", "none");
34195
- const lines = format3.call(mark2, i, index2, sources, scales, values2);
34272
+ const lines = format3.call(mark2, i, index2, sources, scales2, values2);
34196
34273
  if (typeof lines === "string") {
34197
34274
  for (const line3 of mark2.splitLines(lines)) {
34198
34275
  renderLine(that, { value: mark2.clipLine(line3) });
@@ -34330,7 +34407,7 @@ function getPath(anchor, m, r, width2, height2) {
34330
34407
  return `M0,0l${m / 2},${-m / 2}v${m / 2 - h / 2}h${w}v${h}h${-w}v${m / 2 - h / 2}z`;
34331
34408
  }
34332
34409
  }
34333
- function getSourceChannels({ channels }, scales) {
34410
+ function getSourceChannels({ channels }, scales2) {
34334
34411
  const sources = {};
34335
34412
  let format3 = this.format;
34336
34413
  format3 = maybeExpandPairedFormat(format3, channels, "x");
@@ -34356,18 +34433,18 @@ function getSourceChannels({ channels }, scales) {
34356
34433
  sources[key] = source;
34357
34434
  }
34358
34435
  if (this.facet) {
34359
- if (scales.fx && !("fx" in format3))
34436
+ if (scales2.fx && !("fx" in format3))
34360
34437
  sources.fx = true;
34361
- if (scales.fy && !("fy" in format3))
34438
+ if (scales2.fy && !("fy" in format3))
34362
34439
  sources.fy = true;
34363
34440
  }
34364
34441
  for (const key in sources) {
34365
34442
  const format4 = this.format[key];
34366
34443
  if (typeof format4 === "string") {
34367
- const value = sources[key]?.value ?? scales[key]?.domain() ?? [];
34444
+ const value = sources[key]?.value ?? scales2[key]?.domain() ?? [];
34368
34445
  this.format[key] = (isTemporal(value) ? utcFormat : format)(format4);
34369
34446
  } else if (format4 === void 0 || format4 === true) {
34370
- const scale3 = scales[key];
34447
+ const scale3 = scales2[key];
34371
34448
  this.format[key] = scale3?.bandwidth ? inferTickFormat(scale3, scale3.domain()) : formatDefault;
34372
34449
  }
34373
34450
  }
@@ -34388,11 +34465,11 @@ function maybeExpandPairedFormat(format3, channels, key) {
34388
34465
  function formatTitle(i, index2, { title }) {
34389
34466
  return formatDefault(title.value[i], i);
34390
34467
  }
34391
- function* formatChannels(i, index2, channels, scales, values2) {
34468
+ function* formatChannels(i, index2, channels, scales2, values2) {
34392
34469
  for (const key in channels) {
34393
34470
  if (key === "fx" || key === "fy") {
34394
34471
  yield {
34395
- label: formatLabel(scales, channels, key),
34472
+ label: formatLabel(scales2, channels, key),
34396
34473
  value: this.format[key](index2[key], i)
34397
34474
  };
34398
34475
  continue;
@@ -34404,12 +34481,12 @@ function* formatChannels(i, index2, channels, scales, values2) {
34404
34481
  const channel = channels[key];
34405
34482
  if (key === "x2" && "x1" in channels) {
34406
34483
  yield {
34407
- label: formatPairLabel(scales, channels, "x"),
34484
+ label: formatPairLabel(scales2, channels, "x"),
34408
34485
  value: formatPair(this.format.x2, channels.x1, channel, i)
34409
34486
  };
34410
34487
  } else if (key === "y2" && "y1" in channels) {
34411
34488
  yield {
34412
- label: formatPairLabel(scales, channels, "y"),
34489
+ label: formatPairLabel(scales2, channels, "y"),
34413
34490
  value: formatPair(this.format.y2, channels.y1, channel, i)
34414
34491
  };
34415
34492
  } else {
@@ -34418,7 +34495,7 @@ function* formatChannels(i, index2, channels, scales, values2) {
34418
34495
  if (!defined(value) && scale3 == null)
34419
34496
  continue;
34420
34497
  yield {
34421
- label: formatLabel(scales, channels, key),
34498
+ label: formatLabel(scales2, channels, key),
34422
34499
  value: this.format[key](value, i),
34423
34500
  color: scale3 === "color" ? values2[key][i] : null,
34424
34501
  opacity: scale3 === "opacity" ? values2[key][i] : null
@@ -34429,14 +34506,14 @@ function* formatChannels(i, index2, channels, scales, values2) {
34429
34506
  function formatPair(formatValue, c1, c22, i) {
34430
34507
  return c22.hint?.length ? `${formatValue(c22.value[i] - c1.value[i], i)}` : `${formatValue(c1.value[i], i)}\u2013${formatValue(c22.value[i], i)}`;
34431
34508
  }
34432
- function formatPairLabel(scales, channels, key) {
34433
- const l1 = formatLabel(scales, channels, `${key}1`, key);
34434
- const l2 = formatLabel(scales, channels, `${key}2`, key);
34509
+ function formatPairLabel(scales2, channels, key) {
34510
+ const l1 = formatLabel(scales2, channels, `${key}1`, key);
34511
+ const l2 = formatLabel(scales2, channels, `${key}2`, key);
34435
34512
  return l1 === l2 ? l1 : `${l1}\u2013${l2}`;
34436
34513
  }
34437
- function formatLabel(scales, channels, key, defaultLabel = key) {
34514
+ function formatLabel(scales2, channels, key, defaultLabel = key) {
34438
34515
  const channel = channels[key];
34439
- const scale3 = scales[channel?.scale ?? key];
34516
+ const scale3 = scales2[channel?.scale ?? key];
34440
34517
  return String(scale3?.label ?? channel?.label ?? defaultLabel);
34441
34518
  }
34442
34519
 
@@ -34511,10 +34588,10 @@ function plot(options = {}) {
34511
34588
  const scaleDescriptors = createScales(addScaleChannels(channelsByScale, stateByMark, options), options);
34512
34589
  const dimensions = createDimensions(scaleDescriptors, marks2, options);
34513
34590
  autoScaleRange(scaleDescriptors, dimensions);
34514
- const scales = createScaleFunctions(scaleDescriptors);
34515
- const { fx, fy } = scales;
34591
+ const scales2 = createScaleFunctions(scaleDescriptors);
34592
+ const { fx, fy } = scales2;
34516
34593
  const subdimensions = fx || fy ? innerDimensions(scaleDescriptors, dimensions) : dimensions;
34517
- const superdimensions = fx || fy ? actualDimensions(scales, dimensions) : dimensions;
34594
+ const superdimensions = fx || fy ? actualDimensions(scales2, dimensions) : dimensions;
34518
34595
  const context = createContext(options);
34519
34596
  const document2 = context.document;
34520
34597
  const svg = creator_default("svg").call(document2.documentElement);
@@ -34540,7 +34617,7 @@ function plot(options = {}) {
34540
34617
  for (const [mark2, state] of stateByMark) {
34541
34618
  if (mark2.initializer != null) {
34542
34619
  const dimensions2 = mark2.facet === "super" ? superdimensions : subdimensions;
34543
- const update2 = mark2.initializer(state.data, state.facets, state.channels, scales, dimensions2, context);
34620
+ const update2 = mark2.initializer(state.data, state.facets, state.channels, scales2, dimensions2, context);
34544
34621
  if (update2.data !== void 0) {
34545
34622
  state.data = update2.data;
34546
34623
  }
@@ -34570,8 +34647,8 @@ function plot(options = {}) {
34570
34647
  const newScaleDescriptors = inheritScaleLabels(createScales(newChannelsByScale, options), scaleDescriptors);
34571
34648
  const { scales: newExposedScales, ...newScales } = createScaleFunctions(newScaleDescriptors);
34572
34649
  Object.assign(scaleDescriptors, newScaleDescriptors);
34573
- Object.assign(scales, newScales);
34574
- Object.assign(scales.scales, newExposedScales);
34650
+ Object.assign(scales2, newScales);
34651
+ Object.assign(scales2.scales, newExposedScales);
34575
34652
  }
34576
34653
  let facetDomains, facetTranslate;
34577
34654
  if (facets !== void 0) {
@@ -34580,7 +34657,7 @@ function plot(options = {}) {
34580
34657
  facetTranslate = facetTranslator(fx, fy, dimensions);
34581
34658
  }
34582
34659
  for (const [mark2, state] of stateByMark) {
34583
- state.values = mark2.scale(state.channels, scales, context);
34660
+ state.values = mark2.scale(state.channels, scales2, context);
34584
34661
  }
34585
34662
  const { width: width2, height: height2 } = dimensions;
34586
34663
  select_default2(svg).attr("class", className).attr("fill", "currentColor").attr("font-family", "system-ui, sans-serif").attr("font-size", 10).attr("text-anchor", "middle").attr("width", width2).attr("height", height2).attr("viewBox", `0 0 ${width2} ${height2}`).attr("aria-label", ariaLabel).attr("aria-description", ariaDescription).call(
@@ -34611,7 +34688,7 @@ function plot(options = {}) {
34611
34688
  if (index2.length === 0)
34612
34689
  continue;
34613
34690
  }
34614
- const node = mark2.render(index2, scales, values2, superdimensions, context);
34691
+ const node = mark2.render(index2, scales2, values2, superdimensions, context);
34615
34692
  if (node == null)
34616
34693
  continue;
34617
34694
  svg.appendChild(node);
@@ -34631,7 +34708,7 @@ function plot(options = {}) {
34631
34708
  index2 = subarray(index2);
34632
34709
  index2.fx = f.x, index2.fy = f.y, index2.fi = f.i;
34633
34710
  }
34634
- const node = mark2.render(index2, scales, values2, subdimensions, context);
34711
+ const node = mark2.render(index2, scales2, values2, subdimensions, context);
34635
34712
  if (node == null)
34636
34713
  continue;
34637
34714
  (g ??= select_default2(svg).append("g")).append(() => node).datum(f);
@@ -34659,7 +34736,7 @@ function plot(options = {}) {
34659
34736
  if (caption != null)
34660
34737
  figure.append(createFigcaption(document2, caption));
34661
34738
  }
34662
- figure.scale = exposeScales(scales.scales);
34739
+ figure.scale = exposeScales(scales2.scales);
34663
34740
  figure.legend = exposeLegends(scaleDescriptors, context, options);
34664
34741
  figure.projection = context.projection;
34665
34742
  const w = consumeWarnings();
@@ -34806,7 +34883,7 @@ function maybeMarkFacet(mark2, topFacetState, options) {
34806
34883
  }
34807
34884
  }
34808
34885
  function derive(mark2, options = {}) {
34809
- return initializer({ ...options, x: null, y: null }, (data, facets, channels, scales, dimensions, context) => {
34886
+ return initializer({ ...options, x: null, y: null }, (data, facets, channels, scales2, dimensions, context) => {
34810
34887
  return context.getMarkState(mark2);
34811
34888
  });
34812
34889
  }
@@ -34981,10 +35058,10 @@ function hasPositionChannel(k2, marks2) {
34981
35058
  }
34982
35059
  return false;
34983
35060
  }
34984
- function inheritScaleLabels(newScales, scales) {
35061
+ function inheritScaleLabels(newScales, scales2) {
34985
35062
  for (const key in newScales) {
34986
35063
  const newScale = newScales[key];
34987
- const scale3 = scales[key];
35064
+ const scale3 = scales2[key];
34988
35065
  if (newScale.label === void 0 && scale3) {
34989
35066
  newScale.label = scale3.label;
34990
35067
  }
@@ -35872,9 +35949,9 @@ var Area = class extends Mark {
35872
35949
  filter(index2) {
35873
35950
  return index2;
35874
35951
  }
35875
- render(index2, scales, channels, dimensions, context) {
35952
+ render(index2, scales2, channels, dimensions, context) {
35876
35953
  const { x1: X13, y1: Y13, x2: X23 = X13, y2: Y23 = Y13 } = channels;
35877
- return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(applyTransform, this, scales, 0, 0).call(
35954
+ return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(applyTransform, this, scales2, 0, 0).call(
35878
35955
  (g) => g.selectAll().data(groupIndex(index2, [X13, Y13, X23, Y23], this, channels)).enter().append("path").call(applyDirectStyles, this).call(applyGroupedChannelStyles, this, channels).attr(
35879
35956
  "d",
35880
35957
  area_default3().curve(this.curve).defined((i) => i >= 0).x0((i) => X13[i]).y0((i) => Y13[i]).x1((i) => X23[i]).y1((i) => Y23[i])
@@ -35925,10 +36002,10 @@ var Link = class extends Mark {
35925
36002
  super.project(channels, values2, context);
35926
36003
  }
35927
36004
  }
35928
- render(index2, scales, channels, dimensions, context) {
36005
+ render(index2, scales2, channels, dimensions, context) {
35929
36006
  const { x1: X13, y1: Y13, x2: X23 = X13, y2: Y23 = Y13 } = channels;
35930
36007
  const { curve } = this;
35931
- return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(applyTransform, this, scales).call(
36008
+ return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(applyTransform, this, scales2).call(
35932
36009
  (g) => g.selectAll().data(index2).enter().append("path").call(applyDirectStyles, this).attr(
35933
36010
  "d",
35934
36011
  curve === curveAuto && context.projection ? sphereLink(context.projection, X13, Y13, X23, Y23) : (i) => {
@@ -36023,13 +36100,13 @@ var Arrow = class extends Mark {
36023
36100
  this.insetEnd = +insetEnd;
36024
36101
  this.sweep = maybeSweep(sweep);
36025
36102
  }
36026
- render(index2, scales, channels, dimensions, context) {
36103
+ render(index2, scales2, channels, dimensions, context) {
36027
36104
  const { x1: X13, y1: Y13, x2: X23 = X13, y2: Y23 = Y13, SW } = channels;
36028
36105
  const { strokeWidth, bend, headAngle, headLength, insetStart, insetEnd } = this;
36029
36106
  const sw = SW ? (i) => SW[i] : constant(strokeWidth === void 0 ? 1 : strokeWidth);
36030
36107
  const wingAngle = headAngle * radians3 / 2;
36031
36108
  const wingScale = headLength / 1.5;
36032
- return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(applyTransform, this, scales).call(
36109
+ return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(applyTransform, this, scales2).call(
36033
36110
  (g) => g.selectAll().data(index2).enter().append("path").call(applyDirectStyles, this).attr("d", (i) => {
36034
36111
  let x12 = X13[i], y12 = Y13[i], x22 = X23[i], y22 = Y23[i];
36035
36112
  const lineLength = Math.hypot(x22 - x12, y22 - y12);
@@ -36118,17 +36195,17 @@ var AbstractBar = class extends Mark {
36118
36195
  this.rx = impliedString(rx, "auto");
36119
36196
  this.ry = impliedString(ry, "auto");
36120
36197
  }
36121
- render(index2, scales, channels, dimensions, context) {
36198
+ render(index2, scales2, channels, dimensions, context) {
36122
36199
  const { rx, ry } = this;
36123
- return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(this._transform, this, scales).call(
36124
- (g) => g.selectAll().data(index2).enter().append("rect").call(applyDirectStyles, this).attr("x", this._x(scales, channels, dimensions)).attr("width", this._width(scales, channels, dimensions)).attr("y", this._y(scales, channels, dimensions)).attr("height", this._height(scales, channels, dimensions)).call(applyAttr, "rx", rx).call(applyAttr, "ry", ry).call(applyChannelStyles, this, channels)
36200
+ return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(this._transform, this, scales2).call(
36201
+ (g) => g.selectAll().data(index2).enter().append("rect").call(applyDirectStyles, this).attr("x", this._x(scales2, channels, dimensions)).attr("width", this._width(scales2, channels, dimensions)).attr("y", this._y(scales2, channels, dimensions)).attr("height", this._height(scales2, channels, dimensions)).call(applyAttr, "rx", rx).call(applyAttr, "ry", ry).call(applyChannelStyles, this, channels)
36125
36202
  ).node();
36126
36203
  }
36127
- _x(scales, { x: X3 }, { marginLeft: marginLeft2 }) {
36204
+ _x(scales2, { x: X3 }, { marginLeft: marginLeft2 }) {
36128
36205
  const { insetLeft } = this;
36129
36206
  return X3 ? (i) => X3[i] + insetLeft : marginLeft2 + insetLeft;
36130
36207
  }
36131
- _y(scales, { y: Y3 }, { marginTop: marginTop2 }) {
36208
+ _y(scales2, { y: Y3 }, { marginTop: marginTop2 }) {
36132
36209
  const { insetTop } = this;
36133
36210
  return Y3 ? (i) => Y3[i] + insetTop : marginTop2 + insetTop;
36134
36211
  }
@@ -36286,8 +36363,8 @@ var Dot = class extends Mark {
36286
36363
  };
36287
36364
  }
36288
36365
  }
36289
- render(index2, scales, channels, dimensions, context) {
36290
- const { x: x3, y: y3 } = scales;
36366
+ render(index2, scales2, channels, dimensions, context) {
36367
+ const { x: x3, y: y3 } = scales2;
36291
36368
  const { x: X3, y: Y3, r: R, rotate: A5, symbol: S } = channels;
36292
36369
  const { r, rotate, symbol: symbol2 } = this;
36293
36370
  const [cx, cy] = applyFrameAnchor(this, dimensions);
@@ -36381,10 +36458,10 @@ var Line = class extends Mark {
36381
36458
  super.project(channels, values2, context);
36382
36459
  }
36383
36460
  }
36384
- render(index2, scales, channels, dimensions, context) {
36461
+ render(index2, scales2, channels, dimensions, context) {
36385
36462
  const { x: X3, y: Y3 } = channels;
36386
36463
  const { curve } = this;
36387
- return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(applyTransform, this, scales).call(
36464
+ return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(applyTransform, this, scales2).call(
36388
36465
  (g) => g.selectAll().data(groupIndex(index2, [X3, Y3], this, channels)).enter().append("path").call(applyDirectStyles, this).call(applyGroupedChannelStyles, this, channels).call(applyGroupedMarkers, this, channels, context).attr(
36389
36466
  "d",
36390
36467
  curve === curveAuto && context.projection ? sphereLine(context.projection, X3, Y3) : line_default2().curve(curve).defined((i) => i >= 0).x((i) => X3[i]).y((i) => Y3[i])
@@ -36458,8 +36535,8 @@ var Rect = class extends Mark {
36458
36535
  this.rx = impliedString(rx, "auto");
36459
36536
  this.ry = impliedString(ry, "auto");
36460
36537
  }
36461
- render(index2, scales, channels, dimensions, context) {
36462
- const { x: x3, y: y3 } = scales;
36538
+ render(index2, scales2, channels, dimensions, context) {
36539
+ const { x: x3, y: y3 } = scales2;
36463
36540
  const { x1: X13, y1: Y13, x2: X23, y2: Y23 } = channels;
36464
36541
  const { marginTop: marginTop2, marginRight: marginRight2, marginBottom: marginBottom2, marginLeft: marginLeft2, width: width2, height: height2 } = dimensions;
36465
36542
  const { projection: projection3 } = context;
@@ -37235,9 +37312,9 @@ var AbstractTick = class extends Mark {
37235
37312
  super(data, channels, options, defaults15);
37236
37313
  markers(this, options);
37237
37314
  }
37238
- render(index2, scales, channels, dimensions, context) {
37239
- return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(this._transform, this, scales).call(
37240
- (g) => g.selectAll().data(index2).enter().append("line").call(applyDirectStyles, this).attr("x1", this._x1(scales, channels, dimensions)).attr("x2", this._x2(scales, channels, dimensions)).attr("y1", this._y1(scales, channels, dimensions)).attr("y2", this._y2(scales, channels, dimensions)).call(applyChannelStyles, this, channels).call(applyMarkers, this, channels, context)
37315
+ render(index2, scales2, channels, dimensions, context) {
37316
+ return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(this._transform, this, scales2).call(
37317
+ (g) => g.selectAll().data(index2).enter().append("line").call(applyDirectStyles, this).attr("x1", this._x1(scales2, channels, dimensions)).attr("x2", this._x2(scales2, channels, dimensions)).attr("y1", this._y1(scales2, channels, dimensions)).attr("y2", this._y2(scales2, channels, dimensions)).call(applyChannelStyles, this, channels).call(applyMarkers, this, channels, context)
37241
37318
  ).node();
37242
37319
  }
37243
37320
  };
@@ -37258,10 +37335,10 @@ var TickX = class extends AbstractTick {
37258
37335
  _transform(selection2, mark2, { x: x3 }) {
37259
37336
  selection2.call(applyTransform, mark2, { x: x3 }, offset, 0);
37260
37337
  }
37261
- _x1(scales, { x: X3 }) {
37338
+ _x1(scales2, { x: X3 }) {
37262
37339
  return (i) => X3[i];
37263
37340
  }
37264
- _x2(scales, { x: X3 }) {
37341
+ _x2(scales2, { x: X3 }) {
37265
37342
  return (i) => X3[i];
37266
37343
  }
37267
37344
  _y1({ y: y3 }, { y: Y3 }, { marginTop: marginTop2 }) {
@@ -37298,10 +37375,10 @@ var TickY = class extends AbstractTick {
37298
37375
  const { insetRight } = this;
37299
37376
  return X3 && x3 ? (i) => X3[i] + x3.bandwidth() - insetRight : width2 - marginRight2 - insetRight;
37300
37377
  }
37301
- _y1(scales, { y: Y3 }) {
37378
+ _y1(scales2, { y: Y3 }) {
37302
37379
  return (i) => Y3[i];
37303
37380
  }
37304
- _y2(scales, { y: Y3 }) {
37381
+ _y2(scales2, { y: Y3 }) {
37305
37382
  return (i) => Y3[i];
37306
37383
  }
37307
37384
  };
@@ -37461,11 +37538,11 @@ var Raster = class extends AbstractRaster {
37461
37538
  this.imageRendering = impliedString(imageRendering, "auto");
37462
37539
  }
37463
37540
  // Ignore the color scale, so the fill channel is returned unscaled.
37464
- scale(channels, { color: color3, ...scales }, context) {
37465
- return super.scale(channels, scales, context);
37541
+ scale(channels, { color: color3, ...scales2 }, context) {
37542
+ return super.scale(channels, scales2, context);
37466
37543
  }
37467
- render(index2, scales, values2, dimensions, context) {
37468
- const color3 = scales[values2.channels.fill?.scale] ?? ((x3) => x3);
37544
+ render(index2, scales2, values2, dimensions, context) {
37545
+ const color3 = scales2[values2.channels.fill?.scale] ?? ((x3) => x3);
37469
37546
  const { x: X3, y: Y3 } = values2;
37470
37547
  const { document: document2 } = context;
37471
37548
  const [x12, y12, x22, y22] = renderBounds(values2, dimensions, context);
@@ -37514,7 +37591,7 @@ var Raster = class extends AbstractRaster {
37514
37591
  if (this.blur > 0)
37515
37592
  blurImage(image3, this.blur);
37516
37593
  context2d.putImageData(image3, 0, 0);
37517
- return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(applyTransform, this, scales).call(
37594
+ return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(applyTransform, this, scales2).call(
37518
37595
  (g2) => g2.append("image").attr("transform", `translate(${x12},${y12}) scale(${Math.sign(x22 - x12)},${Math.sign(y22 - y12)})`).attr("width", Math.abs(dx)).attr("height", Math.abs(dy)).attr("preserveAspectRatio", "none").call(applyAttr, "image-rendering", this.imageRendering).call(applyDirectStyles, this).attr("xlink:href", canvas.toDataURL())
37519
37596
  ).node();
37520
37597
  }
@@ -37546,7 +37623,7 @@ function renderBounds({ x1: x12, y1: y12, x2: x22, y2: y22 }, dimensions, { proj
37546
37623
  y22 && projection3 == null ? y22[0] : height2 - marginBottom2
37547
37624
  ];
37548
37625
  }
37549
- function rasterBounds({ x1: x12, y1: y12, x2: x22, y2: y22 }, scales, dimensions, context) {
37626
+ function rasterBounds({ x1: x12, y1: y12, x2: x22, y2: y22 }, scales2, dimensions, context) {
37550
37627
  const channels = {};
37551
37628
  if (x12)
37552
37629
  channels.x1 = x12;
@@ -37556,19 +37633,19 @@ function rasterBounds({ x1: x12, y1: y12, x2: x22, y2: y22 }, scales, dimensions
37556
37633
  channels.x2 = x22;
37557
37634
  if (y22)
37558
37635
  channels.y2 = y22;
37559
- return renderBounds(valueObject(channels, scales), dimensions, context);
37636
+ return renderBounds(valueObject(channels, scales2), dimensions, context);
37560
37637
  }
37561
37638
  function sampler(name2, options = {}) {
37562
37639
  const { [name2]: value } = options;
37563
37640
  if (typeof value !== "function")
37564
37641
  throw new Error(`invalid ${name2}: not a function`);
37565
- return initializer({ ...options, [name2]: void 0 }, function(data, facets, channels, scales, dimensions, context) {
37566
- const { x: x3, y: y3 } = scales;
37642
+ return initializer({ ...options, [name2]: void 0 }, function(data, facets, channels, scales2, dimensions, context) {
37643
+ const { x: x3, y: y3 } = scales2;
37567
37644
  if (!x3)
37568
37645
  throw new Error("missing scale: x");
37569
37646
  if (!y3)
37570
37647
  throw new Error("missing scale: y");
37571
- const [x12, y12, x22, y22] = rasterBounds(channels, scales, dimensions, context);
37648
+ const [x12, y12, x22, y22] = rasterBounds(channels, scales2, dimensions, context);
37572
37649
  const dx = x22 - x12;
37573
37650
  const dy = y22 - y12;
37574
37651
  const { pixelSize: k2 } = this;
@@ -37878,18 +37955,18 @@ var Contour = class extends AbstractRaster {
37878
37955
  filter(index2, { x: x3, y: y3, value, ...channels }, values2) {
37879
37956
  return super.filter(index2, channels, values2);
37880
37957
  }
37881
- render(index2, scales, channels, dimensions, context) {
37958
+ render(index2, scales2, channels, dimensions, context) {
37882
37959
  const { geometry: G } = channels;
37883
37960
  const path2 = path_default();
37884
- return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(applyTransform, this, scales).call((g) => {
37961
+ return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(applyTransform, this, scales2).call((g) => {
37885
37962
  g.selectAll().data(index2).enter().append("path").call(applyDirectStyles, this).attr("d", (i) => path2(G[i])).call(applyChannelStyles, this, channels);
37886
37963
  }).node();
37887
37964
  }
37888
37965
  };
37889
37966
  function contourGeometry({ thresholds, interval: interval2, ...options }) {
37890
37967
  thresholds = maybeThresholds(thresholds, interval2, thresholdSturges);
37891
- return initializer(options, function(data, facets, channels, scales, dimensions, context) {
37892
- const [x12, y12, x22, y22] = rasterBounds(channels, scales, dimensions, context);
37968
+ return initializer(options, function(data, facets, channels, scales2, dimensions, context) {
37969
+ const [x12, y12, x22, y22] = rasterBounds(channels, scales2, dimensions, context);
37893
37970
  const dx = x22 - x12;
37894
37971
  const dy = y22 - y12;
37895
37972
  const { pixelSize: k2, width: w = Math.round(Math.abs(dx) / k2), height: h = Math.round(Math.abs(dy) / k2) } = this;
@@ -37898,7 +37975,7 @@ function contourGeometry({ thresholds, interval: interval2, ...options }) {
37898
37975
  const V = channels.value.value;
37899
37976
  const VV = [];
37900
37977
  if (this.interpolate) {
37901
- const { x: X3, y: Y3 } = applyPosition(channels, scales, context);
37978
+ const { x: X3, y: Y3 } = applyPosition(channels, scales2, context);
37902
37979
  const IX = map2(X3, (x3) => (x3 - x12) * kx2, Float64Array);
37903
37980
  const IY = map2(Y3, (y3) => (y3 - y12) * ky2, Float64Array);
37904
37981
  const ichannels = [channels.x, channels.y, channels.value];
@@ -38109,8 +38186,8 @@ var DelaunayLink = class extends Mark {
38109
38186
  this.curve = maybeCurve(curve, tension);
38110
38187
  markers(this, options);
38111
38188
  }
38112
- render(index2, scales, channels, dimensions, context) {
38113
- const { x: x3, y: y3 } = scales;
38189
+ render(index2, scales2, channels, dimensions, context) {
38190
+ const { x: x3, y: y3 } = scales2;
38114
38191
  const { x: X3, y: Y3, z: Z } = channels;
38115
38192
  const { curve } = this;
38116
38193
  const [cx, cy] = applyFrameAnchor(this, dimensions);
@@ -38176,8 +38253,8 @@ var AbstractDelaunayMark = class extends Mark {
38176
38253
  defaults23
38177
38254
  );
38178
38255
  }
38179
- render(index2, scales, channels, dimensions, context) {
38180
- const { x: x3, y: y3 } = scales;
38256
+ render(index2, scales2, channels, dimensions, context) {
38257
+ const { x: x3, y: y3 } = scales2;
38181
38258
  const { x: X3, y: Y3, z: Z } = channels;
38182
38259
  const [cx, cy] = applyFrameAnchor(this, dimensions);
38183
38260
  const xi = X3 ? (i) => X3[i] : constant(cx);
@@ -38223,8 +38300,8 @@ var Voronoi2 = class extends Mark {
38223
38300
  voronoiDefaults
38224
38301
  );
38225
38302
  }
38226
- render(index2, scales, channels, dimensions, context) {
38227
- const { x: x3, y: y3 } = scales;
38303
+ render(index2, scales2, channels, dimensions, context) {
38304
+ const { x: x3, y: y3 } = scales2;
38228
38305
  const { x: X3, y: Y3, z: Z } = channels;
38229
38306
  const [cx, cy] = applyFrameAnchor(this, dimensions);
38230
38307
  const xi = X3 ? (i) => X3[i] : constant(cx);
@@ -38304,7 +38381,7 @@ var Density = class extends Mark {
38304
38381
  filter(index2) {
38305
38382
  return index2;
38306
38383
  }
38307
- render(index2, scales, channels, dimensions, context) {
38384
+ render(index2, scales2, channels, dimensions, context) {
38308
38385
  const { contours } = channels;
38309
38386
  const path2 = path_default();
38310
38387
  return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(applyTransform, this, {}).call(
@@ -38322,13 +38399,13 @@ function densityInitializer(options, fillDensity, strokeDensity) {
38322
38399
  let { bandwidth, thresholds } = options;
38323
38400
  bandwidth = bandwidth === void 0 ? 20 : +bandwidth;
38324
38401
  thresholds = thresholds === void 0 ? 20 : typeof thresholds?.[Symbol.iterator] === "function" ? coerceNumbers(thresholds) : +thresholds;
38325
- return initializer(options, function(data, facets, channels, scales, dimensions, context) {
38402
+ return initializer(options, function(data, facets, channels, scales2, dimensions, context) {
38326
38403
  const W = channels.weight ? coerceNumbers(channels.weight.value) : null;
38327
38404
  const Z = channels.z?.value;
38328
38405
  const { z } = this;
38329
38406
  const [cx, cy] = applyFrameAnchor(this, dimensions);
38330
38407
  const { width: width2, height: height2 } = dimensions;
38331
- const { x: X3, y: Y3 } = applyPosition(channels, scales, context);
38408
+ const { x: X3, y: Y3 } = applyPosition(channels, scales2, context);
38332
38409
  const newChannels = Object.fromEntries(
38333
38410
  Object.entries(channels).filter(([key]) => !dropChannels.has(key)).map(([key, channel]) => [key, { ...channel, value: [] }])
38334
38411
  );
@@ -38488,14 +38565,14 @@ function memo(v2) {
38488
38565
  return { transform: (data) => V || (V = valueof(data, value)), label: label2 };
38489
38566
  }
38490
38567
  function clipDifferenceY(positive2) {
38491
- return (index2, scales, channels, dimensions, context, next) => {
38568
+ return (index2, scales2, channels, dimensions, context, next) => {
38492
38569
  const { x1: x12, x2: x22 } = channels;
38493
38570
  const { height: height2 } = dimensions;
38494
38571
  const y12 = new Float32Array(x12.length);
38495
38572
  const y22 = new Float32Array(x22.length);
38496
- (positive2 === inferScaleOrder(scales.y) < 0 ? y12 : y22).fill(height2);
38497
- const oc = next(index2, scales, { ...channels, x2: x12, y2: y22 }, dimensions, context);
38498
- const og = next(index2, scales, { ...channels, x1: x22, y1: y12 }, dimensions, context);
38573
+ (positive2 === inferScaleOrder(scales2.y) < 0 ? y12 : y22).fill(height2);
38574
+ const oc = next(index2, scales2, { ...channels, x2: x12, y2: y22 }, dimensions, context);
38575
+ const og = next(index2, scales2, { ...channels, x1: x22, y1: y12 }, dimensions, context);
38499
38576
  const c4 = oc.querySelector("g") ?? oc;
38500
38577
  const g = og.querySelector("g") ?? og;
38501
38578
  for (let i = 0; c4.firstChild; i += 2) {
@@ -38533,15 +38610,15 @@ var Geo = class extends Mark {
38533
38610
  );
38534
38611
  this.r = cr;
38535
38612
  }
38536
- render(index2, scales, channels, dimensions, context) {
38613
+ render(index2, scales2, channels, dimensions, context) {
38537
38614
  const { geometry: G, r: R } = channels;
38538
- const path2 = path_default(context.projection ?? scaleProjection2(scales));
38615
+ const path2 = path_default(context.projection ?? scaleProjection2(scales2));
38539
38616
  const { r } = this;
38540
38617
  if (negative(r))
38541
38618
  index2 = [];
38542
38619
  else if (r !== void 0)
38543
38620
  path2.pointRadius(r);
38544
- return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(applyTransform, this, scales).call((g) => {
38621
+ return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(applyTransform, this, scales2).call((g) => {
38545
38622
  g.selectAll().data(index2).enter().append("path").call(applyDirectStyles, this).attr("d", R ? (i) => path2.pointRadius(R[i])(G[i]) : (i) => path2(G[i])).call(applyChannelStyles, this, channels);
38546
38623
  }).node();
38547
38624
  }
@@ -38598,13 +38675,13 @@ function hexbin(outputs = { fill: "count" }, { binWidth, ...options } = {}) {
38598
38675
  options.symbol = "hexagon";
38599
38676
  if (options.r === void 0 && !hasOutput(outputs, "r"))
38600
38677
  options.r = binWidth / 2;
38601
- return initializer(options, (data, facets, channels, scales, _, context) => {
38678
+ return initializer(options, (data, facets, channels, scales2, _, context) => {
38602
38679
  let { x: X3, y: Y3, z: Z, fill: F, stroke: S, symbol: Q } = channels;
38603
38680
  if (X3 === void 0)
38604
38681
  throw new Error("missing channel: x");
38605
38682
  if (Y3 === void 0)
38606
38683
  throw new Error("missing channel: y");
38607
- ({ x: X3, y: Y3 } = applyPosition(channels, scales, context));
38684
+ ({ x: X3, y: Y3 } = applyPosition(channels, scales2, context));
38608
38685
  Z = Z ? Z.value : valueof(data, z);
38609
38686
  F = F?.value;
38610
38687
  S = S?.value;
@@ -38646,8 +38723,8 @@ function hexbin(outputs = { fill: "count" }, { binWidth, ...options } = {}) {
38646
38723
  const sx = channels.x.scale;
38647
38724
  const sy = channels.y.scale;
38648
38725
  const binChannels = {
38649
- x: { value: BX, source: scales[sx] ? { value: map2(BX, scales[sx].invert), scale: sx } : null },
38650
- y: { value: BY, source: scales[sy] ? { value: map2(BY, scales[sy].invert), scale: sy } : null },
38726
+ x: { value: BX, source: scales2[sx] ? { value: map2(BX, scales2[sx].invert), scale: sx } : null },
38727
+ y: { value: BY, source: scales2[sy] ? { value: map2(BY, scales2[sy].invert), scale: sy } : null },
38651
38728
  ...Z && { z: { value: GZ } },
38652
38729
  ...F && { fill: { value: GF, scale: "auto" } },
38653
38730
  ...S && { stroke: { value: GS, scale: "auto" } },
@@ -38706,7 +38783,7 @@ var Hexgrid = class extends Mark {
38706
38783
  super(singleton, void 0, { clip, ...options }, defaults20);
38707
38784
  this.binWidth = number5(binWidth);
38708
38785
  }
38709
- render(index2, scales, channels, dimensions, context) {
38786
+ render(index2, scales2, channels, dimensions, context) {
38710
38787
  const { binWidth } = this;
38711
38788
  const { marginTop: marginTop2, marginRight: marginRight2, marginBottom: marginBottom2, marginLeft: marginLeft2, width: width2, height: height2 } = dimensions;
38712
38789
  const x06 = marginLeft2 - ox, x12 = width2 - marginRight2 - ox, y06 = marginTop2 - oy, y12 = height2 - marginBottom2 - oy, rx = binWidth / 2, ry = rx * sqrt4_3, hy = ry / 2, wx = rx * 2, wy = ry * 1.5, i0 = Math.floor(x06 / wx), i1 = Math.ceil(x12 / wx), j0 = Math.floor((y06 + hy) / wy), j1 = Math.ceil((y12 - hy) / wy) + 1, path2 = `m0,${round(-ry)}l${round(rx)},${round(hy)}v${round(ry)}l${round(-rx)},${round(hy)}`;
@@ -38778,8 +38855,8 @@ var Image = class extends Mark {
38778
38855
  this.frameAnchor = maybeFrameAnchor(frameAnchor);
38779
38856
  this.imageRendering = impliedString(imageRendering, "auto");
38780
38857
  }
38781
- render(index2, scales, channels, dimensions, context) {
38782
- const { x: x3, y: y3 } = scales;
38858
+ render(index2, scales2, channels, dimensions, context) {
38859
+ const { x: x3, y: y3 } = scales2;
38783
38860
  const { x: X3, y: Y3, width: W, height: H, r: R, rotate: A5, src: S } = channels;
38784
38861
  const { r, width: width2, height: height2, rotate } = this;
38785
38862
  const [cx, cy] = applyFrameAnchor(this, dimensions);
@@ -38949,10 +39026,10 @@ var LinearRegression = class extends Mark {
38949
39026
  if (!(this.precision > 0))
38950
39027
  throw new Error(`invalid precision: ${precision}`);
38951
39028
  }
38952
- render(index2, scales, channels, dimensions, context) {
39029
+ render(index2, scales2, channels, dimensions, context) {
38953
39030
  const { x: X3, y: Y3, z: Z } = channels;
38954
39031
  const { ci } = this;
38955
- return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(applyTransform, this, scales).call(
39032
+ return create3("svg:g", context).call(applyIndirectStyles, this, dimensions, context).call(applyTransform, this, scales2).call(
38956
39033
  (g) => g.selectAll().data(Z ? groupZ2(index2, Z, this.z) : [index2]).enter().call(
38957
39034
  (enter) => enter.append("path").attr("fill", "none").call(applyDirectStyles, this).call(applyGroupedChannelStyles, this, { ...channels, fill: null, fillOpacity: null }).attr("d", (I) => this._renderLine(I, X3, Y3)).call(
38958
39035
  ci && !isNone(this.fill) ? (path2) => path2.select(pathBefore).attr("stroke", "none").call(applyDirectStyles, this).call(applyGroupedChannelStyles, this, {
@@ -39464,7 +39541,7 @@ function cluster(data, options) {
39464
39541
 
39465
39542
  // ../../node_modules/@observablehq/plot/src/transforms/centroid.js
39466
39543
  function centroid2({ geometry = identity7, ...options } = {}) {
39467
- return initializer({ ...options, x: null, y: null }, (data, facets, channels, scales, dimensions, { projection: projection3 }) => {
39544
+ return initializer({ ...options, x: null, y: null }, (data, facets, channels, scales2, dimensions, { projection: projection3 }) => {
39468
39545
  const G = valueof(data, geometry);
39469
39546
  const n = G.length;
39470
39547
  const X3 = new Float64Array(n);
@@ -39554,14 +39631,14 @@ function dodge(y3, x3, anchor, padding2, r, options) {
39554
39631
  if (sort3 === void 0 && reverse3 === void 0)
39555
39632
  options.sort = { channel: "-r" };
39556
39633
  }
39557
- return initializer(options, function(data, facets, channels, scales, dimensions, context) {
39634
+ return initializer(options, function(data, facets, channels, scales2, dimensions, context) {
39558
39635
  let { [x3]: X3, r: R } = channels;
39559
39636
  if (!channels[x3])
39560
39637
  throw new Error(`missing channel: ${x3}`);
39561
- ({ [x3]: X3 } = applyPosition(channels, scales, context));
39638
+ ({ [x3]: X3 } = applyPosition(channels, scales2, context));
39562
39639
  const cr = R ? void 0 : r !== void 0 ? number5(r) : this.r !== void 0 ? this.r : 3;
39563
39640
  if (R)
39564
- R = valueof(R.value, scales[R.scale] || identity7, Float64Array);
39641
+ R = valueof(R.value, scales2[R.scale] || identity7, Float64Array);
39565
39642
  let [ky2, ty] = anchor(dimensions);
39566
39643
  const compare = ky2 ? compareAscending : compareSymmetric;
39567
39644
  const Y3 = new Float64Array(X3.length);
@@ -39891,6 +39968,9 @@ var attributeMap = /* @__PURE__ */ new Map([
39891
39968
  ["xAriaDescription", "x.ariaDescription"],
39892
39969
  ["xReverse", "x.reverse"],
39893
39970
  ["xZero", "x.zero"],
39971
+ ["xBase", "x.base"],
39972
+ ["xExponent", "x.exponent"],
39973
+ ["xConstant", "x.constant"],
39894
39974
  ["yScale", "y.type"],
39895
39975
  ["yDomain", "y.domain"],
39896
39976
  ["yRange", "y.range"],
@@ -39921,6 +40001,9 @@ var attributeMap = /* @__PURE__ */ new Map([
39921
40001
  ["yAriaDescription", "y.ariaDescription"],
39922
40002
  ["yReverse", "y.reverse"],
39923
40003
  ["yZero", "y.zero"],
40004
+ ["yBase", "y.base"],
40005
+ ["yExponent", "y.exponent"],
40006
+ ["yConstant", "y.constant"],
39924
40007
  ["facetMargin", "facet.margin"],
39925
40008
  ["facetMarginTop", "facet.marginTop"],
39926
40009
  ["facetMarginBottom", "facet.marginBottom"],
@@ -39996,6 +40079,9 @@ var attributeMap = /* @__PURE__ */ new Map([
39996
40079
  ["colorReverse", "color.reverse"],
39997
40080
  ["colorZero", "color.zero"],
39998
40081
  ["colorTickFormat", "color.tickFormat"],
40082
+ ["colorBase", "color.base"],
40083
+ ["colorExponent", "color.exponent"],
40084
+ ["colorConstant", "color.constant"],
39999
40085
  ["opacityScale", "opacity.type"],
40000
40086
  ["opacityDomain", "opacity.domain"],
40001
40087
  ["opacityRange", "opacity.range"],
@@ -40005,18 +40091,27 @@ var attributeMap = /* @__PURE__ */ new Map([
40005
40091
  ["opacityReverse", "opacity.reverse"],
40006
40092
  ["opacityZero", "opacity.zero"],
40007
40093
  ["opacityTickFormat", "opacity.tickFormat"],
40094
+ ["opacityBase", "opacity.base"],
40095
+ ["opacityExponent", "opacity.exponent"],
40096
+ ["opacityConstant", "opacity.constant"],
40008
40097
  ["rScale", "r.type"],
40009
40098
  ["rDomain", "r.domain"],
40010
40099
  ["rRange", "r.range"],
40011
40100
  ["rClamp", "r.clamp"],
40012
40101
  ["rNice", "r.nice"],
40013
40102
  ["rZero", "r.zero"],
40103
+ ["rBase", "r.base"],
40104
+ ["rExponent", "r.exponent"],
40105
+ ["rConstant", "r.constant"],
40014
40106
  ["lengthScale", "length.type"],
40015
40107
  ["lengthDomain", "length.domain"],
40016
40108
  ["lengthRange", "length.range"],
40017
40109
  ["lengthClamp", "length.clamp"],
40018
40110
  ["lengthNice", "length.nice"],
40019
40111
  ["lengthZero", "length.zero"],
40112
+ ["lengthBase", "length.base"],
40113
+ ["lengthExponent", "length.exponent"],
40114
+ ["lengthConstant", "length.constant"],
40020
40115
  ["projectionType", "projection.type"],
40021
40116
  ["projectionParallels", "projection.parallels"],
40022
40117
  ["projectionPrecision", "projection.precision"],
@@ -40373,14 +40468,26 @@ function isSymbol2(value) {
40373
40468
  return symbols2.has(`${value}`.toLowerCase());
40374
40469
  }
40375
40470
 
40376
- // ../plot/src/marks/util/is-arrow-table.js
40471
+ // ../plot/src/marks/util/arrow.js
40472
+ var INTEGER = 2;
40473
+ var FLOAT = 3;
40474
+ var DECIMAL = 7;
40475
+ var TIMESTAMP = 10;
40377
40476
  function isArrowTable(values2) {
40378
40477
  return typeof values2?.getChild === "function";
40379
40478
  }
40479
+ function convertArrow(type2) {
40480
+ const { typeId } = type2;
40481
+ if (typeId === TIMESTAMP) {
40482
+ return (v2) => v2 == null ? v2 : new Date(v2);
40483
+ }
40484
+ if (typeId === INTEGER && type2.bitWidth >= 64) {
40485
+ return (v2) => v2 == null ? v2 : Number(v2);
40486
+ }
40487
+ return (v2) => v2;
40488
+ }
40380
40489
 
40381
40490
  // ../plot/src/marks/util/to-data-array.js
40382
- var INTEGER = 2;
40383
- var TIMESTAMP = 10;
40384
40491
  function toDataArray(data) {
40385
40492
  return isArrowTable(data) ? arrowToObjects(data) : data;
40386
40493
  }
@@ -40395,7 +40502,7 @@ function arrowToObjects(data) {
40395
40502
  for (let j = 0; j < numCols; ++j) {
40396
40503
  const child = batch.getChildAt(j);
40397
40504
  const { name: name2, type: type2 } = schema.fields[j];
40398
- const valueOf = convert(type2);
40505
+ const valueOf = convertArrow(type2);
40399
40506
  for (let o = k2, i = 0; i < numRows; ++i, ++o) {
40400
40507
  objects[o][name2] = valueOf(child.get(i));
40401
40508
  }
@@ -40404,16 +40511,6 @@ function arrowToObjects(data) {
40404
40511
  }
40405
40512
  return objects;
40406
40513
  }
40407
- function convert(type2) {
40408
- const { typeId } = type2;
40409
- if (typeId === TIMESTAMP) {
40410
- return (v2) => v2 == null ? v2 : new Date(v2);
40411
- }
40412
- if (typeId === INTEGER && type2.bitWidth >= 64) {
40413
- return (v2) => v2 == null ? v2 : Number(v2);
40414
- }
40415
- return (v2) => v2;
40416
- }
40417
40514
 
40418
40515
  // ../plot/src/marks/Mark.js
40419
40516
  var isColorChannel = (channel) => channel === "stroke" || channel === "fill";
@@ -40590,19 +40687,43 @@ function markQuery(channels, table3, skip = []) {
40590
40687
  return q;
40591
40688
  }
40592
40689
 
40593
- // ../plot/src/marks/util/bin-field.js
40594
- function binField(mark2, channel, expr) {
40595
- if (!mark2.stats)
40596
- return field2;
40690
+ // ../plot/src/marks/util/channel-scale.js
40691
+ function channelScale(mark2, channel) {
40692
+ const { plot: plot3 } = mark2;
40693
+ let scaleType = plot3.getAttribute(`${channel}Scale`);
40694
+ if (!scaleType) {
40695
+ const { field: field2 } = mark2.channelField(channel, `${channel}1`, `${channel}2`);
40696
+ const { type: type2 } = mark2.stats[field2.column];
40697
+ scaleType = type2 === "date" ? "time" : "linear";
40698
+ }
40699
+ const options = { type: scaleType };
40700
+ switch (scaleType) {
40701
+ case "log":
40702
+ options.base = plot3.getAttribute(`${channel}Base`) ?? 10;
40703
+ break;
40704
+ case "pow":
40705
+ options.exponent = plot3.getAttribute(`${channel}Exponent`) ?? 1;
40706
+ break;
40707
+ case "symlog":
40708
+ options.constant = plot3.getAttribute(`${channel}Constant`) ?? 1;
40709
+ break;
40710
+ }
40711
+ return scaleTransform(options);
40712
+ }
40713
+
40714
+ // ../plot/src/marks/util/bin-expr.js
40715
+ function binExpr(mark2, channel, n, extent4, pad3 = 1, expr) {
40597
40716
  const { field: field2 } = mark2.channelField(channel);
40598
- const { type: type2 } = mark2.stats[field2.column];
40599
40717
  expr = expr ?? field2;
40600
- return type2 === "date" ? epoch_ms(expr) : expr;
40601
- }
40602
- function bin1d(x3, x06, x12, n, reverse3 = false, pad3 = 1) {
40603
- const d = (n - pad3) / (x12 - x06);
40604
- const f = d !== 1 ? ` * ${d}::DOUBLE` : "";
40605
- return reverse3 ? sql`(${+x12} - ${x3}::DOUBLE)${f}` : sql`(${x3}::DOUBLE - ${+x06})${f}`;
40718
+ const { type: type2, apply: apply2, sqlApply } = channelScale(mark2, channel);
40719
+ const reverse3 = !!mark2.plot.getAttribute(`${channel}Reverse`);
40720
+ const [lo, hi] = extent4.map((v3) => apply2(v3));
40721
+ const v2 = sqlApply(expr);
40722
+ const f = type2 === "time" || type2 === "utc" ? v2 : expr;
40723
+ const d = hi === lo ? 0 : (n - pad3) / (hi - lo);
40724
+ const s2 = d !== 1 ? ` * ${d}::DOUBLE` : "";
40725
+ const bin3 = reverse3 ? sql`(${hi} - ${v2}::DOUBLE)${s2}` : sql`(${v2}::DOUBLE - ${lo})${s2}`;
40726
+ return [bin3, f];
40606
40727
  }
40607
40728
 
40608
40729
  // ../plot/src/marks/util/extent.js
@@ -40658,7 +40779,7 @@ function filteredExtent(filter3, column3) {
40658
40779
  var ConnectedMark = class extends Mark2 {
40659
40780
  constructor(type2, source, encodings) {
40660
40781
  const dim = type2.endsWith("X") ? "y" : type2.endsWith("Y") ? "x" : null;
40661
- const req = { [dim]: ["count", "min", "max"] };
40782
+ const req = { [dim]: ["min", "max"] };
40662
40783
  super(type2, source, encodings, req);
40663
40784
  this.dim = dim;
40664
40785
  }
@@ -40666,27 +40787,29 @@ var ConnectedMark = class extends Mark2 {
40666
40787
  const { plot: plot3, dim, source, stats } = this;
40667
40788
  const { optimize = true } = source.options || {};
40668
40789
  const q = super.query(filter3);
40669
- if (optimize && dim) {
40670
- const { field: field2, as } = this.channelField(dim);
40790
+ if (!dim)
40791
+ return q;
40792
+ const ortho = dim === "x" ? "y" : "x";
40793
+ const value = this.channelField(ortho)?.as;
40794
+ const { field: field2, as } = this.channelField(dim);
40795
+ const { type: type2 } = stats[field2.column];
40796
+ const isContinuous = type2 === "date" || type2 === "number";
40797
+ if (optimize && isContinuous && value) {
40671
40798
  const { column: column3 } = field2;
40672
- const { count: count4, max: max4, min: min5 } = stats[column3];
40799
+ const { max: max4, min: min5 } = stats[column3];
40673
40800
  const size = dim === "x" ? plot3.innerWidth() : plot3.innerHeight();
40674
40801
  const [lo, hi] = filteredExtent(filter3, column3) || [min5, max4];
40675
- const scale3 = (hi - lo) / (max4 - min5);
40676
- if (count4 * scale3 > size * 4) {
40677
- const dd = binField(this, dim, as);
40678
- const val = this.channelField(dim === "x" ? "y" : "x").as;
40679
- const cols = q.select().map((c4) => c4.as).filter((c4) => c4 !== as && c4 !== val);
40680
- return m4(q, dd, as, val, lo, hi, size, cols);
40681
- }
40682
- q.orderby(as);
40802
+ const [expr] = binExpr(this, dim, size, [lo, hi], 1, as);
40803
+ const cols = q.select().map((c4) => c4.as).filter((c4) => c4 !== as && c4 !== value);
40804
+ return m4(q, expr, as, value, cols);
40805
+ } else {
40806
+ return q.orderby(field2);
40683
40807
  }
40684
- return q;
40685
40808
  }
40686
40809
  };
40687
- function m4(input3, bx, x3, y3, lo, hi, width2, cols = []) {
40688
- const bins2 = sql`FLOOR(${width2 / (hi - lo)}::DOUBLE * (${bx} - ${+lo}::DOUBLE))::INTEGER`;
40689
- const q = (sel) => Query.from(input3).select(sel).groupby(bins2, cols);
40810
+ function m4(input3, bin3, x3, y3, cols = []) {
40811
+ const pixel = sql`FLOOR(${bin3})::INTEGER`;
40812
+ const q = (sel) => Query.from(input3).select(sel).groupby(pixel, cols);
40690
40813
  return Query.union(
40691
40814
  q([{ [x3]: min(x3), [y3]: argmin(y3, x3) }, ...cols]),
40692
40815
  q([{ [x3]: max(x3), [y3]: argmax(y3, x3) }, ...cols]),
@@ -40695,6 +40818,120 @@ function m4(input3, bx, x3, y3, lo, hi, width2, cols = []) {
40695
40818
  ).orderby(cols, x3);
40696
40819
  }
40697
40820
 
40821
+ // ../plot/src/marks/util/grid.js
40822
+ function arrayType(values2, name2 = "density") {
40823
+ if (isArrowTable(values2)) {
40824
+ const type2 = values2.getChild(name2).type;
40825
+ switch (type2.typeId) {
40826
+ case INTEGER:
40827
+ case FLOAT:
40828
+ case DECIMAL:
40829
+ return Float64Array;
40830
+ default:
40831
+ return Array;
40832
+ }
40833
+ } else {
40834
+ return typeof values2[0][name2] === "number" ? Float64Array : Array;
40835
+ }
40836
+ }
40837
+ function grid1d(n, values2) {
40838
+ const Type3 = arrayType(values2);
40839
+ return valuesToGrid(new Type3(n), values2);
40840
+ }
40841
+ function grid2d(m, n, values2, aggr, groupby = []) {
40842
+ if (groupby.length) {
40843
+ return groupedValuesToGrids(m * n, values2, aggr, groupby);
40844
+ } else {
40845
+ const cell3 = {};
40846
+ aggr.forEach((name2) => {
40847
+ const Type3 = arrayType(values2, name2);
40848
+ cell3[name2] = valuesToGrid(new Type3(m * n), values2, name2);
40849
+ });
40850
+ return [cell3];
40851
+ }
40852
+ }
40853
+ function valuesToGrid(grid2, values2, name2 = "density") {
40854
+ if (isArrowTable(values2)) {
40855
+ const numRows = values2.numRows;
40856
+ if (numRows === 0)
40857
+ return grid2;
40858
+ const index2 = values2.getChild("index").toArray();
40859
+ const value = values2.getChild(name2).toArray();
40860
+ for (let row = 0; row < numRows; ++row) {
40861
+ grid2[index2[row]] = value[row];
40862
+ }
40863
+ } else {
40864
+ for (const row of values2) {
40865
+ grid2[row.index] = row[name2];
40866
+ }
40867
+ }
40868
+ return grid2;
40869
+ }
40870
+ function groupedValuesToGrids(size, values2, aggr, groupby) {
40871
+ const Types = aggr.map((name2) => arrayType(values2, name2));
40872
+ const numAggr = aggr.length;
40873
+ const cellMap = {};
40874
+ const getCell = (key) => {
40875
+ let cell3 = cellMap[key];
40876
+ if (!cell3) {
40877
+ cell3 = cellMap[key] = {};
40878
+ groupby.forEach((name2, i) => cell3[name2] = key[i]);
40879
+ aggr.forEach((name2, i) => cell3[name2] = new Types[i](size));
40880
+ }
40881
+ return cell3;
40882
+ };
40883
+ if (isArrowTable(values2)) {
40884
+ const numRows = values2.numRows;
40885
+ if (numRows === 0)
40886
+ return [];
40887
+ const index2 = values2.getChild("index").toArray();
40888
+ const value = aggr.map((name2) => values2.getChild(name2).toArray());
40889
+ const groups2 = groupby.map((name2) => values2.getChild(name2));
40890
+ for (let row = 0; row < numRows; ++row) {
40891
+ const key = groups2.map((vec2) => vec2.get(row));
40892
+ const cell3 = getCell(key);
40893
+ for (let i = 0; i < numAggr; ++i) {
40894
+ cell3[aggr[i]][index2[row]] = value[i][row];
40895
+ }
40896
+ }
40897
+ } else {
40898
+ for (const row of values2) {
40899
+ const key = groupby.map((col) => row[col]);
40900
+ const cell3 = getCell(key);
40901
+ for (let i = 0; i < numAggr; ++i) {
40902
+ cell3[aggr[i]][row.index] = row[aggr[i]];
40903
+ }
40904
+ }
40905
+ }
40906
+ return Object.values(cellMap);
40907
+ }
40908
+ function gridDomainContinuous(grids, prop) {
40909
+ let lo = 0, hi = 0;
40910
+ grids.forEach((cell3) => {
40911
+ const grid2 = cell3[prop];
40912
+ const n = grid2.length;
40913
+ for (let i = 0; i < n; ++i) {
40914
+ const v2 = grid2[i];
40915
+ if (v2 < lo)
40916
+ lo = v2;
40917
+ if (v2 > hi)
40918
+ hi = v2;
40919
+ }
40920
+ });
40921
+ return lo === 0 && hi === 0 ? [0, 1] : [lo, hi];
40922
+ }
40923
+ function gridDomainDiscrete(grids, prop) {
40924
+ const values2 = new InternSet();
40925
+ grids.forEach((cell3) => {
40926
+ const grid2 = cell3[prop];
40927
+ const n = grid2.length;
40928
+ for (let i = 0; i < n; ++i) {
40929
+ values2.add(grid2[i]);
40930
+ }
40931
+ });
40932
+ return Array.from(values2).sort(ascending);
40933
+ }
40934
+
40698
40935
  // ../plot/src/marks/util/handle-param.js
40699
40936
  function handleParam(client, key, param, update2) {
40700
40937
  if (isParam(param)) {
@@ -40879,64 +41116,17 @@ function dericheInitZeroPad(dest, src, N, stride, b, p, a2, q, sum5, h) {
40879
41116
  return;
40880
41117
  }
40881
41118
 
40882
- // ../plot/src/marks/util/grid.js
40883
- function grid1d(n, values2) {
40884
- return valuesToGrid(new Float64Array(n), values2);
40885
- }
40886
- function grid2d(m, n, values2, groupby = []) {
40887
- return groupby.length ? Object.values(groupedValuesToGrids(m * n, values2, groupby)) : [{ grid: valuesToGrid(new Float64Array(m * n), values2) }];
40888
- }
40889
- function valuesToGrid(grid2, values2) {
40890
- if (isArrowTable(values2)) {
40891
- const numRows = values2.numRows;
40892
- if (numRows === 0)
40893
- return grid2;
40894
- const index2 = values2.getChild("index").toArray();
40895
- const value = values2.getChild("value").toArray();
40896
- for (let row = 0; row < numRows; ++row) {
40897
- grid2[index2[row]] = value[row];
40898
- }
40899
- } else {
40900
- for (const row of values2) {
40901
- grid2[row.index] = row.value;
40902
- }
40903
- }
40904
- return grid2;
40905
- }
40906
- function groupedValuesToGrids(size, values2, groupby) {
40907
- const grids = {};
40908
- const getGrid = (key) => {
40909
- const cell3 = grids[key] || (grids[key] = { key, grid: new Float64Array(size) });
40910
- return cell3.grid;
40911
- };
40912
- if (isArrowTable(values2)) {
40913
- const numRows = values2.numRows;
40914
- if (numRows === 0)
40915
- return grids;
40916
- const index2 = values2.getChild("index").toArray();
40917
- const value = values2.getChild("value").toArray();
40918
- const groups2 = groupby.map((name2) => values2.getChild(name2));
40919
- for (let row = 0; row < numRows; ++row) {
40920
- const key = groups2.map((vec2) => vec2.get(row));
40921
- getGrid(key)[index2[row]] = value[row];
40922
- }
40923
- } else {
40924
- for (const row of values2) {
40925
- const key = groupby.map((col) => row[col]);
40926
- getGrid(key)[row.index] = row.value;
40927
- }
40928
- }
40929
- return grids;
40930
- }
40931
-
40932
41119
  // ../plot/src/marks/Grid2DMark.js
41120
+ var DENSITY = "density";
40933
41121
  var Grid2DMark = class extends Mark2 {
40934
41122
  constructor(type2, source, options) {
40935
41123
  const {
40936
- bandwidth = 20,
40937
- binType = "linear",
40938
- binWidth = 2,
40939
- binPad = 1,
41124
+ bandwidth = 0,
41125
+ interpolate = "none",
41126
+ pixelSize = 1,
41127
+ pad: pad3 = 1,
41128
+ width: width2,
41129
+ height: height2,
40940
41130
  ...channels
40941
41131
  } = options;
40942
41132
  const densityMap = createDensityMap(channels);
@@ -40945,9 +41135,11 @@ var Grid2DMark = class extends Mark2 {
40945
41135
  handleParam(this, "bandwidth", bandwidth, () => {
40946
41136
  return this.grids ? this.convolve().update() : null;
40947
41137
  });
40948
- handleParam(this, "binWidth", binWidth);
40949
- handleParam(this, "binType", binType);
40950
- handleParam(this, "binPad", binPad);
41138
+ handleParam(this, "pixelSize", pixelSize);
41139
+ handleParam(this, "interpolate", interpolate);
41140
+ handleParam(this, "pad", pad3);
41141
+ handleParam(this, "width", width2);
41142
+ handleParam(this, "height", height2);
40951
41143
  }
40952
41144
  setPlot(plot3, index2) {
40953
41145
  const update2 = () => {
@@ -40964,64 +41156,80 @@ var Grid2DMark = class extends Mark2 {
40964
41156
  return xdom && ydom && !xdom[Transient] && !ydom[Transient];
40965
41157
  }
40966
41158
  query(filter3 = []) {
40967
- const { plot: plot3, binType, binPad, channels, densityMap, source } = this;
41159
+ const { interpolate, pad: pad3, channels, densityMap, source } = this;
40968
41160
  const [x06, x12] = this.extentX = extentX(this, filter3);
40969
41161
  const [y06, y12] = this.extentY = extentY(this, filter3);
40970
41162
  const [nx, ny] = this.bins = this.binDimensions(this);
40971
- const bx = binField(this, "x");
40972
- const by = binField(this, "y");
40973
- const rx = !!plot3.getAttribute("xReverse");
40974
- const ry = !!plot3.getAttribute("yReverse");
40975
- const x3 = bin1d2(bx, x06, x12, nx, rx, this.binPad);
40976
- const y3 = bin1d2(by, y06, y12, ny, ry, this.binPad);
40977
- const bounds = binPad ? [isBetween(bx, [x06, x12]), isBetween(by, [y06, y12])] : [lte(x06, bx), lt(bx, x12), lte(y06, by), lt(by, y12)];
41163
+ const [x3, bx] = binExpr(this, "x", nx, [x06, x12], pad3);
41164
+ const [y3, by] = binExpr(this, "y", ny, [y06, y12], pad3);
41165
+ const bounds = pad3 ? [isBetween(bx, [+x06, +x12]), isBetween(by, [+y06, +y12])] : [lte(+x06, bx), lt(bx, +x12), lte(+y06, by), lt(by, +y12)];
40978
41166
  const q = Query.from(source.table).where(filter3.concat(bounds));
40979
41167
  const groupby = this.groupby = [];
40980
- let agg2 = count();
41168
+ const aggrMap = {};
40981
41169
  for (const c4 of channels) {
40982
41170
  if (Object.hasOwn(c4, "field")) {
40983
41171
  const { as, channel, field: field2 } = c4;
40984
41172
  if (field2.aggregate) {
40985
- agg2 = field2;
41173
+ aggrMap[channel] = field2;
40986
41174
  densityMap[channel] = true;
40987
41175
  } else if (channel === "weight") {
40988
- agg2 = sum2(field2);
41176
+ aggrMap[DENSITY] = sum2(field2);
40989
41177
  } else if (channel !== "x" && channel !== "y") {
40990
41178
  q.select({ [as]: field2 });
40991
41179
  groupby.push(as);
40992
41180
  }
40993
41181
  }
40994
41182
  }
40995
- return binType === "linear" ? binLinear2d(q, x3, y3, agg2, nx, groupby) : bin2d(q, x3, y3, agg2, nx, groupby);
41183
+ const aggr = this.aggr = Object.keys(aggrMap);
41184
+ if (aggrMap.density && aggr.length > 1) {
41185
+ throw new Error("Weight option can not be used with custom aggregates.");
41186
+ }
41187
+ if (!aggr.length) {
41188
+ aggr.push(DENSITY);
41189
+ aggrMap.density = count();
41190
+ }
41191
+ if (interpolate === "linear") {
41192
+ if (aggr.length > 1) {
41193
+ throw new Error("Linear binning not applicable to multiple aggregates.");
41194
+ }
41195
+ if (!aggrMap.density) {
41196
+ throw new Error("Linear binning not applicable to custom aggregates.");
41197
+ }
41198
+ return binLinear2d(q, x3, y3, aggrMap[DENSITY], nx, groupby);
41199
+ } else {
41200
+ return bin2d(q, x3, y3, aggrMap, nx, groupby);
41201
+ }
40996
41202
  }
40997
41203
  binDimensions() {
40998
- const { plot: plot3, binWidth } = this;
41204
+ const { plot: plot3, pixelSize, width: width2, height: height2 } = this;
40999
41205
  return [
41000
- Math.round(plot3.innerWidth() / binWidth),
41001
- Math.round(plot3.innerHeight() / binWidth)
41206
+ width2 ?? Math.round(plot3.innerWidth() / pixelSize),
41207
+ height2 ?? Math.round(plot3.innerHeight() / pixelSize)
41002
41208
  ];
41003
41209
  }
41004
41210
  queryResult(data) {
41005
41211
  const [nx, ny] = this.bins;
41006
- this.grids = grid2d(nx, ny, data, this.groupby);
41212
+ this.grids = grid2d(nx, ny, data, this.aggr, this.groupby);
41007
41213
  return this.convolve();
41008
41214
  }
41009
41215
  convolve() {
41010
- const { bandwidth, bins: bins2, grids, plot: plot3 } = this;
41011
- if (bandwidth <= 0) {
41012
- this.kde = this.grids.map(({ key, grid: grid2 }) => {
41013
- return grid2.key = key, grid2;
41014
- });
41015
- } else {
41216
+ const { aggr, bandwidth, bins: bins2, grids, plot: plot3 } = this;
41217
+ this.kde = this.grids;
41218
+ if (bandwidth > 0) {
41219
+ const gridProp = aggr.length === 1 ? aggr[0] : aggr.includes(DENSITY) ? DENSITY : null;
41220
+ if (!gridProp) {
41221
+ console.warn("No compatible grid found for smoothing.");
41222
+ return this;
41223
+ }
41016
41224
  const w = plot3.innerWidth();
41017
41225
  const h = plot3.innerHeight();
41018
41226
  const [nx, ny] = bins2;
41019
- const neg = grids.some(({ grid: grid2 }) => grid2.some((v2) => v2 < 0));
41227
+ const neg = grids.some((cell3) => cell3[gridProp].some((v2) => v2 < 0));
41020
41228
  const configX = dericheConfig(bandwidth * (nx - 1) / w, neg);
41021
41229
  const configY = dericheConfig(bandwidth * (ny - 1) / h, neg);
41022
- this.kde = this.grids.map(({ key, grid: grid2 }) => {
41023
- const k2 = dericheConv2d(configX, configY, grid2, bins2);
41024
- return k2.key = key, k2;
41230
+ this.kde = this.grids.map((grid2) => {
41231
+ const density3 = dericheConv2d(configX, configY, grid2[gridProp], bins2);
41232
+ return { ...grid2, [gridProp]: density3 };
41025
41233
  });
41026
41234
  }
41027
41235
  return this;
@@ -41040,19 +41248,14 @@ function createDensityMap(channels) {
41040
41248
  }
41041
41249
  return densityMap;
41042
41250
  }
41043
- function bin1d2(x3, x06, x12, n, reverse3, pad3) {
41044
- const d = (n - pad3) / (x12 - x06);
41045
- const f = d !== 1 ? ` * ${d}::DOUBLE` : "";
41046
- return reverse3 ? sql`(${x12} - ${x3}::DOUBLE)${f}` : sql`(${x3}::DOUBLE - ${x06})${f}`;
41047
- }
41048
- function bin2d(q, xp, yp, value, xn, groupby) {
41251
+ function bin2d(q, xp, yp, aggs, xn, groupby) {
41049
41252
  return q.select({
41050
41253
  index: sql`FLOOR(${xp})::INTEGER + FLOOR(${yp})::INTEGER * ${xn}`,
41051
- value
41254
+ ...aggs
41052
41255
  }).groupby("index", groupby);
41053
41256
  }
41054
- function binLinear2d(q, xp, yp, value, xn, groupby) {
41055
- const w = value.column ? `* ${value.column}` : "";
41257
+ function binLinear2d(q, xp, yp, density3, xn, groupby) {
41258
+ const w = density3?.column ? `* ${density3.column}` : "";
41056
41259
  const subq = (i, w2) => q.clone().select({ xp, yp, i, w: w2 });
41057
41260
  const a2 = subq(
41058
41261
  sql`FLOOR(xp)::INTEGER + FLOOR(yp)::INTEGER * ${xn}`,
@@ -41070,14 +41273,19 @@ function binLinear2d(q, xp, yp, value, xn, groupby) {
41070
41273
  sql`FLOOR(xp)::INTEGER + 1 + (FLOOR(yp)::INTEGER + 1) * ${xn}`,
41071
41274
  sql`(xp - FLOOR(xp)::INTEGER) * (yp - FLOOR(yp)::INTEGER)${w}`
41072
41275
  );
41073
- return Query.from(Query.unionAll(a2, b, c4, d)).select({ index: "i", value: sum2("w") }, groupby).groupby("index", groupby).having(gt("value", 0));
41276
+ return Query.from(Query.unionAll(a2, b, c4, d)).select({ index: "i", density: sum2("w") }, groupby).groupby("index", groupby).having(neq("density", 0));
41074
41277
  }
41075
41278
 
41076
41279
  // ../plot/src/marks/ContourMark.js
41077
41280
  var ContourMark = class extends Grid2DMark {
41078
41281
  constructor(source, options) {
41079
41282
  const { thresholds = 10, ...channels } = options;
41080
- super("geo", source, channels);
41283
+ super("geo", source, {
41284
+ bandwidth: 20,
41285
+ interpolate: "linear",
41286
+ pixelSize: 2,
41287
+ ...channels
41288
+ });
41081
41289
  handleParam(this, "thresholds", thresholds, () => {
41082
41290
  return this.grids ? this.contours().update() : null;
41083
41291
  });
@@ -41086,11 +41294,11 @@ var ContourMark = class extends Grid2DMark {
41086
41294
  return super.convolve().contours();
41087
41295
  }
41088
41296
  contours() {
41089
- const { bins: bins2, densityMap, kde, thresholds, groupby, plot: plot3 } = this;
41297
+ const { bins: bins2, densityMap, kde, thresholds, plot: plot3 } = this;
41090
41298
  let tz = thresholds;
41091
41299
  if (!Array.isArray(tz)) {
41092
- const scale3 = max2(kde.map((k2) => max2(k2)));
41093
- tz = Array.from({ length: tz - 1 }, (_, i) => scale3 * (i + 1) / tz);
41300
+ const [, hi] = gridDomainContinuous(kde, "density");
41301
+ tz = Array.from({ length: tz - 1 }, (_, i) => hi * (i + 1) / tz);
41094
41302
  }
41095
41303
  if (densityMap.fill || densityMap.stroke) {
41096
41304
  if (this.plot.getAttribute("colorScale") !== "log") {
@@ -41107,11 +41315,11 @@ var ContourMark = class extends Grid2DMark {
41107
41315
  const x3 = (v2) => xo + v2 * sx;
41108
41316
  const y3 = (v2) => yo + v2 * sy;
41109
41317
  const contour3 = contours_default().size(bins2);
41110
- this.data = kde.flatMap((k2) => tz.map((t) => {
41111
- const c4 = transform2(contour3.contour(k2, t), x3, y3);
41112
- groupby.forEach((name2, i) => c4[name2] = k2.key[i]);
41113
- c4.density = t;
41114
- return c4;
41318
+ this.data = kde.flatMap((cell3) => tz.map((t) => {
41319
+ return Object.assign(
41320
+ transform2(contour3.contour(cell3.density, t), x3, y3),
41321
+ { ...cell3, density: t }
41322
+ );
41115
41323
  }));
41116
41324
  return this;
41117
41325
  }
@@ -41147,23 +41355,95 @@ function transform2(geometry, x3, y3) {
41147
41355
  }
41148
41356
 
41149
41357
  // ../plot/src/marks/util/raster.js
41150
- function raster2(grid2, data, w, h, scale3, scheme28) {
41151
- const n = (scheme28.length >> 2) - 1;
41152
- for (let j = 0, k2 = 0; j < h; ++j) {
41153
- for (let i = 0, row = (h - j - 1) * w; i < w; ++i, k2 += 4) {
41154
- const c4 = n * scale3(grid2[i + row]) << 2;
41155
- data[k2 + 0] = scheme28[c4 + 0];
41156
- data[k2 + 1] = scheme28[c4 + 1];
41157
- data[k2 + 2] = scheme28[c4 + 2];
41158
- data[k2 + 3] = scheme28[c4 + 3];
41159
- }
41358
+ function createCanvas(w, h) {
41359
+ if (typeof document !== "undefined") {
41360
+ const c4 = document.createElement("canvas");
41361
+ c4.setAttribute("width", w);
41362
+ c4.setAttribute("height", h);
41363
+ return c4;
41160
41364
  }
41365
+ throw new Error("Can not create a canvas instance.");
41366
+ }
41367
+ function alphaConstant(v2 = 1) {
41368
+ const a2 = 255 * v2 | 0;
41369
+ return (data, w, h) => {
41370
+ for (let j = 0, k2 = 0; j < h; ++j) {
41371
+ for (let i = 0; i < w; ++i, k2 += 4) {
41372
+ data[k2 + 3] = a2;
41373
+ }
41374
+ }
41375
+ };
41376
+ }
41377
+ function alphaScheme(scale3) {
41378
+ const { apply: apply2 } = scale3;
41379
+ return (data, w, h, grid2) => {
41380
+ for (let j = 0, k2 = 0; j < h; ++j) {
41381
+ for (let i = 0, row = (h - j - 1) * w; i < w; ++i, k2 += 4) {
41382
+ data[k2 + 3] = 255 * apply2(grid2[i + row]) | 0;
41383
+ }
41384
+ }
41385
+ };
41386
+ }
41387
+ function colorConstant(v2 = {}) {
41388
+ const { r = 0, g = 0, b = 0, opacity: opacity2 = 1 } = typeof v2 === "string" ? rgb(v2) : v2;
41389
+ const c4 = new Uint8ClampedArray([r, g, b, 255 * opacity2 | 0]);
41390
+ return (data, w, h) => {
41391
+ for (let j = 0, k2 = 0; j < h; ++j) {
41392
+ for (let i = 0; i < w; ++i, k2 += 4) {
41393
+ data[k2 + 0] = c4[0];
41394
+ data[k2 + 1] = c4[1];
41395
+ data[k2 + 2] = c4[2];
41396
+ data[k2 + 3] = c4[3];
41397
+ }
41398
+ }
41399
+ };
41161
41400
  }
41162
- function palette(size, interp) {
41401
+ function colorCategory(scale3) {
41402
+ const { domain, range: range3 } = scale3;
41403
+ const idx = /* @__PURE__ */ Object.create(null);
41404
+ const p = new Uint8ClampedArray(4 * domain.length);
41405
+ const n = domain.length - 1;
41406
+ const m = range3.length;
41407
+ for (let i = 0; i <= n; ++i) {
41408
+ const v2 = range3[i % m];
41409
+ const { r, g, b, opacity: opacity2 = 1 } = typeof v2 === "string" ? rgb(v2) : v2;
41410
+ const k2 = i << 2;
41411
+ p[k2 + 0] = r;
41412
+ p[k2 + 1] = g;
41413
+ p[k2 + 2] = b;
41414
+ p[k2 + 3] = 255 * opacity2 | 0;
41415
+ idx[domain[i]] = k2;
41416
+ }
41417
+ return (data, w, h, grid2) => {
41418
+ if (grid2.map) {
41419
+ for (let j = 0, k2 = 0; j < h; ++j) {
41420
+ for (let i = 0, row = (h - j - 1) * w; i < w; ++i, k2 += 4) {
41421
+ const c4 = idx[grid2[i + row]];
41422
+ data[k2 + 0] = p[c4 + 0];
41423
+ data[k2 + 1] = p[c4 + 1];
41424
+ data[k2 + 2] = p[c4 + 2];
41425
+ data[k2 + 3] = p[c4 + 3];
41426
+ }
41427
+ }
41428
+ } else {
41429
+ const c4 = idx[grid2];
41430
+ for (let j = 0, k2 = 0; j < h; ++j) {
41431
+ for (let i = 0; i < w; ++i, k2 += 4) {
41432
+ data[k2 + 0] = p[c4 + 0];
41433
+ data[k2 + 1] = p[c4 + 1];
41434
+ data[k2 + 2] = p[c4 + 2];
41435
+ data[k2 + 3] = p[c4 + 3];
41436
+ }
41437
+ }
41438
+ }
41439
+ };
41440
+ }
41441
+ function colorScheme(size, scale3, frac) {
41442
+ const { interpolate } = scale3;
41163
41443
  const p = new Uint8ClampedArray(4 * size);
41164
41444
  const n = size - 1;
41165
41445
  for (let i = 0; i <= n; ++i) {
41166
- const v2 = interp(i / n);
41446
+ const v2 = interpolate(i / n);
41167
41447
  const { r, g, b, opacity: opacity2 = 1 } = typeof v2 === "string" ? rgb(v2) : v2;
41168
41448
  const k2 = i << 2;
41169
41449
  p[k2 + 0] = r;
@@ -41171,20 +41451,17 @@ function palette(size, interp) {
41171
41451
  p[k2 + 2] = b;
41172
41452
  p[k2 + 3] = 255 * opacity2 | 0;
41173
41453
  }
41174
- return p;
41175
- }
41176
- function createCanvas(w, h) {
41177
- if (typeof document !== "undefined") {
41178
- const c4 = document.createElement("canvas");
41179
- c4.setAttribute("width", w);
41180
- c4.setAttribute("height", h);
41181
- return c4;
41182
- }
41183
- throw new Error("Can not create a canvas instance.");
41184
- }
41185
- function opacityMap(color3 = "black") {
41186
- const { r, g, b } = rgb(color3);
41187
- return (opacity2) => ({ r, g, b, opacity: opacity2 });
41454
+ return (data, w, h, grid2) => {
41455
+ for (let j = 0, k2 = 0; j < h; ++j) {
41456
+ for (let i = 0, row = (h - j - 1) * w; i < w; ++i, k2 += 4) {
41457
+ const c4 = n * frac(grid2[i + row]) << 2;
41458
+ data[k2 + 0] = p[c4 + 0];
41459
+ data[k2 + 1] = p[c4 + 1];
41460
+ data[k2 + 2] = p[c4 + 2];
41461
+ data[k2 + 3] = p[c4 + 3];
41462
+ }
41463
+ }
41464
+ };
41188
41465
  }
41189
41466
 
41190
41467
  // ../plot/src/marks/RasterMark.js
@@ -41204,15 +41481,13 @@ var RasterMark = class extends Grid2DMark {
41204
41481
  return super.convolve().rasterize();
41205
41482
  }
41206
41483
  rasterize() {
41207
- const { bins: bins2, kde, groupby } = this;
41484
+ const { bins: bins2, kde } = this;
41208
41485
  const [w, h] = bins2;
41209
41486
  const { canvas, ctx, img } = imageData(this, w, h);
41210
- const s2 = imageScale(this);
41211
- const idx = groupby.indexOf(this.channelField("fill")?.as);
41212
- const domain = idx < 0 ? [] : kde.map(({ key }) => key[idx]);
41213
- this.data = kde.map((grid2) => {
41214
- const palette2 = imagePalette(this, domain, grid2.key?.[idx]);
41215
- raster2(grid2, img.data, w, h, s2, palette2);
41487
+ const { alpha, alphaProp, color: color3, colorProp } = rasterEncoding(this);
41488
+ this.data = kde.map((cell3) => {
41489
+ color3?.(img.data, w, h, cell3[colorProp]);
41490
+ alpha?.(img.data, w, h, cell3[alphaProp]);
41216
41491
  ctx.putImageData(img, 0, 0);
41217
41492
  return { src: canvas.toDataURL() };
41218
41493
  });
@@ -41231,6 +41506,128 @@ var RasterMark = class extends Grid2DMark {
41231
41506
  return [{ type: type2, data, options }];
41232
41507
  }
41233
41508
  };
41509
+ var HeatmapMark = class extends RasterMark {
41510
+ constructor(source, options) {
41511
+ super(source, {
41512
+ bandwidth: 20,
41513
+ interpolate: "linear",
41514
+ pixelSize: 2,
41515
+ ...options
41516
+ });
41517
+ }
41518
+ };
41519
+ function rasterEncoding(mark2) {
41520
+ const { aggr, densityMap, groupby, plot: plot3 } = mark2;
41521
+ const hasDensity = aggr.includes(DENSITY);
41522
+ const hasFillOpacity = aggr.includes("fillOpacity");
41523
+ const fillEntry = mark2.channel("fill");
41524
+ const opacEntry = mark2.channel("fillOpacity");
41525
+ if (aggr.length > 2 || hasDensity && hasFillOpacity) {
41526
+ throw new Error("Invalid raster encodings. Try dropping an aggregate?");
41527
+ }
41528
+ if (groupby.includes(opacEntry?.as)) {
41529
+ throw new Error("Raster fillOpacity must be an aggregate or constant.");
41530
+ }
41531
+ const fill = densityMap.fill || aggr.includes("fill") ? "grid" : groupby.includes(fillEntry?.as) ? "group" : isColor2(fillEntry?.value) ? fillEntry.value : hasDensity && plot3.getAttribute("colorScheme") ? "grid" : void 0;
41532
+ const opac = densityMap.fillOpacity || aggr.includes("fillOpacity") ? "grid" : typeof opacEntry?.value === "number" ? opacEntry.value : hasDensity && fill !== "grid" ? "grid" : void 0;
41533
+ if (fill !== "grid" && opac !== "grid") {
41534
+ throw new Error("Raster mark missing density values.");
41535
+ }
41536
+ const colorProp = fillEntry?.as ?? (fill === "grid" ? DENSITY : null);
41537
+ const alphaProp = opacEntry?.as ?? (opac === "grid" ? DENSITY : null);
41538
+ const color3 = fill !== "grid" && fill !== "group" ? colorConstant(fill) : colorScale(mark2, colorProp);
41539
+ const alpha = opac !== "grid" ? alphaConstant(opac) : alphaScale(mark2, alphaProp);
41540
+ return { alphaProp, colorProp, alpha, color: color3 };
41541
+ }
41542
+ function alphaScale(mark2, prop) {
41543
+ const { plot: plot3, kde: grids } = mark2;
41544
+ const domainAttr = plot3.getAttribute("opacityDomain");
41545
+ const domainFixed = domainAttr === Fixed;
41546
+ const domainTransient = domainAttr?.[Transient];
41547
+ const domain = !domainFixed && !domainTransient && domainAttr || gridDomainContinuous(grids, prop);
41548
+ if (domainFixed || domainTransient) {
41549
+ if (domainTransient)
41550
+ domain[Transient] = true;
41551
+ plot3.setAttribute("colorDomain", domain);
41552
+ }
41553
+ const s2 = scale2({
41554
+ opacity: {
41555
+ type: plot3.getAttribute("opacityScale"),
41556
+ domain,
41557
+ clamp: plot3.getAttribute("opacityClamp"),
41558
+ nice: plot3.getAttribute("opacityNice"),
41559
+ reverse: plot3.getAttribute("opacityReverse"),
41560
+ zero: plot3.getAttribute("opacityZero"),
41561
+ base: plot3.getAttribute("opacityBase"),
41562
+ exponent: plot3.getAttribute("opacityExponent"),
41563
+ constant: plot3.getAttribute("opacityConstant")
41564
+ }
41565
+ });
41566
+ return alphaScheme(s2);
41567
+ }
41568
+ function colorScale(mark2, prop) {
41569
+ const { plot: plot3, kde: grids } = mark2;
41570
+ const flat = !grids[0][prop]?.map;
41571
+ const discrete = flat || Array.isArray(grids[0][prop]);
41572
+ const domainAttr = plot3.getAttribute("colorDomain");
41573
+ const domainFixed = domainAttr === Fixed;
41574
+ const domainTransient = domainAttr?.[Transient];
41575
+ const domain = !domainFixed && !domainTransient && domainAttr || (flat ? grids.map((cell3) => cell3[prop]).sort(ascending) : discrete ? gridDomainDiscrete(grids, prop) : gridDomainContinuous(grids, prop));
41576
+ if (domainFixed || domainTransient) {
41577
+ if (domainTransient)
41578
+ domain[Transient] = true;
41579
+ plot3.setAttribute("colorDomain", domain);
41580
+ }
41581
+ const s2 = scale2({
41582
+ color: {
41583
+ type: plot3.getAttribute("colorScale"),
41584
+ domain,
41585
+ range: plot3.getAttribute("colorRange"),
41586
+ clamp: plot3.getAttribute("colorClamp"),
41587
+ n: plot3.getAttribute("colorN"),
41588
+ nice: plot3.getAttribute("colorNice"),
41589
+ reverse: plot3.getAttribute("colorReverse"),
41590
+ scheme: plot3.getAttribute("colorScheme"),
41591
+ interpolate: plot3.getAttribute("colorInterpolate"),
41592
+ pivot: plot3.getAttribute("colorPivot"),
41593
+ symmetric: plot3.getAttribute("colorSymmetric"),
41594
+ zero: plot3.getAttribute("colorZero"),
41595
+ base: plot3.getAttribute("colorBase"),
41596
+ exponent: plot3.getAttribute("colorExponent"),
41597
+ constant: plot3.getAttribute("colorConstant")
41598
+ }
41599
+ });
41600
+ if (discrete) {
41601
+ return colorCategory(s2);
41602
+ } else {
41603
+ const frac = scale2({
41604
+ x: {
41605
+ type: inferScaleType2(s2.type),
41606
+ domain: s2.domain,
41607
+ reverse: s2.reverse,
41608
+ range: [0, 1],
41609
+ clamp: s2.clamp,
41610
+ base: s2.base,
41611
+ exponent: s2.exponent,
41612
+ constant: s2.constant
41613
+ }
41614
+ });
41615
+ return colorScheme(1024, s2, frac.apply);
41616
+ }
41617
+ }
41618
+ function inferScaleType2(type2) {
41619
+ if (type2.endsWith("symlog"))
41620
+ return "symlog";
41621
+ if (type2.endsWith("log"))
41622
+ return "log";
41623
+ if (type2.endsWith("pow"))
41624
+ return "pow";
41625
+ if (type2.endsWith("sqrt"))
41626
+ return "sqrt";
41627
+ if (type2 === "diverging")
41628
+ return "linear";
41629
+ return type2;
41630
+ }
41234
41631
  function imageData(mark2, w, h) {
41235
41632
  if (!mark2.image || mark2.image.w !== w || mark2.image.h !== h) {
41236
41633
  const canvas = createCanvas(w, h);
@@ -41240,71 +41637,21 @@ function imageData(mark2, w, h) {
41240
41637
  }
41241
41638
  return mark2.image;
41242
41639
  }
41243
- function imageScale(mark2) {
41244
- const { densityMap, kde, plot: plot3 } = mark2;
41245
- let domain = densityMap.fill && plot3.getAttribute("colorDomain");
41246
- if (!domain) {
41247
- let lo = 0, hi = 0;
41248
- kde.forEach((grid2) => {
41249
- for (const v2 of grid2) {
41250
- if (v2 < lo)
41251
- lo = v2;
41252
- if (v2 > hi)
41253
- hi = v2;
41254
- }
41255
- });
41256
- domain = lo === 0 && hi === 0 ? [0, 1] : [lo, hi];
41257
- }
41258
- const type2 = plot3.getAttribute("colorScale");
41259
- return scale2({ x: { type: type2, domain, range: [0, 1] } }).apply;
41260
- }
41261
- function imagePalette(mark2, domain, value, steps = 1024) {
41262
- const { densityMap, plot: plot3 } = mark2;
41263
- const scheme28 = plot3.getAttribute("colorScheme");
41264
- const fill = mark2.channel("fill");
41265
- let color3 = isColor2(fill?.value) ? fill.value : void 0;
41266
- if (densityMap.fill || scheme28 && !color3) {
41267
- if (scheme28) {
41268
- try {
41269
- return palette(
41270
- steps,
41271
- scale2({ color: { scheme: scheme28, domain: [0, 1] } }).interpolate
41272
- );
41273
- } catch (err) {
41274
- console.warn(err);
41275
- }
41276
- }
41277
- } else if (domain.length) {
41278
- const range3 = plot3.getAttribute("colorRange");
41279
- const spec = {
41280
- domain,
41281
- range: range3,
41282
- scheme: scheme28 || (range3 ? void 0 : "tableau10")
41283
- };
41284
- color3 = scale2({ color: spec }).apply(value);
41285
- }
41286
- return palette(steps, opacityMap(color3));
41287
- }
41288
41640
 
41289
41641
  // ../plot/src/marks/DenseLineMark.js
41290
41642
  var DenseLineMark = class extends RasterMark {
41291
41643
  constructor(source, options) {
41292
41644
  const { normalize: normalize4 = true, ...rest } = options;
41293
- super(source, { bandwidth: 0, ...rest });
41645
+ super(source, rest);
41294
41646
  handleParam(this, "normalize", normalize4);
41295
41647
  }
41296
41648
  query(filter3 = []) {
41297
- const { plot: plot3, channels, normalize: normalize4, source } = this;
41298
- const [x06, x12] = extentX(this, filter3);
41299
- const [y06, y12] = extentY(this, filter3);
41649
+ const { channels, normalize: normalize4, source, binPad } = this;
41300
41650
  const [nx, ny] = this.bins = this.binDimensions(this);
41301
- const bx = binField(this, "x");
41302
- const by = binField(this, "y");
41303
- const rx = !!plot3.getAttribute("xReverse");
41304
- const ry = !!plot3.getAttribute("yReverse");
41305
- const x3 = bin1d(bx, x06, x12, nx, rx, this.binPad);
41306
- const y3 = bin1d(by, y06, y12, ny, ry, this.binPad);
41651
+ const [x3] = binExpr(this, "x", nx, extentX(this, filter3), binPad);
41652
+ const [y3] = binExpr(this, "y", ny, extentY(this, filter3), binPad);
41307
41653
  const q = Query.from(source.table).where(stripXY(this, filter3));
41654
+ this.aggr = ["density"];
41308
41655
  const groupby = this.groupby = [];
41309
41656
  const z = [];
41310
41657
  for (const c4 of channels) {
@@ -41351,7 +41698,7 @@ function lineDensity(q, x3, y3, z, xn, yn, groupby = [], normalize4 = true) {
41351
41698
  ));
41352
41699
  const num = Query.select({ x: sql`GREATEST(MAX(ABS(dx)), MAX(ABS(dy)))` }).from("pairs");
41353
41700
  const indices = Query.select({ i: sql`UNNEST(range((${num})))::INTEGER` });
41354
- const raster4 = Query.unionAll(
41701
+ const raster3 = Query.unionAll(
41355
41702
  Query.select(groups2, {
41356
41703
  x: sql`x0 + i`,
41357
41704
  y: sql`y0 + ROUND(i * dy / dx::FLOAT)::INTEGER`
@@ -41368,10 +41715,10 @@ function lineDensity(q, x3, y3, z, xn, yn, groupby = [], normalize4 = true) {
41368
41715
  "x",
41369
41716
  "y",
41370
41717
  normalize4 ? { w: sql`1.0 / COUNT(*) OVER (PARTITION BY ${pointPart})` } : null
41371
- ).where(and(isBetween("x", [0, xn]), isBetween("y", [0, yn])));
41372
- return Query.with({ pairs: pairs2, indices, raster: raster4, points: points2 }).from("points").select(groupby, {
41718
+ ).where(and(isBetween("x", [0, xn], true), isBetween("y", [0, yn], true)));
41719
+ return Query.with({ pairs: pairs2, indices, raster: raster3, points: points2 }).from("points").select(groupby, {
41373
41720
  index: sql`x + y * ${xn}::INTEGER`,
41374
- value: normalize4 ? sum2("w") : count()
41721
+ density: normalize4 ? sum2("w") : count()
41375
41722
  }).groupby("index", groupby);
41376
41723
  }
41377
41724
 
@@ -41396,13 +41743,11 @@ var Density1DMark = class extends Mark2 {
41396
41743
  if (this.hasOwnData())
41397
41744
  throw new Error("Density1DMark requires a data source");
41398
41745
  const { bins: bins2, channels, dim, source: { table: table3 } } = this;
41399
- const [lo, hi] = this.extent = (dim === "x" ? extentX : extentY)(this, filter3);
41400
- const bx = binField(this, dim);
41401
- return binLinear1d(
41402
- markQuery(channels, table3, [dim]).where(filter3.concat(isBetween(bx, [lo, hi]))),
41403
- bin1d(bx, lo, hi, bins2),
41404
- this.channelField("weight") ? "weight" : null
41405
- );
41746
+ const extent4 = this.extent = (dim === "x" ? extentX : extentY)(this, filter3);
41747
+ const [x3, bx] = binExpr(this, dim, bins2, extent4);
41748
+ const q = markQuery(channels, table3, [dim]).where(filter3.concat(isBetween(bx, extent4)));
41749
+ const v2 = this.channelField("weight") ? "weight" : null;
41750
+ return binLinear1d(q, x3, v2);
41406
41751
  }
41407
41752
  queryResult(data) {
41408
41753
  this.grid = grid1d(this.bins, data);
@@ -41437,8 +41782,8 @@ var Density1DMark = class extends Mark2 {
41437
41782
  return [{ type: type2, data, options }];
41438
41783
  }
41439
41784
  };
41440
- function binLinear1d(q, p, value) {
41441
- const w = value ? `* ${value}` : "";
41785
+ function binLinear1d(q, p, density3) {
41786
+ const w = density3 ? `* ${density3}` : "";
41442
41787
  const u4 = q.clone().select({
41443
41788
  p,
41444
41789
  i: sql`FLOOR(p)::INTEGER`,
@@ -41449,37 +41794,45 @@ function binLinear1d(q, p, value) {
41449
41794
  i: sql`FLOOR(p)::INTEGER + 1`,
41450
41795
  w: sql`(p - FLOOR(p))${w}`
41451
41796
  });
41452
- return Query.from(Query.unionAll(u4, v2)).select({ index: "i", value: sum2("w") }).groupby("index").having(gt("value", 0));
41797
+ return Query.from(Query.unionAll(u4, v2)).select({ index: "i", density: sum2("w") }).groupby("index").having(gt("density", 0));
41453
41798
  }
41454
41799
 
41455
41800
  // ../plot/src/marks/Density2DMark.js
41456
41801
  var Density2DMark = class extends Grid2DMark {
41457
41802
  constructor(source, options) {
41458
- const { type: type2 = "dot", binsX, binsY, ...channels } = options;
41459
- channels.binPad = channels.binPad ?? 0;
41460
- super(type2, source, channels);
41461
- handleParam(this, "binsX", binsX);
41462
- handleParam(this, "binsY", binsY);
41803
+ const { type: type2 = "dot", ...channels } = options;
41804
+ super(type2, source, {
41805
+ bandwidth: 20,
41806
+ interpolate: "linear",
41807
+ pad: 0,
41808
+ pixelSize: 2,
41809
+ ...channels
41810
+ });
41463
41811
  }
41464
41812
  convolve() {
41465
41813
  super.convolve();
41466
- const { bins: bins2, binPad, extentX: extentX2, extentY: extentY2 } = this;
41814
+ const { bins: bins2, pad: pad3, extentX: extentX2, extentY: extentY2 } = this;
41467
41815
  const [nx, ny] = bins2;
41468
- const [x06, x12] = extentX2;
41469
- const [y06, y12] = extentY2;
41470
- const deltaX = (x12 - x06) / (nx - binPad);
41471
- const deltaY = (y12 - y06) / (ny - binPad);
41472
- const offset2 = binPad ? 0 : 0.5;
41473
- this.data = points(this.kde, bins2, x06, y06, deltaX, deltaY, offset2);
41816
+ const scaleX = channelScale(this, "x");
41817
+ const scaleY = channelScale(this, "y");
41818
+ const [x06, x12] = extentX2.map((v2) => scaleX.apply(v2));
41819
+ const [y06, y12] = extentY2.map((v2) => scaleY.apply(v2));
41820
+ const deltaX = (x12 - x06) / (nx - pad3);
41821
+ const deltaY = (y12 - y06) / (ny - pad3);
41822
+ const offset2 = pad3 ? 0 : 0.5;
41823
+ this.data = points(
41824
+ this.kde,
41825
+ bins2,
41826
+ x06,
41827
+ y06,
41828
+ deltaX,
41829
+ deltaY,
41830
+ scaleX.invert,
41831
+ scaleY.invert,
41832
+ offset2
41833
+ );
41474
41834
  return this;
41475
41835
  }
41476
- binDimensions() {
41477
- const { plot: plot3, binWidth, binsX, binsY } = this;
41478
- return [
41479
- binsX ?? Math.round(plot3.innerWidth() / binWidth),
41480
- binsY ?? Math.round(plot3.innerHeight() / binWidth)
41481
- ];
41482
- }
41483
41836
  plotSpecs() {
41484
41837
  const { type: type2, channels, densityMap, data } = this;
41485
41838
  const options = {};
@@ -41495,16 +41848,18 @@ var Density2DMark = class extends Grid2DMark {
41495
41848
  return [{ type: type2, data, options }];
41496
41849
  }
41497
41850
  };
41498
- function points(kde, bins2, x06, y06, deltaX, deltaY, offset2) {
41851
+ function points(kde, bins2, x06, y06, deltaX, deltaY, invertX, invertY, offset2) {
41499
41852
  const scale3 = 1 / (deltaX * deltaY);
41500
41853
  const [nx, ny] = bins2;
41501
41854
  const data = [];
41502
- for (const grid2 of kde) {
41855
+ for (const cell3 of kde) {
41856
+ const grid2 = cell3.density;
41503
41857
  for (let k2 = 0, j = 0; j < ny; ++j) {
41504
41858
  for (let i = 0; i < nx; ++i, ++k2) {
41505
41859
  data.push({
41506
- x: x06 + (i + offset2) * deltaX,
41507
- y: y06 + (j + offset2) * deltaY,
41860
+ ...cell3,
41861
+ x: invertX(x06 + (i + offset2) * deltaX),
41862
+ y: invertY(y06 + (j + offset2) * deltaY),
41508
41863
  density: grid2[k2] * scale3
41509
41864
  });
41510
41865
  }
@@ -41622,34 +41977,48 @@ var RasterTileMark = class extends Grid2DMark {
41622
41977
  return null;
41623
41978
  }
41624
41979
  tileQuery(extent4) {
41625
- const { plot: plot3, binType, binPad, channels, densityMap, source } = this;
41980
+ const { binType, binPad, channels, densityMap, source } = this;
41626
41981
  const [[x06, x12], [y06, y12]] = extent4;
41627
41982
  const [nx, ny] = this.bins;
41628
- const bx = binField(this, "x");
41629
- const by = binField(this, "y");
41630
- const rx = !!plot3.getAttribute("xReverse");
41631
- const ry = !!plot3.getAttribute("yReverse");
41632
- const x3 = bin1d3(bx, x06, x12, nx, rx, binPad);
41633
- const y3 = bin1d3(by, y06, y12, ny, ry, binPad);
41634
- const bounds = binPad ? [isBetween(bx, [x06, x12]), isBetween(by, [y06, y12])] : [lte(x06, bx), lt(bx, x12), lte(y06, by), lt(by, y12)];
41983
+ const [x3, bx] = binExpr(this, "x", nx, [x06, x12], binPad);
41984
+ const [y3, by] = binExpr(this, "y", ny, [y06, y12], binPad);
41985
+ const bounds = binPad ? [isBetween(bx, [+x06, +x12]), isBetween(by, [+y06, +y12])] : [lte(+x06, bx), lt(bx, +x12), lte(+y06, by), lt(by, +y12)];
41635
41986
  const q = Query.from(source.table).where(bounds);
41636
41987
  const groupby = this.groupby = [];
41637
- let agg2 = count();
41988
+ const aggrMap = {};
41638
41989
  for (const c4 of channels) {
41639
41990
  if (Object.hasOwn(c4, "field")) {
41640
- const { channel, field: field2 } = c4;
41991
+ const { as, channel, field: field2 } = c4;
41641
41992
  if (field2.aggregate) {
41642
- agg2 = field2;
41993
+ aggrMap[channel] = field2;
41643
41994
  densityMap[channel] = true;
41644
41995
  } else if (channel === "weight") {
41645
- agg2 = sum2(field2);
41996
+ aggrMap.density = sum2(field2);
41646
41997
  } else if (channel !== "x" && channel !== "y") {
41647
- q.select({ [channel]: field2 });
41648
- groupby.push(channel);
41998
+ q.select({ [as]: field2 });
41999
+ groupby.push(as);
41649
42000
  }
41650
42001
  }
41651
42002
  }
41652
- return binType === "linear" ? binLinear2d2(q, x3, y3, agg2, nx, groupby) : bin2d2(q, x3, y3, agg2, nx, groupby);
42003
+ const aggr = this.aggr = Object.keys(aggrMap);
42004
+ if (aggrMap.density && aggr.length > 1) {
42005
+ throw new Error("Weight option can not be used with custom aggregates.");
42006
+ }
42007
+ if (!aggr.length) {
42008
+ aggr.push("density");
42009
+ aggrMap.density = count();
42010
+ }
42011
+ if (binType === "linear") {
42012
+ if (aggr.length > 1) {
42013
+ throw new Error("Linear binning not applicable to multiple aggregates.");
42014
+ }
42015
+ if (!aggrMap.density) {
42016
+ throw new Error("Linear binning not applicable to custom aggregates.");
42017
+ }
42018
+ return binLinear2d2(q, x3, y3, aggrMap.density, nx, groupby);
42019
+ } else {
42020
+ return bin2d2(q, x3, y3, aggrMap, nx, groupby);
42021
+ }
41653
42022
  }
41654
42023
  async requestTiles() {
41655
42024
  const mc = coordinator();
@@ -41699,22 +42068,20 @@ var RasterTileMark = class extends Grid2DMark {
41699
42068
  ([i, j]) => mc.prefetch(this.tileQuery(tileExtent(i, j)))
41700
42069
  );
41701
42070
  const tiles = await Promise.all(queries);
41702
- this.grids = [{ grid: processTiles(m, n, xx, yy, coords, tiles) }];
42071
+ this.grids = [{ density: processTiles(m, n, xx, yy, coords, tiles) }];
41703
42072
  this.convolve().update();
41704
42073
  }
41705
42074
  convolve() {
41706
42075
  return super.convolve().rasterize();
41707
42076
  }
41708
42077
  rasterize() {
41709
- const { bins: bins2, kde, groupby } = this;
42078
+ const { bins: bins2, kde } = this;
41710
42079
  const [w, h] = bins2;
41711
42080
  const { canvas, ctx, img } = imageData2(this, w, h);
41712
- const s2 = imageScale2(this);
41713
- const idx = groupby.indexOf(this.channelField("fill")?.as);
41714
- const domain = idx < 0 ? [] : kde.map(({ key }) => key[idx]);
41715
- this.data = kde.map((grid2) => {
41716
- const palette2 = imagePalette2(this, domain, grid2.key?.[idx]);
41717
- raster2(grid2, img.data, w, h, s2, palette2);
42081
+ const { alpha, alphaProp, color: color3, colorProp } = rasterEncoding(this);
42082
+ this.data = kde.map((cell3) => {
42083
+ color3?.(img.data, w, h, cell3[colorProp]);
42084
+ alpha?.(img.data, w, h, cell3[alphaProp]);
41718
42085
  ctx.putImageData(img, 0, 0);
41719
42086
  return { src: canvas.toDataURL() };
41720
42087
  });
@@ -41748,7 +42115,7 @@ function copy3(m, n, grid2, values2, tx, ty) {
41748
42115
  if (num === 0)
41749
42116
  return;
41750
42117
  const index2 = values2.getChild("index").toArray();
41751
- const value = values2.getChild("value").toArray();
42118
+ const value = values2.getChild("density").toArray();
41752
42119
  for (let row = 0; row < num; ++row) {
41753
42120
  const idx = index2[row];
41754
42121
  const i = tx + idx % m;
@@ -41767,60 +42134,10 @@ function imageData2(mark2, w, h) {
41767
42134
  }
41768
42135
  return mark2.image;
41769
42136
  }
41770
- function imageScale2(mark2) {
41771
- const { densityMap, kde, plot: plot3 } = mark2;
41772
- let domain = densityMap.fill && plot3.getAttribute("colorDomain");
41773
- if (!domain) {
41774
- let lo = 0, hi = 0;
41775
- kde.forEach((grid2) => {
41776
- for (const v2 of grid2) {
41777
- if (v2 < lo)
41778
- lo = v2;
41779
- if (v2 > hi)
41780
- hi = v2;
41781
- }
41782
- });
41783
- domain = lo === 0 && hi === 0 ? [0, 1] : [lo, hi];
41784
- }
41785
- const type2 = plot3.getAttribute("colorScale");
41786
- return scale2({ x: { type: type2, domain, range: [0, 1] } }).apply;
41787
- }
41788
- function imagePalette2(mark2, domain, value, steps = 1024) {
41789
- const { densityMap, plot: plot3 } = mark2;
41790
- const scheme28 = plot3.getAttribute("colorScheme");
41791
- const fill = mark2.channel("fill");
41792
- let color3 = isColor2(fill?.value) ? fill.value : void 0;
41793
- if (densityMap.fill || scheme28 && !color3) {
41794
- if (scheme28) {
41795
- try {
41796
- return palette(
41797
- steps,
41798
- scale2({ color: { scheme: scheme28, domain: [0, 1] } }).interpolate
41799
- );
41800
- } catch (err) {
41801
- console.warn(err);
41802
- }
41803
- }
41804
- } else if (domain.length) {
41805
- const range3 = plot3.getAttribute("colorRange");
41806
- const spec = {
41807
- domain,
41808
- range: range3,
41809
- scheme: scheme28 || (range3 ? void 0 : "tableau10")
41810
- };
41811
- color3 = scale2({ color: spec }).apply(value);
41812
- }
41813
- return palette(steps, opacityMap(color3));
41814
- }
41815
- function bin1d3(x3, x06, x12, n, reverse3, pad3) {
41816
- const d = (n - pad3) / (x12 - x06);
41817
- const f = d !== 1 ? ` * ${d}::DOUBLE` : "";
41818
- return reverse3 ? sql`(${x12} - ${x3}::DOUBLE)${f}` : sql`(${x3}::DOUBLE - ${x06})${f}`;
41819
- }
41820
- function bin2d2(q, xp, yp, value, xn, groupby) {
42137
+ function bin2d2(q, xp, yp, aggs, xn, groupby) {
41821
42138
  return q.select({
41822
42139
  index: sql`FLOOR(${xp})::INTEGER + FLOOR(${yp})::INTEGER * ${xn}`,
41823
- value
42140
+ ...aggs
41824
42141
  }).groupby("index", groupby);
41825
42142
  }
41826
42143
  function binLinear2d2(q, xp, yp, value, xn, groupby) {
@@ -41842,7 +42159,7 @@ function binLinear2d2(q, xp, yp, value, xn, groupby) {
41842
42159
  sql`FLOOR(xp)::INTEGER + 1 + (FLOOR(yp)::INTEGER + 1) * ${xn}`,
41843
42160
  sql`(xp - FLOOR(xp)::INTEGER) * (yp - FLOOR(yp)::INTEGER)${w}`
41844
42161
  );
41845
- return Query.from(Query.unionAll(a2, b, c4, d)).select({ index: "i", value: sum2("w") }, groupby).groupby("index", groupby).having(neq("value", 0));
42162
+ return Query.from(Query.unionAll(a2, b, c4, d)).select({ index: "i", density: sum2("w") }, groupby).groupby("index", groupby).having(neq("density", 0));
41846
42163
  }
41847
42164
  function tileFloor(value) {
41848
42165
  const floored = Math.floor(value);
@@ -42673,28 +42990,24 @@ function findMark({ marks: marks2 }, channel) {
42673
42990
  }
42674
42991
 
42675
42992
  // ../plot/src/transforms/bin.js
42676
- var EXTENT = [
42677
- "rectY-x",
42678
- "rectX-y",
42679
- "rect-x",
42680
- "rect-y"
42681
- ];
42682
- function hasExtent(channel, type2) {
42683
- return EXTENT.includes(`${type2}-${channel}`);
42684
- }
42993
+ var EXTENT = /* @__PURE__ */ new Set(["rectY-x", "rectX-y", "rect-x", "rect-y"]);
42685
42994
  function bin2(field2, options = { steps: 25 }) {
42686
42995
  const fn = (mark2, channel) => {
42687
- return hasExtent(channel, mark2.type) ? {
42688
- [`${channel}1`]: binField2(mark2, field2, options),
42689
- [`${channel}2`]: binField2(mark2, field2, { ...options, offset: 1 })
42690
- } : {
42691
- [channel]: binField2(mark2, field2, options)
42692
- };
42996
+ if (EXTENT.has(`${mark2.type}-${channel}`)) {
42997
+ return {
42998
+ [`${channel}1`]: binField(mark2, channel, field2, options),
42999
+ [`${channel}2`]: binField(mark2, channel, field2, { ...options, offset: 1 })
43000
+ };
43001
+ } else {
43002
+ return {
43003
+ [channel]: binField(mark2, channel, field2, options)
43004
+ };
43005
+ }
42693
43006
  };
42694
43007
  fn[Transform] = true;
42695
43008
  return fn;
42696
43009
  }
42697
- function binField2(mark2, column3, options) {
43010
+ function binField(mark2, channel, column3, options) {
42698
43011
  return {
42699
43012
  column: column3,
42700
43013
  label: column3,
@@ -42708,13 +43021,15 @@ function binField2(mark2, column3, options) {
42708
43021
  return column3;
42709
43022
  },
42710
43023
  toString() {
43024
+ const { apply: apply2, sqlApply, sqlInvert } = channelScale(mark2, channel);
42711
43025
  const { min: min5, max: max4 } = mark2.stats[column3];
42712
- const b = bins(min5, max4, options);
42713
- const col = asColumn(column3);
43026
+ const b = bins(apply2(min5), apply2(max4), options);
43027
+ const col = sqlApply(column3);
42714
43028
  const base = b.min === 0 ? col : `(${col} - ${b.min})`;
42715
43029
  const alpha = `${(b.max - b.min) / b.steps}::DOUBLE`;
42716
43030
  const off = options.offset ? `${options.offset} + ` : "";
42717
- return `${b.min} + ${alpha} * (${off}FLOOR(${base} / ${alpha})::INTEGER)`;
43031
+ const expr = `${b.min} + ${alpha} * (${off}FLOOR(${base} / ${alpha}))`;
43032
+ return `${sqlInvert(expr)}`;
42718
43033
  }
42719
43034
  };
42720
43035
  }
@@ -43311,8 +43626,11 @@ __export(attributes_exports, {
43311
43626
  align: () => align,
43312
43627
  aspectRatio: () => aspectRatio,
43313
43628
  axis: () => axis2,
43629
+ colorBase: () => colorBase,
43314
43630
  colorClamp: () => colorClamp,
43631
+ colorConstant: () => colorConstant2,
43315
43632
  colorDomain: () => colorDomain,
43633
+ colorExponent: () => colorExponent,
43316
43634
  colorInterpolate: () => colorInterpolate,
43317
43635
  colorLabel: () => colorLabel,
43318
43636
  colorN: () => colorN,
@@ -43320,8 +43638,8 @@ __export(attributes_exports, {
43320
43638
  colorPivot: () => colorPivot,
43321
43639
  colorRange: () => colorRange,
43322
43640
  colorReverse: () => colorReverse,
43323
- colorScale: () => colorScale,
43324
- colorScheme: () => colorScheme,
43641
+ colorScale: () => colorScale2,
43642
+ colorScheme: () => colorScheme2,
43325
43643
  colorSymmetric: () => colorSymmetric,
43326
43644
  colorTickFormat: () => colorTickFormat,
43327
43645
  colorZero: () => colorZero,
@@ -43390,8 +43708,11 @@ __export(attributes_exports, {
43390
43708
  height: () => height,
43391
43709
  inset: () => inset,
43392
43710
  label: () => label,
43711
+ lengthBase: () => lengthBase,
43393
43712
  lengthClamp: () => lengthClamp,
43713
+ lengthConstant: () => lengthConstant,
43394
43714
  lengthDomain: () => lengthDomain,
43715
+ lengthExponent: () => lengthExponent,
43395
43716
  lengthNice: () => lengthNice,
43396
43717
  lengthRange: () => lengthRange,
43397
43718
  lengthScale: () => lengthScale,
@@ -43403,8 +43724,11 @@ __export(attributes_exports, {
43403
43724
  marginTop: () => marginTop,
43404
43725
  margins: () => margins,
43405
43726
  name: () => name,
43727
+ opacityBase: () => opacityBase,
43406
43728
  opacityClamp: () => opacityClamp,
43729
+ opacityConstant: () => opacityConstant,
43407
43730
  opacityDomain: () => opacityDomain,
43731
+ opacityExponent: () => opacityExponent,
43408
43732
  opacityLabel: () => opacityLabel,
43409
43733
  opacityNice: () => opacityNice,
43410
43734
  opacityRange: () => opacityRange,
@@ -43424,8 +43748,11 @@ __export(attributes_exports, {
43424
43748
  projectionPrecision: () => projectionPrecision,
43425
43749
  projectionRotate: () => projectionRotate,
43426
43750
  projectionType: () => projectionType,
43751
+ rBase: () => rBase,
43427
43752
  rClamp: () => rClamp,
43753
+ rConstant: () => rConstant,
43428
43754
  rDomain: () => rDomain,
43755
+ rExponent: () => rExponent,
43429
43756
  rNice: () => rNice,
43430
43757
  rRange: () => rRange,
43431
43758
  rScale: () => rScale,
@@ -43437,8 +43764,11 @@ __export(attributes_exports, {
43437
43764
  xAriaDescription: () => xAriaDescription,
43438
43765
  xAriaLabel: () => xAriaLabel,
43439
43766
  xAxis: () => xAxis,
43767
+ xBase: () => xBase,
43440
43768
  xClamp: () => xClamp,
43769
+ xConstant: () => xConstant,
43441
43770
  xDomain: () => xDomain,
43771
+ xExponent: () => xExponent,
43442
43772
  xFontVariant: () => xFontVariant,
43443
43773
  xGrid: () => xGrid,
43444
43774
  xInset: () => xInset,
@@ -43468,8 +43798,11 @@ __export(attributes_exports, {
43468
43798
  yAriaDescription: () => yAriaDescription,
43469
43799
  yAriaLabel: () => yAriaLabel,
43470
43800
  yAxis: () => yAxis,
43801
+ yBase: () => yBase,
43471
43802
  yClamp: () => yClamp,
43803
+ yConstant: () => yConstant,
43472
43804
  yDomain: () => yDomain,
43805
+ yExponent: () => yExponent,
43473
43806
  yFontVariant: () => yFontVariant,
43474
43807
  yGrid: () => yGrid,
43475
43808
  yInset: () => yInset,
@@ -43628,6 +43961,9 @@ var xAriaLabel = attrf("xAriaLabel");
43628
43961
  var xAriaDescription = attrf("xAriaDescription");
43629
43962
  var xReverse = attrf("xReverse");
43630
43963
  var xZero = attrf("xZero");
43964
+ var xBase = attrf("xBase");
43965
+ var xExponent = attrf("xExponent");
43966
+ var xConstant = attrf("xConstant");
43631
43967
  var yScale = attrf("yScale");
43632
43968
  var yDomain = attrf("yDomain");
43633
43969
  var yRange = attrf("yRange");
@@ -43658,6 +43994,9 @@ var yAriaLabel = attrf("yAriaLabel");
43658
43994
  var yAriaDescription = attrf("yAriaDescription");
43659
43995
  var yReverse = attrf("yReverse");
43660
43996
  var yZero = attrf("yZero");
43997
+ var yBase = attrf("yBase");
43998
+ var yExponent = attrf("yExponent");
43999
+ var yConstant = attrf("yConstant");
43661
44000
  var facetMargin = attrf("facetMargin");
43662
44001
  var facetMarginTop = attrf("facetMarginTop");
43663
44002
  var facetMarginBottom = attrf("facetMarginBottom");
@@ -43719,13 +44058,13 @@ var fyFontVariant = attrf("fyFontVariant");
43719
44058
  var fyAriaLabel = attrf("fyAriaLabel");
43720
44059
  var fyAriaDescription = attrf("fyAriaDescription");
43721
44060
  var fyReverse = attrf("fyReverse");
43722
- var colorScale = attrf("colorScale");
44061
+ var colorScale2 = attrf("colorScale");
43723
44062
  var colorDomain = attrf("colorDomain");
43724
44063
  var colorRange = attrf("colorRange");
43725
44064
  var colorClamp = attrf("colorClamp");
43726
44065
  var colorN = attrf("colorN");
43727
44066
  var colorNice = attrf("colorNice");
43728
- var colorScheme = attrf("colorScheme");
44067
+ var colorScheme2 = attrf("colorScheme");
43729
44068
  var colorInterpolate = attrf("colorInterpolate");
43730
44069
  var colorPivot = attrf("colorPivot");
43731
44070
  var colorSymmetric = attrf("colorSymmetric");
@@ -43733,6 +44072,9 @@ var colorLabel = attrf("colorLabel");
43733
44072
  var colorReverse = attrf("colorReverse");
43734
44073
  var colorZero = attrf("colorZero");
43735
44074
  var colorTickFormat = attrf("colorTickFormat");
44075
+ var colorBase = attrf("colorBase");
44076
+ var colorExponent = attrf("colorExponent");
44077
+ var colorConstant2 = attrf("colorConstant");
43736
44078
  var opacityScale = attrf("opacityScale");
43737
44079
  var opacityDomain = attrf("opacityDomain");
43738
44080
  var opacityRange = attrf("opacityRange");
@@ -43742,18 +44084,27 @@ var opacityLabel = attrf("opacityLabel");
43742
44084
  var opacityReverse = attrf("opacityReverse");
43743
44085
  var opacityZero = attrf("opacityZero");
43744
44086
  var opacityTickFormat = attrf("opacityTickFormat");
44087
+ var opacityBase = attrf("opacityBase");
44088
+ var opacityExponent = attrf("opacityExponent");
44089
+ var opacityConstant = attrf("opacityConstant");
43745
44090
  var rScale = attrf("rScale");
43746
44091
  var rDomain = attrf("rDomain");
43747
44092
  var rRange = attrf("rRange");
43748
44093
  var rClamp = attrf("rClamp");
43749
44094
  var rNice = attrf("rNice");
43750
44095
  var rZero = attrf("rZero");
44096
+ var rBase = attrf("rBase");
44097
+ var rExponent = attrf("rExponent");
44098
+ var rConstant = attrf("rConstant");
43751
44099
  var lengthScale = attrf("lengthScale");
43752
44100
  var lengthDomain = attrf("lengthDomain");
43753
44101
  var lengthRange = attrf("lengthRange");
43754
44102
  var lengthClamp = attrf("lengthClamp");
43755
44103
  var lengthNice = attrf("lengthNice");
43756
44104
  var lengthZero = attrf("lengthZero");
44105
+ var lengthBase = attrf("lengthBase");
44106
+ var lengthExponent = attrf("lengthExponent");
44107
+ var lengthConstant = attrf("lengthConstant");
43757
44108
  var projectionType = attrf("projectionType");
43758
44109
  var projectionParallels = attrf("projectionParallels");
43759
44110
  var projectionPrecision = attrf("projectionPrecision");
@@ -43805,6 +44156,7 @@ __export(marks_exports, {
43805
44156
  gridFy: () => gridFy2,
43806
44157
  gridX: () => gridX2,
43807
44158
  gridY: () => gridY2,
44159
+ heatmap: () => heatmap,
43808
44160
  hexagon: () => hexagon2,
43809
44161
  hexbin: () => hexbin2,
43810
44162
  hexgrid: () => hexgrid2,
@@ -43814,7 +44166,7 @@ __export(marks_exports, {
43814
44166
  lineX: () => lineX2,
43815
44167
  lineY: () => lineY2,
43816
44168
  link: () => link3,
43817
- raster: () => raster3,
44169
+ raster: () => raster2,
43818
44170
  rasterTile: () => rasterTile,
43819
44171
  rect: () => rect2,
43820
44172
  rectX: () => rectX2,
@@ -43903,7 +44255,8 @@ var densityY = (...args) => explicitType(Density1DMark, "areaY", ...args);
43903
44255
  var density2 = (...args) => implicitType(Density2DMark, ...args);
43904
44256
  var denseLine = (...args) => implicitType(DenseLineMark, ...args);
43905
44257
  var contour2 = (...args) => implicitType(ContourMark, ...args);
43906
- var raster3 = (...args) => implicitType(RasterMark, ...args);
44258
+ var heatmap = (...args) => implicitType(HeatmapMark, ...args);
44259
+ var raster2 = (...args) => implicitType(RasterMark, ...args);
43907
44260
  var rasterTile = (...args) => implicitType(RasterTileMark, ...args);
43908
44261
  var hexbin2 = (...args) => implicitType(HexbinMark, ...args);
43909
44262
  var hexgrid2 = (...args) => mark("hexgrid", ...args);
@@ -45271,6 +45624,8 @@ function plotMarkNames(overrides = []) {
45271
45624
  // src/config/transforms.js
45272
45625
  function transformNames(overrides = []) {
45273
45626
  return /* @__PURE__ */ new Set([
45627
+ "argmin",
45628
+ "argmax",
45274
45629
  "avg",
45275
45630
  "bin",
45276
45631
  "centroid",
@@ -45280,11 +45635,14 @@ function transformNames(overrides = []) {
45280
45635
  "dateMonth",
45281
45636
  "dateMonthDay",
45282
45637
  "dateDay",
45638
+ "first",
45283
45639
  "geojson",
45640
+ "last",
45284
45641
  "max",
45285
45642
  "median",
45286
45643
  "min",
45287
45644
  "mode",
45645
+ "product",
45288
45646
  "quantile",
45289
45647
  "sum",
45290
45648
  "row_number",