@uwdata/mosaic-plot 0.19.1 → 0.20.1

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.
@@ -40,7 +40,7 @@ export class Grid2DMark extends Mark {
40
40
  } | {
41
41
  numRows: number;
42
42
  columns: {
43
- [x: string]: import("./util/grid.js").Arrayish | Int32Array<ArrayBuffer> | Uint8Array<ArrayBuffer> | Int8Array<ArrayBuffer> | Uint8ClampedArray<ArrayBuffer> | Int16Array<ArrayBuffer> | Uint16Array<ArrayBuffer> | Uint32Array<ArrayBuffer> | Float32Array<ArrayBuffer> | Float64Array<ArrayBuffer>;
43
+ [x: string]: import("./util/grid.js").Arrayish | Uint8Array<ArrayBuffer> | Int8Array<ArrayBuffer> | Uint8ClampedArray<ArrayBuffer> | Int16Array<ArrayBuffer> | Uint16Array<ArrayBuffer> | Int32Array<ArrayBuffer> | Uint32Array<ArrayBuffer> | Float32Array<ArrayBuffer> | Float64Array<ArrayBuffer>;
44
44
  };
45
45
  };
46
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../../src/transforms/bin.js"],"names":[],"mappings":"AAQA,4DAEC;AAED;;;;;EAeC;AAWD;IACE,gEAMC;IAJC,YAAoB;IACpB,UAAgB;IAChB,aAAsB;IACtB,aAAsB;IAGxB;;;MAEC;CAaF;0BA7DyB,eAAe;yBADO,oBAAoB"}
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../../src/transforms/bin.js"],"names":[],"mappings":"AASA,4DAEC;AAED;;;;;EAeC;AAWD;IACE,gEAMC;IAJC,YAAoB;IACpB,UAAgB;IAChB,aAAsB;IACtB,aAAsB;IAGxB;;;MAEC;CAgBF;0BAhEyB,eAAe;yBAD4B,oBAAoB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uwdata/mosaic-plot",
3
- "version": "0.19.1",
3
+ "version": "0.20.1",
4
4
  "description": "A Mosaic-powered plotting framework based on Observable Plot.",
5
5
  "keywords": [
6
6
  "data",
@@ -34,9 +34,9 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@observablehq/plot": "^0.6.17",
37
- "@uwdata/mosaic-core": "^0.19.1",
38
- "@uwdata/mosaic-sql": "^0.19.0",
37
+ "@uwdata/mosaic-core": "^0.20.1",
38
+ "@uwdata/mosaic-sql": "^0.20.1",
39
39
  "d3": "^7.9.0"
40
40
  },
41
- "gitHead": "64ac2aaeefe9ff469edfeed417414a0a7866863f"
41
+ "gitHead": "1e093fdf1bd1f1300d64ed2c4f7efcec74218048"
42
42
  }
@@ -123,7 +123,9 @@ function inferLabel(key, spec, marks) {
123
123
  function fieldLabel(field) {
124
124
  if (!field) return undefined;
125
125
  switch (field.type) {
126
- case 'COLUMN_REF': return field.column;
126
+ case 'COLUMN_REF':
127
+ case 'CUSTOM':
128
+ return field.column;
127
129
  case 'CAST': return fieldLabel(field.expr);
128
130
  case 'FUNCTION':
129
131
  if (field.name === 'make_date') return 'date';
@@ -1,4 +1,5 @@
1
- import { ExprNode, binDate, binHistogram } from '@uwdata/mosaic-sql';
1
+ /** @import { SQLCodeGenerator } from '@uwdata/mosaic-sql'; */
2
+ import { ExprNode, binDate, binHistogram, duckDBCodeGenerator } from '@uwdata/mosaic-sql';
2
3
  import { Transform } from '../symbols.js';
3
4
  import { channelScale } from '../marks/util/channel-scale.js';
4
5
 
@@ -38,7 +39,7 @@ function hasTimeScale(mark, channel) {
38
39
 
39
40
  class BinTransformNode extends ExprNode {
40
41
  constructor(column, mark, channel, options) {
41
- super('COLUMN_REF');
42
+ super('CUSTOM');
42
43
  this.column = column;
43
44
  this.mark = mark;
44
45
  this.channel = channel;
@@ -49,7 +50,10 @@ class BinTransformNode extends ExprNode {
49
50
  return { column: this.column, stats: ['min', 'max'] };
50
51
  }
51
52
 
52
- toString() {
53
+ /**
54
+ * @param {SQLCodeGenerator} visitor
55
+ */
56
+ toString(visitor = duckDBCodeGenerator) {
53
57
  const { mark, channel, column, options } = this;
54
58
  const { type, min, max } = mark.channelField(channel);
55
59
  const isDate = options.interval
@@ -58,6 +62,6 @@ class BinTransformNode extends ExprNode {
58
62
  const result = isDate
59
63
  ? binDate(column, [min, max], options)
60
64
  : binHistogram(column, [min, max], options, channelScale(mark, channel));
61
- return `${result}`;
65
+ return visitor.toString(result);
62
66
  }
63
67
  }