ggaction 0.0.7 → 0.0.8

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +1 -1
  3. package/package.json +1 -1
  4. package/src/actions/categoryOrder/index.js +111 -0
  5. package/src/actions/data/index.js +6 -0
  6. package/src/actions/data/timeUnit.js +48 -0
  7. package/src/actions/encodings/angle.js +77 -0
  8. package/src/actions/encodings/color/index.js +17 -13
  9. package/src/actions/encodings/color/layout.js +2 -0
  10. package/src/actions/encodings/color/policy.js +3 -0
  11. package/src/actions/encodings/index.js +2 -0
  12. package/src/actions/encodings/position/policies/area.js +40 -2
  13. package/src/actions/encodings/position/policies/bar.js +6 -0
  14. package/src/actions/encodings/position/policies/index.js +2 -0
  15. package/src/actions/encodings/position/policies/tick.js +19 -0
  16. package/src/actions/encodings/remove.js +1 -1
  17. package/src/actions/guides/legends/categorical/actions.js +23 -6
  18. package/src/actions/guides/legends/categorical/index.js +8 -0
  19. package/src/actions/guides/legends/continuous/common.js +17 -5
  20. package/src/actions/guides/legends/continuous/gradient.js +12 -8
  21. package/src/actions/guides/legends/continuous/opacity.js +70 -17
  22. package/src/actions/guides/legends/edit.js +13 -8
  23. package/src/actions/guides/legends/lane.js +468 -0
  24. package/src/actions/guides/legends/remove.js +3 -7
  25. package/src/actions/index.js +2 -0
  26. package/src/actions/marks/area/actions.js +3 -1
  27. package/src/actions/marks/area/materialize.js +12 -3
  28. package/src/actions/marks/index.js +2 -0
  29. package/src/actions/marks/point/materialize.js +17 -5
  30. package/src/actions/marks/tick/actions.js +225 -0
  31. package/src/actions/marks/tick/index.js +1 -0
  32. package/src/actions/primitives/semanticValidation/layer.js +2 -0
  33. package/src/actions/scales/consumers/index.js +8 -0
  34. package/src/actions/scales/consumers/seriesLayout.js +22 -2
  35. package/src/actions/scales/materialize.js +2 -0
  36. package/src/actions/selection/actions.js +5 -2
  37. package/src/core/vocabulary.js +7 -3
  38. package/src/grammar/areaSeries.js +112 -2
  39. package/src/grammar/categoryOrder.js +138 -0
  40. package/src/grammar/direction.js +46 -0
  41. package/src/grammar/facets/index.js +1 -1
  42. package/src/grammar/pointShapes.js +34 -6
  43. package/src/grammar/positionCompatibility.js +4 -0
  44. package/src/grammar/schemas/semanticPath.js +2 -1
  45. package/src/grammar/seriesLayout.js +10 -2
  46. package/src/grammar/timeUnit.js +108 -0
  47. package/src/grammar/transforms.js +6 -0
  48. package/src/grammar/window.js +73 -7
  49. package/src/layout/legendLane.js +338 -0
  50. package/src/materialization/marks/capabilities.js +9 -0
  51. package/src/materialization/marks/index.js +2 -1
  52. package/src/materialization/marks/policies.js +13 -0
  53. package/src/materialization/scales/policies/series.js +9 -0
  54. package/src/materialization/scales/resolve.js +25 -3
  55. package/src/materialization/selection/items/index.js +1 -0
  56. package/src/materialization/selection/items/path.js +4 -1
  57. package/src/materialization/selection/items/tick.js +42 -0
  58. package/src/materialization/selection/policies/index.js +2 -0
  59. package/src/materialization/selection/policies/tick.js +10 -0
  60. package/types/index.d.ts +10 -0
  61. package/types/program.d.ts +96 -3
@@ -78,6 +78,7 @@ export type ScaleType =
78
78
  | "quantile"
79
79
  | "threshold";
80
80
  export type StackMode = "zero" | "normalize" | null;
81
+ export type YStackMode = StackMode | "center";
81
82
  export type CompositionAlign = "start" | "center" | "end";
82
83
  export interface CompositionPadding {
83
84
  top?: number;
@@ -370,6 +371,15 @@ export type WindowOperation =
370
371
  as: string;
371
372
  offset?: number;
372
373
  default?: unknown;
374
+ }
375
+ | {
376
+ op: "movingMean" | "movingSum";
377
+ field: string;
378
+ as: string;
379
+ frame: {
380
+ preceding: number;
381
+ following?: number;
382
+ };
373
383
  };
374
384
  export interface DatasetWindowSort {
375
385
  readonly field: string;
@@ -388,6 +398,15 @@ export type DatasetWindowOperation =
388
398
  readonly as: string;
389
399
  readonly offset: number;
390
400
  readonly default: unknown;
401
+ }
402
+ | {
403
+ readonly op: "movingMean" | "movingSum";
404
+ readonly field: string;
405
+ readonly as: string;
406
+ readonly frame: {
407
+ readonly preceding: number;
408
+ readonly following: number;
409
+ };
391
410
  };
392
411
  export interface DatasetWindowTransform {
393
412
  readonly type: "window";
@@ -395,6 +414,20 @@ export interface DatasetWindowTransform {
395
414
  readonly sortBy: readonly DatasetWindowSort[];
396
415
  readonly operations: readonly DatasetWindowOperation[];
397
416
  }
417
+ export type TimeUnit =
418
+ | "year"
419
+ | "quarter"
420
+ | "month"
421
+ | "day"
422
+ | "hour"
423
+ | "minute"
424
+ | "second";
425
+ export interface DatasetTimeUnitTransform {
426
+ readonly type: "timeUnit";
427
+ readonly field: string;
428
+ readonly unit: TimeUnit;
429
+ readonly as: string;
430
+ }
398
431
  export interface Bin2DCounts {
399
432
  x: number;
400
433
  y: number;
@@ -451,6 +484,7 @@ export type DatasetTransform =
451
484
  | DatasetDensityTransform
452
485
  | DatasetHorizonTransform
453
486
  | DatasetIntervalTransform
487
+ | DatasetTimeUnitTransform
454
488
  | DatasetWindowTransform;
455
489
  export interface CreateDerivedDataOptions {
456
490
  id: string;
@@ -518,7 +552,8 @@ export type ColorLayout =
518
552
  | "fill"
519
553
  | "group"
520
554
  | "overlay"
521
- | "diverging";
555
+ | "diverging"
556
+ | "center";
522
557
  export type ScalarAggregateOperation =
523
558
  | "count" | "sum" | "mean" | "median" | "min" | "max"
524
559
  | "distinct" | "valid" | "missing"
@@ -918,6 +953,9 @@ export interface PositionEncodingOptions {
918
953
  stack?: StackMode;
919
954
  }
920
955
 
956
+ export type YPositionEncodingOptions =
957
+ Omit<PositionEncodingOptions, "stack"> & { stack?: YStackMode };
958
+
921
959
  export interface ThetaScaleOptions {
922
960
  id?: string;
923
961
  type?: "linear" | "time" | "band" | "point";
@@ -1111,6 +1149,14 @@ export interface WindowDataOptions {
1111
1149
  operations: readonly WindowOperation[];
1112
1150
  }
1113
1151
 
1152
+ export interface TimeUnitDataOptions {
1153
+ id: string;
1154
+ source?: string;
1155
+ field: string;
1156
+ unit: TimeUnit;
1157
+ as: string;
1158
+ }
1159
+
1114
1160
  export interface Bin2DDataOptions {
1115
1161
  id: string;
1116
1162
  source?: string;
@@ -2098,6 +2144,31 @@ export interface RemovePathOrderOptions {
2098
2144
  target?: string;
2099
2145
  }
2100
2146
 
2147
+ export type CategoryValue = string | number | boolean;
2148
+ export type CategoryOrderSummary = {
2149
+ field: string;
2150
+ aggregate: "sum" | "mean" | "min" | "max";
2151
+ };
2152
+ export type CategoryOrder =
2153
+ | {
2154
+ values: readonly CategoryValue[];
2155
+ by?: never;
2156
+ direction?: never;
2157
+ }
2158
+ | {
2159
+ values?: never;
2160
+ by: "category" | "count" | CategoryOrderSummary;
2161
+ direction?: "ascending" | "descending";
2162
+ };
2163
+ export type OrderCategoriesOptions = {
2164
+ target?: string;
2165
+ channel: "x" | "y";
2166
+ } & CategoryOrder;
2167
+ export interface RemoveCategoryOrderOptions {
2168
+ target?: string;
2169
+ channel: "x" | "y";
2170
+ }
2171
+
2101
2172
  export interface TitleOptions {
2102
2173
  text: string;
2103
2174
  subtitle?: string;
@@ -2143,6 +2214,7 @@ export class ChartProgram {
2143
2214
  createDensityData(options: DensityDataOptions): ChartProgram;
2144
2215
  createRegressionData(options: RegressionDataOptions): ChartProgram;
2145
2216
  createIntervalData(options: IntervalDataOptions): ChartProgram;
2217
+ createTimeUnitData(options: TimeUnitDataOptions): ChartProgram;
2146
2218
  createWindowData(options: WindowDataOptions): ChartProgram;
2147
2219
  createBin2DData(options: Bin2DDataOptions): ChartProgram;
2148
2220
  editBin2DData(options: EditBin2DDataOptions): ChartProgram;
@@ -2164,6 +2236,21 @@ export class ChartProgram {
2164
2236
  stroke?: string | false;
2165
2237
  strokeWidth?: number;
2166
2238
  }): ChartProgram;
2239
+ createTickMark(options?: {
2240
+ id?: string;
2241
+ data?: string;
2242
+ length?: number;
2243
+ stroke?: string;
2244
+ strokeWidth?: number;
2245
+ opacity?: number;
2246
+ }): ChartProgram;
2247
+ editTickMark(options: {
2248
+ target?: string;
2249
+ length?: number;
2250
+ stroke?: string;
2251
+ strokeWidth?: number;
2252
+ opacity?: number;
2253
+ }): ChartProgram;
2167
2254
  jitterPoints(options: JitterPointsOptions): ChartProgram;
2168
2255
  removeJitter(options?: RemoveJitterOptions): ChartProgram;
2169
2256
  createLineMark(options?: {
@@ -2243,7 +2330,7 @@ export class ChartProgram {
2243
2330
  }): ChartProgram;
2244
2331
 
2245
2332
  encodeX(options: PositionEncodingOptions | RulePositionEncodingOptions): ChartProgram;
2246
- encodeY(options: PositionEncodingOptions | RulePositionEncodingOptions): ChartProgram;
2333
+ encodeY(options: YPositionEncodingOptions | RulePositionEncodingOptions): ChartProgram;
2247
2334
  encodeTheta(options: ThetaEncodingOptions): ChartProgram;
2248
2335
  encodeR(options: RadialEncodingOptions): ChartProgram;
2249
2336
  encodeX2(options: SecondaryPositionEncodingOptions): ChartProgram;
@@ -2251,6 +2338,10 @@ export class ChartProgram {
2251
2338
  encodeStrokeDash(options: StrokeDashEncodingOptions): ChartProgram;
2252
2339
  encodeSize(options: { field: string; target?: string; fieldType?: "quantitative"; scale?: ScaleOptions }): ChartProgram;
2253
2340
  encodeShape(options: { field: string; target?: string; fieldType?: "nominal"; scale?: ScaleOptions }): ChartProgram;
2341
+ encodeAngle(options:
2342
+ | { target?: string; value: number; field?: never; fieldType?: never }
2343
+ | { target?: string; field: string; fieldType?: "quantitative"; value?: never }
2344
+ ): ChartProgram;
2254
2345
  encodeOpacity(options: OpacityEncodingOptions): ChartProgram;
2255
2346
  encodeRadius(options: { value: number; target?: string }): ChartProgram;
2256
2347
  encodePointRadius(options: { value: number; target?: string }): ChartProgram;
@@ -2276,14 +2367,16 @@ export class ChartProgram {
2276
2367
  }): ChartProgram;
2277
2368
  encodeGroup(options: { field: string; target?: string; fieldType?: "nominal" }): ChartProgram;
2278
2369
  encodePathOrder(options: PathOrderEncodingOptions): ChartProgram;
2370
+ orderCategories(options: OrderCategoriesOptions): ChartProgram;
2279
2371
  encodeParallelCoordinates(options: ParallelCoordinatesEncodingOptions): ChartProgram;
2280
2372
  removePathOrder(options?: RemovePathOrderOptions): ChartProgram;
2373
+ removeCategoryOrder(options: RemoveCategoryOrderOptions): ChartProgram;
2281
2374
  removeEncoding(options: {
2282
2375
  target?: string;
2283
2376
  channel:
2284
2377
  | "x" | "y" | "x2" | "y2" | "xOffset" | "yOffset"
2285
2378
  | "theta" | "radius" | "color" | "strokeDash" | "strokeWidth"
2286
- | "size" | "shape" | "group" | "opacity" | "text";
2379
+ | "size" | "shape" | "angle" | "group" | "opacity" | "text";
2287
2380
  }): ChartProgram;
2288
2381
  encodeText(options: TextEncodingOptions): ChartProgram;
2289
2382
  encodeHistogram(options: HistogramEncodingOptions): ChartProgram;