@sipemu/ggplot-rs 0.39.0 → 0.40.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.
@@ -69,12 +69,40 @@ export interface LayerParams {
69
69
  target?: string;
70
70
  /** bullet / bullet_vertical: qualitative range band upper bounds. */
71
71
  ranges?: number[];
72
+ /** boxplot: notched box (`notch = TRUE`). */
73
+ notch?: boolean;
74
+ /** boxplot: box width ∝ √n. */
75
+ varwidth?: boolean;
76
+ /** boxplot: whisker reach in IQRs (default 1.5). */
77
+ coef?: number;
78
+ /** boxplot: draw outliers (default true; false also drops them from the scale). */
79
+ outliers?: boolean;
80
+ /** boxplot: whisker cap width relative to the box (0 = none). */
81
+ staplewidth?: number;
82
+ /** violin: trim to the data range (default true). */
83
+ trim?: boolean;
84
+ /** violin: `"area"` (default), `"count"`, `"width"`. */
85
+ scale?: "area" | "count" | "width";
86
+ /** violin: draw lines at these sample quantiles. */
87
+ quantiles?: number[];
88
+ /** violin: fixed kernel bandwidth (default `bw.nrd0`). */
89
+ bw?: number;
90
+ /** violin: bandwidth multiplier. */
91
+ adjust?: number;
92
+ /** stat "connect": how consecutive points join (default "hv"). */
93
+ connection?: "hv" | "vh" | "mid" | "linear";
94
+ /** stat "summary_hex": summary of the raw `z` column (default "mean"). */
95
+ fun?: "mean" | "median" | "min" | "max" | "sum";
72
96
  }
73
97
 
74
98
  export type PositionName = "identity" | "stack" | "fill" | "dodge" | "dodge2" | "jitter" | "nudge";
75
99
  export type Position =
76
100
  | PositionName
77
- | { type: PositionName; width?: number; height?: number; padding?: number; x?: number; y?: number };
101
+ | {
102
+ type: PositionName; width?: number; height?: number; padding?: number; x?: number; y?: number;
103
+ /** dodge / dodge2: keep one group's width in slots with fewer groups (default "total"). */
104
+ preserve?: "total" | "single";
105
+ };
78
106
 
79
107
  export interface Layer {
80
108
  geom: GeomName;
@@ -83,8 +111,17 @@ export interface Layer {
83
111
  /** Layer-specific data, replacing the plot's. */
84
112
  data?: Data;
85
113
  params?: LayerParams;
86
- /** Override the geom's default stat; only "identity" is supported. */
87
- stat?: "identity";
114
+ /** Override the geom's default stat: "identity" (plot values as given), "unique"
115
+ * (drop duplicate rows), "connect" (steps, see params.connection), "summary_hex"
116
+ * (hexagons of params.fun over a `z` column), "sf_coordinates" (a point per WKT
117
+ * `geometry`, e.g. text on a map). */
118
+ stat?: "identity" | "unique" | "connect" | "summary_hex" | "sf_coordinates";
119
+ /** Legend key picture (ggplot2's key_glyph); default per geom. */
120
+ key_glyph?: "point" | "path" | "rect" | "polygon" | "boxplot" | "crossbar" | "pointrange"
121
+ | "linerange" | "smooth" | "text" | "label" | "vline" | "vpath" | "abline" | "timeseries"
122
+ | "dotplot" | "blank";
123
+ /** Show this layer in the legends, or per aesthetic: `{ color: true, fill: false }`. */
124
+ show_legend?: boolean | Partial<Record<"color" | "colour" | "fill" | "shape" | "size" | "alpha" | "linetype" | "linewidth", boolean>>;
88
125
  position?: Position;
89
126
  }
90
127
 
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sipemu/ggplot-rs",
3
- "version": "0.39.0",
3
+ "version": "0.40.0",
4
4
  "description": "Grammar-of-graphics charts (ggplot2-style) rendered to SVG — WebAssembly build of the ggplot-rs Rust crate, no runtime dependencies",
5
5
  "type": "module",
6
6
  "main": "./dist/ggplot_rs.js",
@@ -64,10 +64,12 @@ if (!svg.startsWith("<svg")) throw new Error("render failed");
64
64
  | `data` | `{ col: (number \| string \| boolean \| null)[] }` — numbers continuous, strings/booleans categorical |
65
65
  | `aes` / `layers[].aes` | aesthetic → column: `x y color fill size shape alpha group linetype linewidth label weight xmin xmax ymin ymax xend yend angle radius tooltip from to subgroup open high low close lower middle upper fontface class` |
66
66
  | `layers[].geom` | see Geoms |
67
- | `layers[].params` | `bins` · `method` (`"lm"`/`"loess"`) `span` `se` · `yintercept` `xintercept` `slope` `intercept` · `levels` · `rows` · `box_size` `reversal` · `shape` · `speed` `direction` · `censor` · `projection` · `target` `ranges` |
68
- | `layers[].position` | `identity stack fill dodge dodge2 jitter nudge`, or `{ type: "dodge", width: 0.8 }` |
69
- | `layers[].stat` | `"identity"` (plot precomputed values, e.g. bar heights) |
67
+ | `layers[].params` | `bins` · `method` (`"lm"`/`"loess"`) `span` `se` · `yintercept` `xintercept` `slope` `intercept` · `levels` · `rows` · `box_size` `reversal` · `shape` · `speed` `direction` · `censor` · `projection` · `target` `ranges` · boxplot `notch` `varwidth` `coef` `outliers` `staplewidth` · violin `trim` `scale` (`"area"`/`"count"`/`"width"`) `quantiles` `bw` `adjust` · stat connect `connection` · stat summary_hex `fun` |
68
+ | `layers[].position` | `identity stack fill dodge dodge2 jitter nudge`, or `{ type: "dodge", width: 0.8, preserve: "single" }`. boxplot dodges (`dodge2`) and violin (`dodge`) by default, so grouped boxes sit side by side |
69
+ | `layers[].stat` | `"identity"` (plot precomputed values, e.g. bar heights), `"unique"` (drop duplicate rows), `"connect"` (steps; `params.connection` `hv`/`vh`/`mid`/`linear`), `"summary_hex"` (`params.fun` of a `z` column per hexagon), `"sf_coordinates"` (a point per WKT `geometry` — text on a map) |
70
70
  | `layers[].data` | layer-specific data |
71
+ | `layers[].key_glyph` | legend key picture: `point path rect polygon boxplot crossbar pointrange linerange smooth text label vline vpath abline timeseries dotplot blank` (default per geom; layers on one mapping share a key) |
72
+ | `layers[].show_legend` | `false` hides the layer from legends; `{ color: false }` per aesthetic |
71
73
  | `scales.x/y` | `{ trans, limits: [lo, hi], breaks: [...], name }`; trans `log10 log2 ln sqrt reverse logit probit pseudo_log reciprocal exp` |
72
74
  | `scales.color/fill` | `{ palette }` (`Set1 Dark2 Paired npg …` categorical; `viridis magma plasma inferno` numeric), `{ values: { level: "#rrggbb" } }`, `{ gradient: ["#lo", "#hi"] }`, `{ levels: [...] }` |
73
75
  | `facet` | `{ wrap, ncol?, scales? }` or `{ rows?, cols?, scales? }`; scales `fixed free free_x free_y` |