@datama/studio-skill-instructions 0.0.0-stage → 1.0.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.
@@ -0,0 +1,77 @@
1
+ # Datama Studio
2
+
3
+ Delivers a standalone HTML page rendering Datama Studio **stories** (one question each, holding one or more analyses) or a single **Plotter** chart. The dataset is inlined in the page; Datama computes in the browser.
4
+
5
+ Linked `references/…` files are read the same way as this one: `python3 scripts/datama.py instructions references/<file>.md`. Read one only when the request needs it.
6
+
7
+ ## Steps
8
+
9
+ 1. **Pick the solution.** Two sides ("2024 vs 2025", "before/after", "why did X drop") → `compare`. A breakdown or a chart across dimensions → `explore`. Unusual points over time → `detect` (needs a date column). Where a KPI is the most uneven, no comparison → `pivot`. One exact chart from aggregated values, no analysis → [Plotter](#plotter). Comparison and breakdown together, or unclear → `compare`.
10
+ 2. **Save the dataset to a file once, as you received it**: a JSON array, a connector result holding a `rows` array, JSON Lines or CSV. Over ~20 000 rows, aggregate along the dimensions that matter first.
11
+ 3. **Write the configuration** (below), then **build**:
12
+
13
+ ```bash
14
+ python3 scripts/datama.py build --data rows.json --config '<json>' --out page.html
15
+ ```
16
+
17
+ It prints `true`, a summary line and `Warning:` lines (then, for a licensed page, `Datama comment:` and the comments the page shows), or `Validation failed:` with one fix per line: apply them and run it again. Warnings do not block: fix those that touch the request. Without Python, fill `assets/studio-output-template.html` by hand with [studio-instantiation.md](references/studio-instantiation.md) and [studio-stories.md](references/studio-stories.md).
18
+ 4. **Deliver** the page: an HTML Artifact with `capabilities: {downloads: true}` on Claude, a full-height iframe Frame on Dust (if the Frame blocks the CDN, the `.html` file to open in a browser), Canvas or the file on ChatGPT, the file in the workspace on Cursor and Claude Code.
19
+ 5. **Summarize.** When the build printed `Datama comment:`, sum up those comments in the user's words: they are the analysis the page shows. Otherwise say in a few lines what each story analyses. Never produce a breakdown of your own from the rows.
20
+
21
+ ## Configuration
22
+
23
+ Write only the choices that need judgement, as one flat JSON object. The build derives the rest (dimensions, story, pins, module, steps, formula).
24
+
25
+ ```json
26
+ {"solution": "compare", "metrics": ["Sessions", "Orders", "Revenue"], "context": "Period",
27
+ "start": ["Q1"], "end": ["Q2"], "totalStepName": "Revenue", "totalStepUnit": "€",
28
+ "title": "Pourquoi le CA a baissé au T2", "language": "fr-FR"}
29
+ ```
30
+
31
+ Column names are exact tokens from the data: never translate, pluralize, rename or re-case them.
32
+
33
+ **`language`, always:** `fr-FR` when the user writes in French, `de-DE` in German, `es-ES` in Spanish, otherwise `en-US`. It sets the language of the generated titles, comments and labels, not of the data. **`title`:** the user's question, in their language.
34
+
35
+ **`metrics`, ordered.** Studio turns them into steps `metrics[0]`, then `<metrics[i]> per <metrics[i-1]>`, multiplied together, so a change is explained by each link of the chain.
36
+ - Which: the ones the user names; otherwise every raw numeric column, without precomputed ratios or averages (`rate`, `avg`, `%`, `ROAS`, `CTR`, `AOV`, …) unless asked for. One metric is fine: the change is then explained by segments only.
37
+ - Order: the business flow. Web: sessions → product views → add to cart → checkout → orders → revenue. Acquisition: cost → impressions → clicks → sessions → conversions → revenue. Subscription: expirations → renewals → revenue. Otherwise: column order.
38
+ - Custom equation, only when the meaning requires it: `steps` (each `{"numerator", "denominator"}`, named `"<numerator> per <denominator>"`) and `formula` over step indices `[1]`…`[N]`. Cost per unit: `[1]+[2]+[3]` over `Cost_x / Units` steps. NPS: `([1]-[2])*100` over `Promoters / Answers`, `Detractors / Answers`. Details: [market-equation.md](references/market-equation.md).
39
+ - `totalStepName`: the KPI computed, in business words (`Revenue`, `ROAS`, `NPS`), never a step name like `Revenue per Orders`. `totalStepUnit`: `"€"` for money, `"%"` for a percentage, otherwise `""`.
40
+ - `dimensions` defaults to every other column; set it only to leave columns out.
41
+
42
+ **Comparison** (Compare; optional in the other solutions). `context` is the dimension holding the two sides. `start` is the reference side (before, A), `end` the side explained (after, B): values as written in the data (`["2024"]`, several merged on one side: `["Desktop", "Tablet"]`), or `[first, last]` each on a date column. Without `context`: the older half of the first date column against the newer half. Rolling periods: `"relative": true`, indices from the most recent date, `"start": [13, 7], "end": [6, 0]`. Two metric columns (budget vs actual) or a second comparison: `comparisons` in the form of [studio-stories.md](references/studio-stories.md#comparisons).
43
+
44
+ **Filters**, only when asked: `"filters": [{"column": "Country", "operator": "in", "value": ["France"]}]` (`in`, `not`, `like`, `gte`, `lte`, `between`, `after`, `before`).
45
+
46
+ **Module inputs.** Every other key configures the analysis. Write only what the request asks:
47
+ - Compare: `view` (`waterfall-default` · `tree-default`), `analysisMethod` (`auto` · `steps` · `dimensions`), `waterfallMeasure`, `stylePreset`, `chartTitle` — [compare.md](references/solutions/compare.md).
48
+ - Explore: `primary` (axis dimension), `secondary` (series dimension, or `"Comparison Dimension"` for Start vs End), `metric1` / `metric2` / `metric3` (a metric, a step name, or with a comparison `"<measure> Δ"` / `"<measure> % Change"`), `chart.category` (`bar` · `line` · `area` · `combo` · `mekko` · `scatter`), `chart.layout` (`clustered` · `stacked` · `percent` · `overlay`) — [explore.md](references/solutions/explore.md).
49
+ - Detect: `detectionMethod`, `lastPointsOnlyEnabled` with `lastPointsCount`, `confidence` — [detect.md](references/solutions/detect.md).
50
+ - Pivot: `view`, `hierarchyExplorationMethod` (`hierarchy` · `top`), `hierarchyTopLeaves` — [pivot.md](references/solutions/pivot.md).
51
+ - `plotter`: a partial chart configuration for a precise chart need ([plotter/embedded.md](references/plotter/embedded.md)). On Explore, any `plotter` drops the default look.
52
+
53
+ `python3 scripts/datama.py settings compare|explore|detect|pivot [word]` lists every input with its default. An input listed neither there nor in the solution file does not exist: say "configurable in the Datama app, not exposed to this skill", never "Datama cannot do it".
54
+
55
+ **Several analyses.** `"modules": [{"solution": "compare"}, {"solution": "explore", "primary": "Country", "secondary": "Comparison Dimension"}]` stacks analyses in one story, sharing its comparison, filters and equation (`"displayMode": "slide"`: one per slide). `"stories": [{…}, {…}]` adds one tab per question; each story takes the top-level keys and overrides them.
56
+
57
+ **Look** (palette, brand colors, background) goes in `--theme '{"colors": {"palette": "modern"}}'`, not in the configuration: [theming.md](references/theming.md); `datama.py settings theme` lists palettes, style presets and colors.
58
+
59
+ ## Plotter
60
+
61
+ For one exact chart, aggregate and sort the rows yourself (dimension values as strings, measures as numbers), then:
62
+
63
+ ```bash
64
+ python3 scripts/datama.py plot --data chart.json --title "Sessions by country" --out chart.html \
65
+ --layer '{traces: [{type: "bars", x: {value: "Country", stack: "Channel", position: "bottom"}, y: {value: "Session", position: "left", start: 0}, stacked: true}]}'
66
+ ```
67
+
68
+ Layer, traces, `--config` and `--palette`: [plotter/standalone.md](references/plotter/standalone.md). Arrows and reference lines: [plotter/annotations.md](references/plotter/annotations.md).
69
+
70
+ ## Editing a page
71
+
72
+ Rebuild from the page, passing only the keys that change: `--from page.html --config '{"view": "tree-default"}'`, `--config '{"solution": "explore", "primary": "Country"}'`, or `--from page.html --theme '{"colors": {"palette": "ocean"}}'`. On a page with several stories, a top-level key changes every story; `"stories": [{}, {"view": "tree-default"}]` changes the second only. A Plotter page is rebuilt with `plot`.
73
+
74
+ ## Rules
75
+
76
+ - Never rebuild the chart yourself, add scripts to the page, edit a template, or send the rows anywhere.
77
+ - If the metrics, the comparison axis or the data do not fit the request (no date column for Detect, a single segment for Compare), ask before building.
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
- # Temporary Holding Version
1
+ # @datama/studio-skill-instructions
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Workflow of the `datama-studio` agent skill. The installed skill prints it with `python3 scripts/datama.py instructions`, and one reference with `python3 scripts/datama.py instructions references/<file>.md`.
4
+
5
+ Published from the `studio-skill` repository on each release tag. `references/generated/` is derived from the Studio sources at build time.
package/package.json CHANGED
@@ -1,6 +1,20 @@
1
1
  {
2
- "name": "@datama/studio-skill-instructions",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@datama/studio-skill-instructions",
3
+ "version": "1.0.0",
4
+ "description": "Workflow and references of the datama-studio agent skill, read at run time by its scripts/datama.py.",
5
+ "files": [
6
+ "INSTRUCTIONS.md",
7
+ "README.md",
8
+ "references"
9
+ ],
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "keywords": [
14
+ "datama",
15
+ "studio",
16
+ "agent-skill"
17
+ ],
18
+ "author": "Datama",
19
+ "license": "UNLICENSED"
20
+ }
@@ -0,0 +1,109 @@
1
+ # Market equation: metrics, steps, formula, main KPI
2
+
3
+ The market equation explains a main KPI as a chain of steps (volumes and ratios). Compare decomposes a change along it, Explore and Detect use its steps as plottable measures. It is shared by every solution.
4
+
5
+ ## Where it lives
6
+
7
+ | Part | Location |
8
+ | --- | --- |
9
+ | Metric columns and their order | `source.metrics` ([studio-instantiation.md](studio-instantiation.md)) |
10
+ | Dimension columns | `source.dimensions` |
11
+ | Steps | `pins.marketEquation.steps` ([studio-stories.md](studio-stories.md#pins)) |
12
+ | `formula`, `totalStepName`, `totalStepUnit`, `totalStepEmoji` | `pins.marketEquation.inputs` |
13
+
14
+ ## Automatic or explicit
15
+
16
+ - **Automatic** (no `marketEquation` pin): Studio builds a sequential funnel from `source.metrics`, in that order: step 1 = first metric, step i = metric i per metric i-1, formula = product of every step, main KPI = last metric. To control it, order (and restrict) `source.metrics`. This covers most requests.
17
+ - **Explicit** (`marketEquation` pin): write it when the user names the KPI, when the formula is not a plain product (sum of costs, NPS, branching funnel), when a step must use a denominator that is not the previous metric, or when units matter.
18
+
19
+ ## Column mapping (strict)
20
+
21
+ - Use the exact column names of the dataset: never pluralize, translate, rename or re-case them (`Session` stays `Session`).
22
+ - `source.dimensions` and `source.metrics` are arrays of plain strings.
23
+
24
+ ## Metric scope
25
+
26
+ - Metrics are numeric columns only.
27
+ - The user names metrics → include only those.
28
+ - Otherwise include every raw numeric metric.
29
+ - Exclude precomputed rates, ratios and averages unless explicitly requested (names suggesting `rate`, `ratio`, `avg`, `mean`, `%`, `ROAS`, `CPA`, `CPC`, `CTR`, `CVR`, `AOV`, `ROI`, `NPS`): the equation recomputes ratios from raw counts.
30
+
31
+ ## Metric order
32
+
33
+ Order with business logic first:
34
+
35
+ - Web funnel: `sessions → views → product views → add to cart → checkout → transactions / orders → revenue`
36
+ - Acquisition funnel: `cost → impressions → clicks → sessions → leads → conversions → transactions → revenue`
37
+ - Subscription: `expirations → renewals → transactions → revenue`
38
+
39
+ Without a clear flow: numeric sequence in the names, then column order, then alphabetical as a last resort. Never invent a metric.
40
+
41
+ ## Steps
42
+
43
+ One step per included metric, in metric order:
44
+
45
+ ```json
46
+ {"name": "Checkout per Session", "numerator": "Checkout", "denominator": "Session", "exclude": [], "unit": "%"}
47
+ ```
48
+
49
+ | Key | Rule |
50
+ | --- | --- |
51
+ | `numerator` | Metric column |
52
+ | `denominator` | Metric column, or `""` for a volume step |
53
+ | `name` | `numerator` alone for a volume step; `"<numerator> per <denominator>"` for a ratio step (Studio's own naming) |
54
+ | `exclude` | Always `[]` |
55
+ | `unit` | Optional: `"€"` (or the currency the user implies) for money, `"%"` only for a true rate, otherwise omit or `""` |
56
+
57
+ - First step: `numerator = metrics[0]`, `denominator = ""`, `name = metrics[0]`.
58
+ - Step i: `numerator = metrics[i]`, `denominator = metrics[i-1]`.
59
+ - A denominator may be a column that is not itself a step (NPS answers, units). Keep it in `source.metrics` only if the user wants it as a metric.
60
+ - Never put a unit inside `name`.
61
+
62
+ ## Formula
63
+
64
+ `inputs.formula` uses 1-based step indices, never column names:
65
+
66
+ - Single step: `"[1]"`
67
+ - Sequential funnel: `"[1]*[2]*[3]*…*[N]"`
68
+ - Additive: `"[1]+[2]+[3]+[4]"`
69
+ - NPS-style: `"([1]-[2])*100"`
70
+ - Branching: `"[1]*[2]*([3]*[4]+(1-[3])*[5])*[6]"`
71
+
72
+ Reference only existing indices. When unsure, use the sequential product of every step.
73
+
74
+ ## Main KPI
75
+
76
+ - `totalStepName`: name of what the formula computes. Priority: the KPI the user names → the business KPI implied by the formula (`ROAS` for cost → revenue, `NPS`, `Total cost per unit`) → the last metric. Never a step name such as `"Revenue per Checkout"`.
77
+ - `totalStepUnit`: `"€"` (or the implied currency) for money, `"%"` only for a percentage KPI, otherwise `""`.
78
+ - `totalStepEmoji`: optional single emoji shown next to the KPI.
79
+ - Recompute both whenever steps or formula change.
80
+
81
+ ## Examples
82
+
83
+ | Scenario | Metrics (order) | Steps | Formula | Main KPI |
84
+ | --- | --- | --- | --- | --- |
85
+ | Acquisition | Cost, Impressions, Clicks, Sessions, Conversions, Revenue | Cost · Impressions per Cost · Clicks per Impressions · Sessions per Clicks · Conversions per Sessions · Revenue per Conversions | `[1]*[2]*[3]*[4]*[5]*[6]` | `ROAS`, `""` |
86
+ | E-commerce | Session, ProductViews, AddToCart, Checkout, Transactions, Revenue | Session · ProductViews per Session · … · Revenue per Transactions | `[1]*[2]*[3]*[4]*[5]*[6]` | `Revenue`, `€` |
87
+ | NPS | Nb_promoters, Nb_detractors (denominator Nb_answers) | Nb_promoters per Nb_answers · Nb_detractors per Nb_answers | `([1]-[2])*100` | `NPS`, `""` |
88
+ | Cost per unit | First_cost, Packaging_cost, Transport_cost (denominator Units) | First_cost per Units · Packaging_cost per Units · Transport_cost per Units | `[1]+[2]+[3]` | `Total cost per unit`, `""` |
89
+ | Subscription | Expirations, Renewals, Revenue | Expirations · Renewals per Expirations · Revenue per Renewals | `[1]*[2]*[3]` | `Revenue`, `€` |
90
+
91
+ Complete pin for the e-commerce case reduced to three metrics:
92
+
93
+ ```json
94
+ {"marketEquation": {
95
+ "inputs": {"formula": "[1]*[2]*[3]", "totalStepName": "Revenue", "totalStepUnit": "€"},
96
+ "steps": [
97
+ {"name": "Session", "numerator": "Session", "denominator": "", "exclude": []},
98
+ {"name": "Checkout per Session", "numerator": "Checkout", "denominator": "Session", "exclude": [], "unit": "%"},
99
+ {"name": "Revenue per Checkout", "numerator": "Revenue", "denominator": "Checkout", "exclude": [], "unit": "€"}
100
+ ]
101
+ }}
102
+ ```
103
+
104
+ ## Preflight
105
+
106
+ - Every column in `source.metrics`, `steps` and inputs exists in the dataset.
107
+ - Each step `name` follows from its numerator and denominator.
108
+ - `formula` is non-empty and references existing step indices only.
109
+ - `totalStepName` is a non-empty main KPI name; `totalStepUnit` is present (may be `""`).
@@ -0,0 +1,54 @@
1
+ # Plotter annotations: difference arrows, CAGR, value lines
2
+
3
+ Chart decorations stored in the Plotter configuration under `annotations`. They hold **semantic anchors** (row ids, trace keys, series), never pixels: values and positions are recomputed on every render, and an annotation whose anchor is not visible is hidden, not deleted.
4
+
5
+ Add an annotation only when the user asks for it ("show the gap between Q1 and Q4", "add the average line"). One annotation answers a question; five are noise.
6
+
7
+ ## Where to write them
8
+
9
+ | Page | Location |
10
+ | --- | --- |
11
+ | Compare module | Prefer the module input `waterfallDifferenceArrows` ([solutions/compare.md](../solutions/compare.md#custom-pillars-and-difference-arrows)): it takes bar labels, not row ids |
12
+ | Explore module | `configuration.plotter.annotations.valueLines` on the module slot ([plotter/embedded.md](embedded.md)) |
13
+ | Plotter template | `CONFIGURATION.annotations` |
14
+
15
+ ## Value lines
16
+
17
+ Dotted reference line at an element value, or at an average, with its label past the end of the plot.
18
+
19
+ ```json
20
+ {"annotations": {"valueLines": [
21
+ {"id": "average-sessions", "trace": "Session", "kind": "average"},
22
+ {"id": "average-tablet", "trace": "Session", "kind": "average", "series": "Tablet"}
23
+ ]}}
24
+ ```
25
+
26
+ | Key | Value | Meaning |
27
+ | --- | --- | --- |
28
+ | `id` | string | Unique id |
29
+ | `trace` | string | Trace key: in Explore, the measure name; in a Plotter page, the trace `name` (or `type:x.value:y.value` without a name) |
30
+ | `kind` | `"average"` · `"value"` | Mean of the plotted elements (stack totals when stacked), or the value of one element |
31
+ | `series` | string | `average` of one series only (one value of the D2 / `x.stack`) |
32
+ | `key` | string | `value` lines: stable id of the anchor element |
33
+
34
+ ## Difference arrows
35
+
36
+ Think-cell style arrows between two elements of the same trace.
37
+
38
+ ```json
39
+ {"annotations": {"differences": [
40
+ {"id": "q1-vs-q4", "trace": "Revenue", "from": {"key": "<row id>"}, "to": {"key": "<row id>"}, "kind": "total", "mode": "both", "direction": "to"}
41
+ ]}}
42
+ ```
43
+
44
+ | Key | Value | Meaning |
45
+ | --- | --- | --- |
46
+ | `trace` | string | Trace key, as for value lines |
47
+ | `from.key` / `to.key` | string | Stable ids of the two elements. In a Plotter page, give each row an `id` field in `DATA` and use it here |
48
+ | `kind` | `level` · `total` · `cagr` | Adjacent elements, a bracket spanning the elements between, or the compound growth rate per period (years between date values, else one period per slot) |
49
+ | `mode` | `percent` · `absolute` · `both` | Label content (ignored by `cagr`) |
50
+ | `direction` | `to` · `from` · `both` | Arrow head placement; `both` = unsigned gap |
51
+ | `position` | 0 … 1 | Placement of a `level` arrow between the two elements |
52
+ | `lift` | 0 … 1 | Elevation of a `total` arrow above its automatic lane |
53
+
54
+ Supported on `bars`, `waterfall`, `lines`, `scatter` and `areas` traces.
@@ -0,0 +1,37 @@
1
+ # Tuning the chart of a Studio module (`configuration.plotter`)
2
+
3
+ Every Studio module draws with Plotter. Its chart state is saved on the module slot under `configuration.plotter`: a **partial** Plotter configuration deep-merged over the defaults. Use it for precise chart requests the solution inputs do not cover (axis, legend, labels, padding, annotations).
4
+
5
+ ```json
6
+ {"module": "compare.waterfall", "inputs": {}, "configuration": {"plotter": {"reverse": true, "legends": {"display": true}}}}
7
+ ```
8
+
9
+ ## Rules
10
+
11
+ - Write only the keys that change. Every valid key, its type and its default: [generated/plotter-configuration.md](../generated/plotter-configuration.md). A key not listed there does not exist.
12
+ - Prefer solution inputs first: Compare `stylePreset`, `chartTitle`, `waterfallValueLabels`, `view`; Explore chart spec. They are tested together with the solution layout.
13
+ - Explore: any non-empty `configuration.plotter` is read as a saved chart and skips Explore's default look (preset, value labels on bars). Add one only when needed.
14
+ - Never store pixel positions or computed values: annotations use semantic anchors ([annotations.md](annotations.md)).
15
+ - Keys owned by the solution layout (`layout`, `views`, `traces`, `customViews`) are rebuilt by the module; leave them out.
16
+
17
+ ## Frequent requests
18
+
19
+ | Request | Partial configuration |
20
+ | --- | --- |
21
+ | Horizontal bars / swap axes | `{"reverse": true}` |
22
+ | Show the legend at the bottom | `{"legends": {"display": true, "position": "bottom"}}` |
23
+ | Hide the measure axis | `{"axis": {"y": {"hidden": true}}}` |
24
+ | Compact numbers on axis ticks (K / M) | `{"axis": {"ticks": {"texts": {"format": {"compact": true}}}}}` |
25
+ | Two decimals on axis ticks | `{"axis": {"ticks": {"texts": {"format": {"decimals": 2}}}}}` |
26
+ | Bigger chart margins | `{"plot": {"padding": {"top": 30, "right": 20, "bottom": 30, "left": 20}}}` |
27
+ | No bar gradient | `{"bars": {"gradient": {"display": false}}}` |
28
+ | Bar value labels | `{"bars": {"labels": {"display": true}}}` |
29
+ | Hide the waterfall connectors | `{"waterfall": {"links": {"display": false}}}` |
30
+ | Bigger header title | `{"header": {"title": {"size": 22}}}` |
31
+ | No animations | `{"behaviors": {"transitionDuration": 0}}` |
32
+
33
+ Check every path against [generated/plotter-configuration.md](../generated/plotter-configuration.md) before writing it: branch names and defaults there are the reference for this bundle.
34
+
35
+ ## Table view
36
+
37
+ Every Plotter chart also offers a table view (`table.enabled`, default on). Its columns, pagination and styling live under `configuration.plotter.table`; leave them to the solution unless the user asks for a table change.
@@ -0,0 +1,142 @@
1
+ # Plotter alone (Plotter template)
2
+
3
+ The Plotter template draws one chart (or several switchable views) from rows you prepare. Plotter computes nothing: aggregate, sort and derive every value before inlining it.
4
+
5
+ ## Template variables
6
+
7
+ | Variable | Format | Content |
8
+ | --- | --- | --- |
9
+ | `DATA` | JSON array | One flat object per plotted element (already aggregated) |
10
+ | `LAYER` | JavaScript object literal | Views and traces (below). Functions are allowed for `color`, `if`, `label` |
11
+ | `CONFIGURATION` | JSON object or `null` | Partial Plotter configuration, merged over the defaults ([generated/plotter-configuration.md](../generated/plotter-configuration.md)) |
12
+ | `PALETTE` | JSON array or `null` | Hex colors `[net, up, down, start, end, series…]` (named palettes: [generated/theme.md](../generated/theme.md)) |
13
+ | `TITLE` / `SUBTITLE` | JSON string or `null` | Header title and subtitle |
14
+
15
+ The template runs, in order: `new Plotter({id, parent, data: DATA, palette: PALETTE})`, `init({...LAYER, configuration: Plotter.loadConfiguration(CONFIGURATION)})`, `render()`.
16
+
17
+ ## Data
18
+
19
+ - Dimension values are strings (`"France"`, `"2025-01"`); sort the rows in the order the axis must show them (chronological for time).
20
+ - Measures are numbers; `null` for a missing value.
21
+ - One row per (D1 × D2) element: for a stacked chart of Sessions by Country × Channel, one row per country and channel.
22
+
23
+ ```json
24
+ [
25
+ {"Country": "France", "Channel": "SEA", "Session": 5556},
26
+ {"Country": "France", "Channel": "SEO", "Session": 5300},
27
+ {"Country": "Germany", "Channel": "SEA", "Session": 4120}
28
+ ]
29
+ ```
30
+
31
+ ## Layer
32
+
33
+ Single view:
34
+
35
+ ```js
36
+ {
37
+ traces: [
38
+ {type: "bars", x: {value: "Country", stack: "Channel", position: "bottom"}, y: {value: "Session", position: "left", start: 0}, stacked: true}
39
+ ]
40
+ }
41
+ ```
42
+
43
+ Several views switchable from the chart toolbar (`trace` = view shown first):
44
+
45
+ ```js
46
+ {
47
+ traces: {
48
+ "bars-default": {label: "Bars", group: "Charts", traces: [/* traces */]},
49
+ "lines-default": {label: "Lines", group: "Charts", traces: [/* traces */]}
50
+ },
51
+ trace: "bars-default"
52
+ }
53
+ ```
54
+
55
+ A table view of `DATA` is always available too (`configuration.table.enabled`, default `true`).
56
+
57
+ ## Trace
58
+
59
+ Every trace needs `type`, `x` and `y`. Trace types available in this bundle are listed at the top of [generated/plotter-configuration.md](../generated/plotter-configuration.md#trace-types).
60
+
61
+ | Key | Value | Meaning |
62
+ | --- | --- | --- |
63
+ | `type` | `bars` · `lines` · `areas` · `scatter` · `mekko` · `mekko100` · `bubble` · `events` · `waterfall` · `tree` | Mark type |
64
+ | `x` / `y` | `{value, position, stack?, start?, unit?, hidden?, type?}` | Axis binding: `value` = column, `position` = `bottom` · `top` · `left` · `right` |
65
+ | `x.stack` | column | Series column on the dimension axis (one bar / line per value) |
66
+ | `y.start` | number | Force the measure axis to start at this value (usually `0`) |
67
+ | `y.unit` | string | Unit appended to values (`"€"`, `"%"`) |
68
+ | `y.upper` / `y.lower` | column | Range bars and bands |
69
+ | `name` | string | Series name in legends and hovers |
70
+ | `color` | hex string · `{seriesValue: hex}` · `function (row) {...}` | Fixed color, map per series value, or a function returning a hex or a series key |
71
+ | `colors` | `{key: hex}` | Palette used when `color` returns a key |
72
+ | `stacked` | boolean | Stack the `x.stack` series |
73
+ | `overlay` | boolean | Overlap series instead of placing them side by side |
74
+ | `relative` | boolean | Normalize to percentages (100 % charts) |
75
+ | `opacity` | number 0–1 | Mark opacity |
76
+ | `legend` | boolean | `false` hides this trace in the legend |
77
+ | `if` | `function (row) {...}` | Keep only matching rows for this trace |
78
+ | `width` | number | Line width (`lines`) |
79
+ | `dots` | `{hidden, opacity, sizingRatio}` | Line points (`lines`, `areas`) |
80
+ | `curve` | `default` · `linear` · `step` · `step-before` · `step-after` · `natural` · `cardinal` | Line interpolation |
81
+ | `as` | `dot` · `circle` · `square` · `line-h` · `line-v` · `icons` | Scatter mark shape |
82
+
83
+ Without `color`, each series value of `x.stack` (or each `x.value`) gets the next palette color.
84
+
85
+ Type-specific notes:
86
+
87
+ - `mekko`: three bindings, `x` = dimension (`stack` = series), `y` = width measure on a horizontal position (`bottom`), `y2` = height measure on a vertical position (`left`).
88
+ - `waterfall` and `tree` expect hierarchical rows built by Datama: use Studio Compare or Pivot instead.
89
+ - `events` draws calendar events on a time axis (`calendar: {on, type, events}`); rarely needed outside Studio.
90
+
91
+ ## Recipes
92
+
93
+ Stacked bars:
94
+
95
+ ```js
96
+ {traces: [{type: "bars", x: {value: "Country", stack: "Channel", position: "bottom"}, y: {value: "Session", position: "left", start: 0}, stacked: true}]}
97
+ ```
98
+
99
+ Trend with one line per device:
100
+
101
+ ```js
102
+ {traces: [{type: "lines", x: {value: "Date", stack: "Device", position: "bottom"}, y: {value: "Session", position: "left", start: 0}, width: 2, curve: "linear"}]}
103
+ ```
104
+
105
+ Combo, volume bars and rate line on a second axis:
106
+
107
+ ```js
108
+ {traces: [
109
+ {type: "bars", name: "Session", x: {value: "Month", position: "bottom"}, y: {value: "Session", position: "left", start: 0}, color: "#1B2A4A"},
110
+ {type: "lines", name: "Conversion", x: {value: "Month", position: "bottom"}, y: {value: "Conversion", position: "right", start: 0, unit: "%"}, color: "#F2A93B", width: 2}
111
+ ]}
112
+ ```
113
+
114
+ Horizontal ranking: same bars trace with `CONFIGURATION = {"reverse": true}`.
115
+
116
+ Highlight one category:
117
+
118
+ ```js
119
+ {traces: [{type: "bars", x: {value: "Country", position: "bottom"}, y: {value: "Revenue", position: "left", start: 0}, color: function (row) { return row.Country === "France" ? "#D64545" : "#B0B7C3"; }}]}
120
+ ```
121
+
122
+ ## Configuration
123
+
124
+ `CONFIGURATION` is a partial tree: write only what changes. Common keys (full list with defaults in [generated/plotter-configuration.md](../generated/plotter-configuration.md)):
125
+
126
+ | Need | Partial configuration |
127
+ | --- | --- |
128
+ | Swap axes (horizontal bars) | `{"reverse": true}` |
129
+ | Legend at the bottom / hidden | `{"legends": {"position": "bottom"}}` · `{"legends": {"display": false}}` |
130
+ | Value labels on bars | `{"bars": {"labels": {"display": true}}}` |
131
+ | Flat bars | `{"bars": {"gradient": {"display": false}}}` |
132
+ | Compact tick numbers | `{"axis": {"ticks": {"texts": {"format": {"compact": true}}}}}` |
133
+ | No animation | `{"behaviors": {"transitionDuration": 0}}` |
134
+ | Wider margins | `{"plot": {"padding": {"top": 30, "right": 20, "bottom": 30, "left": 20}}}` |
135
+
136
+ Arrows and reference lines: [annotations.md](annotations.md).
137
+
138
+ ## Checks
139
+
140
+ - Every `x.value`, `x.stack`, `y.value` names a key present in `DATA`.
141
+ - `LAYER` is a valid JavaScript object literal (functions allowed, no trailing code).
142
+ - `CONFIGURATION` paths exist in [generated/plotter-configuration.md](../generated/plotter-configuration.md).
@@ -0,0 +1,124 @@
1
+ # Compare (`compare.waterfall`)
2
+
3
+ Explains **why** a main KPI changed between two sides (two periods, two segments): a waterfall from Start to End where each bar is a driver (market-equation step, segment mix, segment performance), plus a generated title and comment.
4
+
5
+ ## When
6
+
7
+ - "Why did revenue drop?", "compare Q1 vs Q2", "decompose the conversion change", "Mobile vs Desktop".
8
+ - Needs a comparison (two sides) and at least one metric. Without an explicit comparison, Studio compares the older half of the first date column with its newer half.
9
+
10
+ ## Recipe
11
+
12
+ 1. `source`: rows + `dimensions` (every dimension worth drilling into, the comparison dimension included) + `metrics` in funnel order ([studio-instantiation.md](../studio-instantiation.md)).
13
+ 2. `pins.comparison`: the two sides ([studio-stories.md](../studio-stories.md#comparisons)).
14
+ 3. `pins.marketEquation`: only when the user names the KPI or the formula is not a plain funnel ([market-equation.md](../market-equation.md)).
15
+ 4. Module `{"module": "compare.waterfall", "inputs": {…}}` with only the inputs below that the request needs.
16
+ 5. Story `title`: the question, in the user's language.
17
+
18
+ ```json
19
+ {
20
+ "stories": {"story-mobile-vs-desktop": {
21
+ "title": "Mobile vs Desktop: what explains the revenue gap?",
22
+ "pins": {"comparison": {"inputs": {"comparisons": [{"mode": "dimension",
23
+ "start": {"column": "Device", "operator": "in", "value": ["Desktop"]},
24
+ "end": {"column": "Device", "operator": "in", "value": ["Mobile"]}}], "relative": false, "order": "desc"}}},
25
+ "modules": [{"module": "compare.waterfall", "inputs": {"analysisMethod": "auto"}}]
26
+ }},
27
+ "activeStory": "story-mobile-vs-desktop"
28
+ }
29
+ ```
30
+
31
+ ## Module inputs
32
+
33
+ All optional. Defaults: [generated/solutions.md](../generated/solutions.md#compare). Change only what the request asks.
34
+
35
+ ### View and measure
36
+
37
+ | Key | Values | Meaning |
38
+ | --- | --- | --- |
39
+ | `view` | `"waterfall-default"` · `"tree-default"` | Waterfall of drivers, or tree of cards decomposing the KPI dimension by dimension |
40
+ | `waterfallMeasure` | `"Impact"` · `"Pts_gap"` | Bar value: contribution to the main KPI (in `totalStepUnit`), or gap in points (rate steps) |
41
+ | `waterfallValueLabels` | boolean, default `true` | Value printed on each bar; `false` on a dense waterfall |
42
+ | `chartTitle` / `chartSubtitle` | string, default `""` | Title / subtitle bands above the chart, shown verbatim (write them in the user's language). Empty = hidden, the generated insight speaks |
43
+ | `stylePreset` | style preset key ([generated/theme.md](../generated/theme.md)) | One-key look: shapes, typography, spacing, comment placement. Applies the preset palette too |
44
+
45
+ ### Analysis
46
+
47
+ | Key | Values | Meaning |
48
+ | --- | --- | --- |
49
+ | `analysisMethod` | `"auto"` · `"steps"` · `"dimensions"` | `auto` picks the most interesting; `steps` starts from the market-equation steps then opens on dimensions; `dimensions` starts from segments then steps |
50
+ | `Split_Mix_and_Perf` | `"Auto"` · `"Always"` · `"Never"` | Split each segment bar into a mix effect (share shift) and a performance effect (rate change) |
51
+ | `separateCovariance` | `"Never"` · `"Auto"` · `"Always"` | Isolate the interaction between steps in a final "Covariance" bar (`Auto`: only above `separateCovarianceThreshold`) |
52
+ | `separateCovarianceThreshold` | number 0–100 | `Auto` threshold, in % of everything the steps moved |
53
+ | `covarianceWarningThreshold` | number 0–100 | Above it, the page warns that the two sides may not be comparable |
54
+ | `mixPerfCovariance` | `"pro-rata"` · `"performance"` · `"mix"` | Who carries the mix × performance cross term inside a segment |
55
+ | `waterfallOpenBarByDefault` | boolean, default `true` | Drill into the main bars on load |
56
+ | `waterfallExpandDepth` | `1` · `2` · `3` | How deep a drilled bar opens |
57
+ | `waterfallExplorationDepth` | `1` · `2` · `3` | Dimension levels explored automatically |
58
+ | `waterfallCommentThreshold` | number (points), default `1` | Minimum impact for a segment to be cited in the comment: higher = shorter comment |
59
+ | `segment_complement` | `"Variation relative to avg"` · `"Variation %"` · `"Nothing"` | Text after each segment name in labels and hovers |
60
+ | `waterfallGroupEquationSteps` | boolean | Also fold small market-equation step bars into "Remaining" |
61
+ | `waterfallMergeOnCommonBars` | boolean | With two comparisons: merge the bars both tables share |
62
+
63
+ ### Segments, hierarchy, scope
64
+
65
+ | Key | Values | Meaning |
66
+ | --- | --- | --- |
67
+ | `clusteringThreshold` | number 0–100 (%), default `2` | Segments weighing less than this share of `metricForClustering` are grouped into "Other" |
68
+ | `clusteringMethod` | `"threshold"` · `"tail"` | Group by share threshold, or keep the top segments and group the tail |
69
+ | `clusteringBins` | integer 2–20, default `5` | Number of bins for numeric dimensions |
70
+ | `metricForClustering` | metric column | Metric used to weigh segments (default: first metric) |
71
+ | `dimensionsHierarchy` | `[{"name": "Country", "level": 0, "pinned": false}, {"name": "City", "level": 1, "pinned": false}]` | Drill-down order of dimensions (parent before child) |
72
+ | `hierarchicalMix` | boolean | Measure each level's mix against its parent segment (cascade along `dimensionsHierarchy`) |
73
+ | `clusteringAtParentLevel` | boolean, default `true` | With `hierarchicalMix`: rebuild "Other" inside every parent |
74
+ | `outOfScopeDimensions` | dimension names | Segments present on one side only are grouped in an "Out of scope" block |
75
+ | `outOfScopeLabel` | string | Label of that block (default: translated "Out of scope") |
76
+ | `outOfScopeAddComparablePillar` | boolean, default `true` | Add a "Comparable" pillar after the out-of-scope block |
77
+
78
+ ### Tree view (`view: "tree-default"`)
79
+
80
+ | Key | Values | Meaning |
81
+ | --- | --- | --- |
82
+ | `hierarchyExplorationMethod` | `"hierarchy"` · `"top"` | Expand along the dimension order, or pick the most contributing leaves |
83
+ | `hierarchyTopLeaves` | integer ≥ 1, default `4` | Leaves per node with `top` |
84
+ | `treeCardMainKpiRatio` / `treeCardSubKpiRatio` / `treeCardTitleRatio` | `0.75` · `1` · `1.25` | Font size of the card headline / sub lines / title |
85
+
86
+ ### Two comparisons
87
+
88
+ With a second entry in `pins.comparison.inputs.comparisons`:
89
+
90
+ | Key | Values | Meaning |
91
+ | --- | --- | --- |
92
+ | `splitOrientation` | `"horizontal"` · `"vertical"` | Waterfalls side by side, or stacked |
93
+ | `splitDisplayMode` | `"grouped"` · `"overlay"` | Bars grouped per comparison, or overlaid |
94
+
95
+ ### Custom pillars and difference arrows
96
+
97
+ `waterfallCustomPillars` adds subtotal bars: `[{"id": "pillar-eu", "anchorKey": "<bar label>", "position": "before", "label": "Subtotal EU"}]` (`position`: `before` · `after`).
98
+
99
+ `waterfallDifferenceArrows` annotates the gap between two bars, think-cell style:
100
+
101
+ ```json
102
+ [{"id": "start-vs-end", "fromAnchorKey": "Start", "toAnchorKey": "End", "kind": "total", "mode": "both"}]
103
+ ```
104
+
105
+ | Key | Values |
106
+ | --- | --- |
107
+ | `fromAnchorKey` / `toAnchorKey` | Exact bar labels (segment name, step name, `Start`, `End`) |
108
+ | `kind` | `level` (adjacent bars) · `total` (spans the bars between) · `cagr` (compound rate per period) |
109
+ | `mode` | `percent` · `absolute` · `both` (ignored by `cagr`) |
110
+ | `direction` | `to` · `from` · `both` |
111
+ | `position` | −0.5 … 1.5, default `0.5` (`level` arrows) |
112
+ | `lift` | 0 … 1, default `0` (`total` arrows) |
113
+
114
+ Add pillars and arrows only when the user asks for them.
115
+
116
+ ## Chart tuning
117
+
118
+ `configuration.plotter` on the module tunes the chart beyond these inputs, for instance `{"plotter": {"reverse": true}}` for horizontal bars ([plotter/embedded.md](../plotter/embedded.md)). Prefer `stylePreset` and the theme for look requests.
119
+
120
+ ## Checks
121
+
122
+ - Both comparison sides use the same column and values that exist in it.
123
+ - The two sides are not identical and each contains rows after filters.
124
+ - Every name in `dimensionsHierarchy`, `outOfScopeDimensions`, `metricForClustering` exists in the source.
@@ -0,0 +1,50 @@
1
+ # Detect (`detect.anomaly`)
2
+
3
+ Finds outliers in a time series: the measure over time with its expected range, the flagged points, and a table ranking the segments and steps that drive each anomaly.
4
+
5
+ ## When
6
+
7
+ - "Find anomalies in daily orders", "which days were unusual", "monitor the last points", "did anything abnormal happen last week".
8
+ - Needs a **date** dimension (the solution is unavailable otherwise) and at least one metric. More periods give a better baseline (dozens of points at least).
9
+
10
+ ## Recipe
11
+
12
+ 1. `source`: rows with a date column at a regular grain (one row per day × segment, for instance), `dimensions` (the date first), `metrics`.
13
+ 2. Optional `pins.marketEquation` to choose the main KPI and its steps ([market-equation.md](../market-equation.md)).
14
+ 3. Module `{"module": "detect.anomaly", "inputs": {…}}`; `"detect.anomaly"` alone uses every default (observed volatility on the whole series).
15
+
16
+ ```json
17
+ {
18
+ "stories": {"story-orders-anomalies": {
19
+ "title": "Unusual days in orders",
20
+ "modules": [{"module": "detect.anomaly", "inputs": {"detectionMethod": "observed-volatility", "lastPointsOnlyEnabled": true, "lastPointsCount": 7}}]
21
+ }},
22
+ "activeStory": "story-orders-anomalies"
23
+ }
24
+ ```
25
+
26
+ ## Module inputs
27
+
28
+ All optional. Defaults: [generated/solutions.md](../generated/solutions.md#detect).
29
+
30
+ | Key | Values | Meaning |
31
+ | --- | --- | --- |
32
+ | `detectionMethod` | `observed-volatility` · `variation-volatility` · `relative-variation-threshold` · `absolute-variation-threshold` · `absolute-value-threshold` · `forecast` | Volatility of the values, volatility of point-to-point variations, a threshold on the variation (% or value), a threshold on the value, or the gap to a forecast |
33
+ | `detectionThreshold` | number | Threshold of the `*-threshold` methods (percent for `relative-variation-threshold`, measure unit otherwise) |
34
+ | `confidence` | number (%), default `95` | Confidence of the volatility and forecast bands |
35
+ | `confidenceInterval` | boolean, default `true` | Draw the expected band |
36
+ | `flagWhenAbove` / `flagWhenBelow` | boolean, default `true` | Flag spikes, drops, or both |
37
+ | `minImpactThreshold` | number, default `0.5` | Minimum impact for a segment to be reported |
38
+ | `lastPointsOnlyEnabled` | boolean, default `false` | Evaluate only the most recent points (monitoring) |
39
+ | `lastPointsCount` | integer | Number of recent points evaluated with `lastPointsOnlyEnabled` |
40
+ | `baselineMode` | `"all"` | Points used to learn the baseline |
41
+ | `segmentChartMode` | `"overlay"` · `"split"` | Selected segments superimposed, or stacked one chart per segment |
42
+ | `displayDenominator` | boolean | Also plot the denominator of a ratio step |
43
+ | `computeMainKpi` | boolean, default `true` | Detect on the main KPI as well as on the steps |
44
+
45
+ Detection settings can be shared by several Detect modules through `pins.detection` ([studio-stories.md](../studio-stories.md#pins)).
46
+
47
+ ## Checks
48
+
49
+ - A date column exists and its values parse as dates (ISO `YYYY-MM-DD` recommended).
50
+ - One grain per page: do not mix days and months in the same column.
@@ -0,0 +1,101 @@
1
+ # Explore (`explore.dimensions`)
2
+
3
+ Breaks one or two measures down across one or two dimensions, with an optional comparison: bar, line, area, combo, mekko and scatter charts, plus a generated title and comment. Zero settings already give a board-ready chart; every setting below is optional.
4
+
5
+ ## When
6
+
7
+ - "Break down revenue by country", "sessions by device and channel", "orders by week", "show the funnel step by country", "distribution of X across Y".
8
+ - A two-side "why did it change" question is Compare, not Explore. Explore can still **show** a comparison (two periods side by side, deltas).
9
+
10
+ ## Recipe
11
+
12
+ 1. `source`: rows + `dimensions` + `metrics` ([studio-instantiation.md](../studio-instantiation.md)).
13
+ 2. Optional `pins.comparison` to compare two periods or segments ([studio-stories.md](../studio-stories.md#comparisons)).
14
+ 3. Optional `pins.marketEquation` when ratios between metrics must be plottable ([market-equation.md](../market-equation.md)).
15
+ 4. Module `{"module": "explore.dimensions", "inputs": {bindings + chart spec}}`.
16
+
17
+ ```json
18
+ {
19
+ "stories": {"story-sessions-by-country": {
20
+ "title": "Sessions by country and channel",
21
+ "modules": [{"module": "explore.dimensions", "inputs": {
22
+ "primary": "Country", "secondary": "Channel", "metric1": "Session", "metric2": "",
23
+ "chart.category": "bar", "chart.layout": "stacked", "trace": "bar", "view": "bar"
24
+ }}]
25
+ }},
26
+ "activeStory": "story-sessions-by-country"
27
+ }
28
+ ```
29
+
30
+ ## Bindings
31
+
32
+ | Key | Value | Meaning |
33
+ | --- | --- | --- |
34
+ | `primary` | dimension name, or `"Comparison Dimension"` | D1: the axis of the chart. Default: chosen automatically |
35
+ | `secondary` | dimension name, `"Comparison Dimension"` or `""` | D2: series (colors / stacks). `""` = none |
36
+ | `metric1` | measure name | M1: main measure (bars, line, area, height of a mekko, X of a scatter) |
37
+ | `metric2` | measure name or `""` | M2: second measure (line on a right axis in a combo, width of a mekko, Y of a scatter) |
38
+ | `metric3` | measure name or `""` | M3: bubble area (scatter `bubble` only) |
39
+
40
+ A **measure name** is, verbatim:
41
+
42
+ - a metric column (`"Revenue"`),
43
+ - a market-equation step name (`"Checkout per Session"`, also those of the automatic equation),
44
+ - with a comparison only: a delta `"<measure> Δ"` or a relative change `"<measure> % Change"` (`"Revenue Δ"`, `"Checkout per Session % Change"`). Positive deltas use the rise color, negative ones the drop color.
45
+
46
+ `"Comparison Dimension"` stands for the Start / End sides of the comparison pin: as `secondary`, each D1 value gets one bar per period; as `primary`, one group per period.
47
+
48
+ ## Chart spec
49
+
50
+ Write `chart.category` and keep `trace` and `view` equal to it (they are synced from it, and a disagreeing `trace` wins on load).
51
+
52
+ | Key | Values | Default | Meaning |
53
+ | --- | --- | --- | --- |
54
+ | `chart.category` | `bar` · `line` · `area` · `combo` · `mekko` · `scatter` | `bar` | Chart type. `combo` = M1 bars + M2 line; allowed with a single metric |
55
+ | `chart.layout` | `clustered` · `stacked` · `percent` · `overlay` | `clustered` | Series layout. `stacked` / `percent` need a D2 and an additive measure (a ratio falls back to `clustered`). Mekko: `clustered` = Bar Mekko (width = share of M2, height = M1), `percent` = Marimekko 100 % |
56
+ | `chart.variant` | `""` · `moves` · `bubble` | `""` | Scatter only. `moves`: one arrow per segment from Start to End (needs a comparison). `bubble`: M1 across, M2 up, M3 area |
57
+ | `chart.orientation` | `vertical` · `horizontal` | `vertical` | Bar orientation (`horizontal` currently renders vertical) |
58
+ | `chart.comparisonAxis` | `aligned` · `all` | `aligned` | When D1 is the compared dimension: one position per compared pair, or every value colored Start / End / Other |
59
+ | `chart.dualAxis` | `""` · `shared` · `split` | `""` (auto) | With M2: one chart with a right axis, or M2 in its own chart below |
60
+ | `chart.metric2Shape` | `""` · `ticks` · `bars` | `""` (auto) | Shape of M2 on a bar chart |
61
+ | `chart.alignZeros` | boolean | `true` | Both value axes share the zero height |
62
+ | `chart.barOpacity` | `""` or number in (0, 1] | `""` (auto) | Bar fill opacity |
63
+ | `chart.overlapWidth` | `""` or number | `""` (0.55) | Width share of the front bar in `overlay` |
64
+
65
+ Pick the chart from the question:
66
+
67
+ | Ask | Spec |
68
+ | --- | --- |
69
+ | Ranking / comparison of values across categories | `bar` + `clustered` |
70
+ | Composition of a total by a second dimension | `bar` + `stacked` (shares: `percent`) |
71
+ | Trend over time | `line` (D1 = date); several series with a D2 |
72
+ | Volume and rate together | `combo` with M1 = volume, M2 = ratio |
73
+ | Share by two dimensions at once | `mekko` + `percent` |
74
+ | Size and rate of each segment | `mekko` + `clustered` (height = ratio M1, width = volume M2) |
75
+ | Correlation of two measures | `scatter` + `bubble` (M3 optional) |
76
+ | How segments moved between two periods | `scatter` + `moves` with a comparison pin |
77
+ | Period vs period per category | comparison pin, `secondary: "Comparison Dimension"`, `bar` + `clustered` |
78
+
79
+ ## Other inputs
80
+
81
+ | Key | Values | Meaning |
82
+ | --- | --- | --- |
83
+ | `clusteringThreshold` | number 0–100 (%), default `2` | Small D1 / D2 values grouped into "Other" |
84
+ | `clusteringMethod` | `"threshold"` · `"tail"` | Grouping rule |
85
+ | `clusteringBins` | integer 2–20, default `5` | Bins for numeric dimensions |
86
+ | `metricForClustering` | metric column | Metric weighing the segments |
87
+
88
+ Defaults of every input: [generated/solutions.md](../generated/solutions.md#explore).
89
+
90
+ ## Chart tuning
91
+
92
+ Without `configuration.plotter`, a new Explore chart starts on the Datama look (style preset, value labels on bars, comment beside the chart). **Any** non-empty `configuration.plotter` is treated as a saved chart and keeps its own look instead, so add one only for a precise need (value lines, an axis option) and expect to restate the look you want ([plotter/embedded.md](../plotter/embedded.md)). For colors, use the theme ([theming.md](../theming.md)).
93
+
94
+ Average and value lines (`configuration.plotter.annotations.valueLines`) are described in [plotter/annotations.md](../plotter/annotations.md).
95
+
96
+ ## Checks
97
+
98
+ - `primary` and `secondary` are dimension names of the source (or `"Comparison Dimension"` with a comparison pin).
99
+ - `metric1` / `metric2` / `metric3` are measure names that exist verbatim.
100
+ - `Δ` / `% Change` measures, `moves` and `"Comparison Dimension"` require a comparison pin.
101
+ - `trace` and `view` equal `chart.category`.
@@ -0,0 +1,41 @@
1
+ # Pivot (`pivot.tree`)
2
+
3
+ "Where is my KPI the most dispersed right now?" — Compare without a comparison: Pivot scores every dimension on how unevenly the main KPI spreads across its segments, and shows the decomposition as a tree of cards (market-equation steps, then the most dispersed dimensions).
4
+
5
+ ## When
6
+
7
+ - "Where is conversion the most uneven?", "which dimension explains the most variance in basket size", "show me the KPI tree", "pivot table of revenue by segments".
8
+ - No two sides needed. When the user wants a change between two periods, use Compare.
9
+
10
+ ## Recipe
11
+
12
+ 1. `source`: rows + `dimensions` + `metrics` ([studio-instantiation.md](../studio-instantiation.md)).
13
+ 2. Optional `pins.marketEquation` to define the KPI tree ([market-equation.md](../market-equation.md)).
14
+ 3. Module `"pivot.tree"`, or with inputs:
15
+
16
+ ```json
17
+ {
18
+ "stories": {"story-conversion-dispersion": {
19
+ "title": "Where is conversion the most uneven?",
20
+ "modules": [{"module": "pivot.tree", "inputs": {"view": "tree-default", "hierarchyExplorationMethod": "top", "hierarchyTopLeaves": 3}}]
21
+ }},
22
+ "activeStory": "story-conversion-dispersion"
23
+ }
24
+ ```
25
+
26
+ ## Module inputs
27
+
28
+ All optional. Defaults: [generated/solutions.md](../generated/solutions.md#pivot).
29
+
30
+ | Key | Values | Meaning |
31
+ | --- | --- | --- |
32
+ | `view` | `"tree-default"` · `"waterfall-default"` | Tree of cards (dispersion), or the Compare waterfall when a comparison is set |
33
+ | `hierarchyExplorationMethod` | `"hierarchy"` · `"top"` | Expand along the dimension order, or pick the most contributing leaves |
34
+ | `hierarchyTopLeaves` | integer ≥ 1 | Leaves per node with `top` |
35
+ | `clusteringThreshold` | number 0–100 (%), default `2` | Small segments grouped into "Other" |
36
+ | `clusteringMethod` | `"threshold"` · `"tail"` | Grouping rule |
37
+ | `clusteringBins` | integer 2–20, default `5` | Bins for numeric dimensions |
38
+ | `metricForClustering` | metric column | Metric weighing the segments |
39
+ | `totalStepName` / `totalStepUnit` / `totalStepEmoji` | string | Main KPI label (prefer `pins.marketEquation`) |
40
+
41
+ Tree card typography (`treeCardMainKpiRatio`, `treeCardSubKpiRatio`, `treeCardTitleRatio`) works as in Compare ([compare.md](compare.md#tree-view-view-tree-default)).
@@ -0,0 +1,117 @@
1
+ # Studio instantiation
2
+
3
+ How the Studio template boots Datama Studio, and every parameter it accepts. The template already calls `DatamaStudio.render`; you only provide `DATASET`, `CONFIGURATION`, `THEME` and `LICENSE`. Read this file to build the `source` bag correctly, and when a request needs a parameter the template does not set.
4
+
5
+ ## `DatamaStudio.render(container, options)` — what the template calls
6
+
7
+ ```js
8
+ DatamaStudio.render("#datama-studio", {
9
+ source: DATASET, // rows array, or the source bag below
10
+ configuration: CONFIGURATION, // story configuration bag (studio-stories.md); {} = defaults
11
+ theme: THEME, // look (theming.md); undefined = Datama default
12
+ license: LICENSE, // license token string; "" = demo page
13
+ sourceMeta: {embedded: true},
14
+ callbacks: {exportAsHTML, onError},
15
+ }).then((studio) => { /* DatamaStudio instance */ });
16
+ ```
17
+
18
+ | Option | Type | Default | Meaning |
19
+ | --- | --- | --- | --- |
20
+ | `container` (1st argument) | `Element` or string | — | The element, a `#id` / `.class` selector, or a bare element id |
21
+ | `source` (alias `data`) | `Object[]` or source bag | `{data: []}` | The dataset, see below |
22
+ | `configuration` | Object | `{}` | Stories, modules, pins, language ([studio-stories.md](studio-stories.md)). A Datama Light settings bag is also accepted and migrated |
23
+ | `theme` | Object | Datama default | `{colors: {...}}` ([theming.md](theming.md)) |
24
+ | `license` | string | `""` | `DL2.…` token (or a legacy Datama Light token). Empty = demo / unlicensed page |
25
+ | `sourceMeta` | Object | `{embedded: true}` | Free metadata about the dataset origin shown in the header (`embedded`, `createdAt`, `editable`) |
26
+ | `callbacks` | Object | `{windowOpen}` | Host listeners, see [Callbacks](#callbacks) |
27
+ | `debug` | boolean | `false` | Verbose console logs and timers |
28
+ | `context` | string | `"export"` | Host context label |
29
+ | `host` | Object | `{configurable: true}` | `configurable: false` = read-only page: no settings editing, silent notifications |
30
+
31
+ `render` resolves with the mounted `DatamaStudio` instance once the first story is rendered. The template stores it on `window.__DATAMA_STUDIO_INSTANCE__`.
32
+
33
+ ## The `source` bag
34
+
35
+ The simplest source is the rows array itself. Use the bag form to control how columns are classified:
36
+
37
+ ```json
38
+ {
39
+ "data": [
40
+ {"Date": "2025-01-06", "Country": "France", "Device": "Mobile", "Session": 1200, "Checkout": 84, "Revenue": 5120.5}
41
+ ],
42
+ "dimensions": ["Date", "Country", "Device"],
43
+ "metrics": ["Session", "Checkout", "Revenue"]
44
+ }
45
+ ```
46
+
47
+ | Key | Type | Meaning |
48
+ | --- | --- | --- |
49
+ | `data` | `Object[]` | One flat object per row. Same keys on every row. Values: string, number, or `null` |
50
+ | `dimensions` | `string[]` | Columns used as dimensions (text, date, ids, years). Omitted: deduced (text and date columns) |
51
+ | `metrics` | `string[]` | Numeric columns used as metrics, **in market-equation order** (first metric = top of the funnel). Omitted: every numeric column, in column order |
52
+ | `meta` | Object | Column metadata hint. Leave it out: Studio deduces it from the rows |
53
+ | `dateHierarchies` | boolean | `true` adds period columns `Date[Year]`, `Date[Quarter]`, `Date[Month]`, `Date[Week]`, `Date[Day]` for every date column. Default `false` |
54
+
55
+ Rules for the rows:
56
+
57
+ - **Dates**: one consistent format per column, ISO `YYYY-MM-DD` (or `YYYY-MM-DD HH:mm:ss`) preferred. Studio casts them internally; you keep writing the dataset values in configurations (comparisons, filters).
58
+ - **Metrics**: plain numbers (no `"1 200 €"` strings, no thousands separators). Use `null` for a missing value, never `""`.
59
+ - **Ratios and averages** (`conversion_rate`, `AOV`, `CTR`…) should not be metrics: give the raw counts and let the market equation compute ratios ([market-equation.md](market-equation.md)).
60
+ - A numeric column that is really a label (year, store id, zip code) goes in `dimensions` explicitly, otherwise it is read as a metric.
61
+ - Aggregate before inlining when the raw data is larger than ~20 000 rows: keep only the dimensions the request needs and sum the metrics.
62
+ - `metrics` defines what the automatic market equation uses: listing only `["Session", "Checkout", "Revenue"]` gives the funnel Session → Checkout per Session → Revenue per Checkout without writing any step.
63
+
64
+ ## License
65
+
66
+ - No license (`null` in the template): the page runs as a demo. Datama decides which features a demo shows (for instance "Download as HTML" is disabled in demo mode).
67
+ - Licensed page: the template's `__LICENSE__` receives the token string the user or the skill package provided. Never invent, edit or reuse a token from elsewhere.
68
+
69
+ ## Callbacks
70
+
71
+ `callbacks` keys are event channels registered on the instance. Every listener is optional.
72
+
73
+ | Key | Arguments | When |
74
+ | --- | --- | --- |
75
+ | `exportAsHTML` | `(settings)` | Header "Download as HTML": receives the live configuration bag. The template builds and saves a standalone page |
76
+ | `onError` | `(error)` | A refresh failed |
77
+ | `onSuccess` | `()` | A refresh succeeded |
78
+ | `onRenderSettled` | `(detail)` | Charts finished drawing (screenshots, bots) |
79
+ | `onStoryActivate` | `(story, id)` | The active story changed |
80
+ | `onSettingsApply` | `(configurationBag)` | The user saved settings in the page (persist the bag to reload it later) |
81
+ | `windowOpen` | `(url, target)` | Opens a link (default: `window.open`) |
82
+ | `getDataset` | `async () => sourceBag` | Only with `DatamaStudio.create({data: null})`: Studio awaits the dataset |
83
+
84
+ ## Instance methods
85
+
86
+ | Method | Use |
87
+ | --- | --- |
88
+ | `await studio.exportConfigurationForHost()` | Current configuration bag (same shape as `configuration`), with the user's live edits |
89
+ | `await studio.applyLicense(token)` | Apply a license without losing the live settings |
90
+ | `await studio.setStoryLanguage("fr-FR")` | Switch the language (`en-US`, `fr-FR`, `de-DE`, `es-ES`) |
91
+ | `studio.startStoryPresentation()` / `exitStoryPresentation()` | Full-screen slide presentation of the active story |
92
+ | `studio.refresh()` | Re-render after an external change |
93
+
94
+ ## `DatamaStudio.create(params)` — lower-level entry
95
+
96
+ `render(container, options)` is `create` with page defaults. Use `create` only when you need one of its extra parameters:
97
+
98
+ | Param | Meaning |
99
+ | --- | --- |
100
+ | `container` | Element or element id |
101
+ | `data` | Rows array or source bag; `null` to wait for `callbacks.getDataset` |
102
+ | `dimensions` / `metrics` / `meta` / `dateHierarchies` | Same as the source bag keys, at the top level |
103
+ | `configuration`, `license`, `theme`, `callbacks`, `debug`, `host`, `sourceMeta` | Same as `render` |
104
+ | `lite` | `true` = reduced effects and animations (slow devices) |
105
+
106
+ ## Minimal examples
107
+
108
+ Compare with every default (first date column split into its older half vs its newer half, automatic market equation from `metrics`):
109
+
110
+ ```js
111
+ var DATASET = {"data": [/* rows */], "metrics": ["Session", "Checkout", "Revenue"]};
112
+ var CONFIGURATION = {};
113
+ var THEME = null;
114
+ var LICENSE = null;
115
+ ```
116
+
117
+ `{}` creates one default story per bundled solution; the first one (Compare) is shown. To open on a given solution, with a title and a precise analysis, write a story ([studio-stories.md](studio-stories.md)).
@@ -0,0 +1,241 @@
1
+ # Studio configuration: stories, modules and pins
2
+
3
+ `CONFIGURATION` in the Studio template is the same bag Studio itself saves and reloads. Write it in that shape and the page opens exactly on the requested analysis.
4
+
5
+ ## Shape
6
+
7
+ ```json
8
+ {
9
+ "stories": {
10
+ "story-revenue": {
11
+ "title": "Why did revenue drop in March?",
12
+ "emoji": "📉",
13
+ "displayMode": "scroll",
14
+ "pins": {
15
+ "comparison": {"inputs": {"comparisons": [/* see Comparisons */], "relative": false, "order": "desc"}},
16
+ "marketEquation": {"inputs": {"formula": "[1]*[2]*[3]", "totalStepName": "Revenue", "totalStepUnit": "€"}, "steps": [/* market-equation.md */]}
17
+ },
18
+ "modules": [
19
+ {"module": "compare.waterfall", "inputs": {/* solution inputs */}, "configuration": {"plotter": {/* chart tuning */}}}
20
+ ]
21
+ }
22
+ },
23
+ "activeStory": "story-revenue",
24
+ "inputs": {"language": "en-US"}
25
+ }
26
+ ```
27
+
28
+ | Key | Type | Meaning |
29
+ | --- | --- | --- |
30
+ | `stories` | Object (id → story) or array of stories with an `id` | Every story of the page, shown as tabs |
31
+ | `activeStory` | string | Id of the story shown first. Missing or unknown: the first story |
32
+ | `inputs.language` | `"en-US"` · `"fr-FR"` · `"de-DE"` · `"es-ES"` | Language of the whole page (labels, generated titles and comments). Default `en-US`. Match the user's language |
33
+ | `theme` | Object | Same as the template `THEME` ([theming.md](theming.md)); prefer the template variable |
34
+
35
+ `{}` is valid: Studio creates one default story per bundled solution with default analyses. Write stories as soon as the request names a solution, a comparison, metrics or a chart.
36
+
37
+ ## Story
38
+
39
+ | Key | Type | Default | Meaning |
40
+ | --- | --- | --- | --- |
41
+ | `title` | string | solution name | Tab and slide title. Write the user's question or the insight they want |
42
+ | `emoji` | string | 📊 | One emoji shown in the tab |
43
+ | `displayMode` | `"scroll"` · `"slide"` | `"scroll"` | `scroll`: modules stacked in a scrolling page. `slide`: one module per slide, arrow navigation |
44
+ | `appearance` | Object | flat | Story canvas tokens, see [Appearance](#appearance). Omit it for the default flat look |
45
+ | `pins` | Object | `{}` | Analysis scopes shared by every module of the story, see [Pins](#pins) |
46
+ | `modules` | Array | default module of the solution | Render modules, in display order. `activeModules` is accepted as an alias |
47
+
48
+ A story id is any string (`story-` + a slug is the convention). Keep ids unique.
49
+
50
+ ## Module slot
51
+
52
+ A module is one analysis rendered with Plotter. Its key is `<solution id>.<module id>`; the bundled keys are listed in [generated/solutions.md](generated/solutions.md) (`compare.waterfall`, `explore.dimensions`, `detect.anomaly`, `pivot.tree`).
53
+
54
+ ```json
55
+ {"module": "explore.dimensions", "inputs": {"primary": "Country", "metric1": "Revenue"}, "configuration": {}}
56
+ ```
57
+
58
+ A bare string (`"compare.waterfall"`) is a module with default inputs.
59
+
60
+ | Key | Type | Meaning |
61
+ | --- | --- | --- |
62
+ | `module` | string | Module key (required) |
63
+ | `instance` | string | Stable slot id. Optional; needed only to tell two slots of the same module apart |
64
+ | `inputs` | Object | Solution inputs of this slot: view, chart, analysis method, display options. Keys per solution in `solutions/*.md` and defaults in [generated/solutions.md](generated/solutions.md) |
65
+ | `steps` | Array | Market-equation steps of this slot only (prefer the `marketEquation` pin) |
66
+ | `configuration` | Object | Display state; `configuration.plotter` tunes the chart ([plotter/embedded.md](plotter/embedded.md)). `{}` keeps the solution look |
67
+ | `whatIf` | Object | What-if scenarios of this slot (prefer the `whatIf` pin) |
68
+ | `smart` | Object | Internal state written by Studio. Never author it |
69
+
70
+ Several modules in one story read the same data and pins: for instance a Compare waterfall followed by an Explore chart of the same comparison.
71
+
72
+ ## Pins
73
+
74
+ A pin holds one analysis scope **once for the whole story**: every module reads it, and a key held by a pin is ignored on the module slots. This is where Studio saves comparisons, filters and the market equation, so write them there.
75
+
76
+ | Share id | Holds | Use for |
77
+ | --- | --- | --- |
78
+ | `comparison` | `inputs: {comparisons, relative, order, anchor}` | Start vs End sides ([Comparisons](#comparisons)) |
79
+ | `filters` | `inputs: {dataFilters}` | Rows kept for the analysis ([Filters](#filters)) |
80
+ | `marketEquation` | `inputs: {formula, totalStepName, totalStepUnit, totalStepEmoji}` + `steps` | Metrics, steps and main KPI ([market-equation.md](market-equation.md)) |
81
+ | `dimensions` | `inputs: {dimensionsHierarchy, clusteringThreshold, metricForClustering, hierarchicalMix, …}` | Drill-down hierarchy and segment grouping (Compare) |
82
+ | `clustering` | `inputs: {clusteringThreshold, metricForClustering}` | Grouping of small segments into "Other" |
83
+ | `date` | `inputs: {startOfWeek, dateDisplayFormat, dateDisplayCustomPattern, dateHierarchies}` | Date display and period columns |
84
+ | `analysisMethod` | `inputs: {analysisMethod, waterfallMeasure, …, primary, secondary, metric1, metric2}` | Compare / Explore method shared by every module |
85
+ | `detection` | `inputs: {detectionMethod, detectionThreshold, lastPointsCount, lastPointsOnlyEnabled, …}` | Detect settings shared by every module |
86
+ | `whatIf` | `whatIf: {scenarios}` | What-if scenarios ([What if](#what-if)) |
87
+ | `events` | `calendar` | Calendar events (set in the app; do not author) |
88
+ | `theme` | `theme` | Story colors (set in the app; use `THEME` instead) |
89
+
90
+ The exact key list of each pin is generated in [generated/solutions.md](generated/solutions.md#story-pins). A key that is not in its pin list is dropped on load.
91
+
92
+ Default choice:
93
+
94
+ - `comparison`, `filters` and `marketEquation`: always as pins.
95
+ - Everything else (views, chart bindings, methods, display options): on the module `inputs`, unless the user wants it shared by several modules.
96
+
97
+ ## Comparisons
98
+
99
+ `pins.comparison.inputs`:
100
+
101
+ ```json
102
+ {
103
+ "comparisons": [
104
+ {
105
+ "mode": "dimension",
106
+ "start": {"column": "Date", "operator": "between", "value": ["2025-01-01", "2025-01-31"]},
107
+ "end": {"column": "Date", "operator": "between", "value": ["2025-02-01", "2025-02-28"]}
108
+ }
109
+ ],
110
+ "relative": false,
111
+ "order": "desc"
112
+ }
113
+ ```
114
+
115
+ | Key | Values | Meaning |
116
+ | --- | --- | --- |
117
+ | `comparisons` | Array | One entry per comparison. The first is the primary one; a second entry adds a secondary comparison |
118
+ | `comparisons[].mode` | `"dimension"` · `"metric"` | Compare two groups of rows, or two metric columns |
119
+ | `start` / `end` | clause `{column, operator, value}` | The two sides. `column` is the comparison dimension, the same on both sides |
120
+ | `operator` | `"between"` · `"in"` | `between [low, high]` for a date or numeric range (inclusive); `in [v1, v2, …]` for a list of values |
121
+ | `value` | Array | Exact dataset values (same spelling and date format as the rows) |
122
+ | `relative` | boolean | `false`: values are dataset values (use this). `true`: values are indices in the sorted distinct values, `0` = most recent with `order: "desc"` (rolling periods, see below) |
123
+ | `order` | `"desc"` · `"asc"` | Sort used by relative indices and by the comparison dimension. Keep `"desc"` |
124
+ | `anchor` | `"data"` · `"today"` | Reference instant of relative indices. Default `"data"` |
125
+
126
+ Rules:
127
+
128
+ - Date comparison: `between` with the first and last date of each period. Two periods of the same length make the clearest analysis.
129
+ - Categorical comparison: `in` with one value per side (`["Mobile"]` vs `["Desktop"]`), or several values merged on one side (`["Desktop", "Tablet"]`).
130
+ - Both sides use the same `column`. Values must exist in that column.
131
+ - Default when the user gives no comparison: the first date column, its older half of dates vs its newer half (Studio applies it automatically when no comparison pin exists; write it explicitly only when you want other periods).
132
+ - Rolling periods ("last 7 days vs the 7 days before", whatever the data): `relative: true`, `order: "desc"`, `start: {"column": "Date", "operator": "between", "value": [13, 7]}`, `end: {"column": "Date", "operator": "between", "value": [6, 0]}`.
133
+
134
+ Metric comparison (two metric columns of the same rows, for example budget vs actual):
135
+
136
+ ```json
137
+ {"mode": "metric", "pairs": [{"start": "Revenue_budget", "end": "Revenue_actual", "name": "Revenue"}], "startSegment": "Budget", "endSegment": "Actual"}
138
+ ```
139
+
140
+ Datama Light shorthand is still accepted and converted on load: `{"context": "Device", "start": ["Mobile"], "end": ["Desktop"], "relative": false}` (date sides as `[first, last]`). Prefer the canonical `comparisons` form above.
141
+
142
+ ## Filters
143
+
144
+ `pins.filters.inputs.dataFilters` keeps only the matching rows (AND of every clause):
145
+
146
+ ```json
147
+ {"dataFilters": [
148
+ {"id": "filter-country", "column": "Country", "operator": "in", "value": ["France", "Germany"]},
149
+ {"id": "filter-date", "column": "Date", "operator": "between", "value": ["2025-01-01", "2025-03-31"]}
150
+ ]}
151
+ ```
152
+
153
+ | Operator | `value` | Keeps |
154
+ | --- | --- | --- |
155
+ | `in` | Array of values | Rows whose column is one of the values |
156
+ | `not` | Array of values | Rows whose column is none of the values |
157
+ | `like` | string | Rows whose column contains the text |
158
+ | `gte` / `lte` | number or date | Rows above / below the bound (inclusive) |
159
+ | `between` | `[low, high]` | Rows inside the range (inclusive) |
160
+ | `after` / `before` | date | Rows after / before the date |
161
+
162
+ `id` is any unique string. Filter only what the user asked for; a filter on the comparison dimension can empty one side.
163
+
164
+ ## What if
165
+
166
+ Scenario that changes a KPI on a segment and compares it with the baseline (Compare):
167
+
168
+ ```json
169
+ {"whatIf": {"scenarios": [{
170
+ "name": "Optimize Mobile",
171
+ "enabled": true,
172
+ "comparison": true,
173
+ "baseline": {"name": "", "dimension": "Device", "segments": ["Mobile"]},
174
+ "kpis": [{"name": "Basket per Session", "scope": {}, "impact": {"type": "relative", "value": 10}, "pinned": true}]
175
+ }]}}
176
+ ```
177
+
178
+ `kpis[].name` is a step name of the market equation; `impact.type` `"relative"` takes a percentage. Place it in `pins.whatIf`. Use it only when the user asks for a simulation.
179
+
180
+ ## Appearance
181
+
182
+ Story canvas tokens. Omit `appearance` for the default flat look (no padding, no card). The official Datama "slide" card look is:
183
+
184
+ ```json
185
+ {"paddingY": 20, "paddingX": 24, "modulePaddingY": 16, "modulePaddingX": 16, "background": "#EEF2F2", "border": true, "radius": 12, "borderWidth": 1, "borderColor": "#C8D6D6", "shadow": true, "shadowSize": 5, "shadowAlign": "center", "shadowColor": "#000000", "shadowOpacity": 25}
186
+ ```
187
+
188
+ Colors accept `#rgb`, `#rrggbb`, `rgb(...)`, `rgba(...)` or `transparent`; numbers are pixels (opacity in percent).
189
+
190
+ ## Complete examples
191
+
192
+ Compare, February vs January on Revenue:
193
+
194
+ ```json
195
+ {
196
+ "stories": {
197
+ "story-revenue-feb-vs-jan": {
198
+ "title": "Revenue: February vs January",
199
+ "emoji": "📉",
200
+ "pins": {
201
+ "comparison": {"inputs": {
202
+ "comparisons": [{"mode": "dimension",
203
+ "start": {"column": "Date", "operator": "between", "value": ["2025-01-01", "2025-01-31"]},
204
+ "end": {"column": "Date", "operator": "between", "value": ["2025-02-01", "2025-02-28"]}}],
205
+ "relative": false, "order": "desc"}},
206
+ "marketEquation": {
207
+ "inputs": {"formula": "[1]*[2]*[3]", "totalStepName": "Revenue", "totalStepUnit": "€"},
208
+ "steps": [
209
+ {"name": "Session", "numerator": "Session", "denominator": "", "exclude": []},
210
+ {"name": "Checkout per Session", "numerator": "Checkout", "denominator": "Session", "exclude": [], "unit": "%"},
211
+ {"name": "Revenue per Checkout", "numerator": "Revenue", "denominator": "Checkout", "exclude": [], "unit": "€"}
212
+ ]}
213
+ },
214
+ "modules": [
215
+ {"module": "compare.waterfall", "inputs": {"stylePreset": "standard"}}
216
+ ]
217
+ }
218
+ },
219
+ "activeStory": "story-revenue-feb-vs-jan",
220
+ "inputs": {"language": "en-US"}
221
+ }
222
+ ```
223
+
224
+ Two stories, one Explore breakdown and one Detect, in French:
225
+
226
+ ```json
227
+ {
228
+ "stories": {
229
+ "story-breakdown": {"title": "Sessions par pays et canal", "modules": [
230
+ {"module": "explore.dimensions", "inputs": {"primary": "Country", "secondary": "Channel", "metric1": "Session", "chart.category": "bar", "chart.layout": "stacked", "trace": "bar", "view": "bar"}}
231
+ ]},
232
+ "story-anomalies": {"title": "Anomalies des commandes", "modules": ["detect.anomaly"]}
233
+ },
234
+ "activeStory": "story-breakdown",
235
+ "inputs": {"language": "fr-FR"}
236
+ }
237
+ ```
238
+
239
+ ## Datama Light configurations
240
+
241
+ A Datama Light settings bag (`{inputs, steps, configuration}` without `stories`) is still accepted: Studio creates one story per bundled solution from it and opens the first (Compare). Use the story shape for anything new: it is the only way to choose the solution, the title and the modules.
@@ -0,0 +1,79 @@
1
+ # Theming: palette, colors, style presets
2
+
3
+ `THEME` (Studio template) is the **look** of the page. It never changes what is computed. Default: `null` (Datama look). Emit a theme only when the user asks for colors, a brand, a background or a "more modern" / "more sober" look.
4
+
5
+ ```js
6
+ var THEME = {"colors": {"palette": "modern"}};
7
+ ```
8
+
9
+ Every palette, preset and application color key is listed with its exact values in [generated/theme.md](generated/theme.md). A name absent from that file does not exist.
10
+
11
+ ## `colors.palette`: named palette
12
+
13
+ One key answers most requests. Palette slots: 0 net (totals), 1 rise, 2 drop, 3 start, 4 end, then one color per series.
14
+
15
+ | Request | Palette |
16
+ | --- | --- |
17
+ | "More modern", "brighter" | `modern` |
18
+ | Slides, projection, cool tones | `ocean` |
19
+ | Warm tones | `sunset` |
20
+ | Datama product look | `datama` |
21
+ | Datama brand greens (follows `datama-primary-hex`) | `brand` |
22
+ | Retro, muted | `vintage` |
23
+ | High-end, dark and gold | `luxury` |
24
+ | Matches an Excel / Office deck | `excel` |
25
+ | Sober, one hue | `monochrome` · `monochromeGray` |
26
+ | Standard series | `default` |
27
+
28
+ ## Custom colors (`palette: "custom"`)
29
+
30
+ For brand colors given by the user. Write every slot you need; the named palette is ignored.
31
+
32
+ ```json
33
+ {"colors": {
34
+ "palette": "custom",
35
+ "waterfall": {"net": "#1B2A4A", "Up": "#1E9E6A", "Down": "#D64545"},
36
+ "plots": ["#F2A93B", "#4C6EF5", "#1B2A4A", "#12B886", "#E64980"]
37
+ }}
38
+ ```
39
+
40
+ | Key | Meaning |
41
+ | --- | --- |
42
+ | `waterfall.net` | Total bars (Start, End, intermediate pillars) |
43
+ | `waterfall.Up` / `waterfall.Down` | Drivers that raise / lower the main KPI (and positive / negative deltas) |
44
+ | `plots` | Start, End, then one color per series, in order |
45
+
46
+ When a **drop is good news** (costs, churn, complaints), swap the two: `Up` red, `Down` green.
47
+
48
+ ## `colors.application`: page chrome
49
+
50
+ Same keys as the in-app Colors editor ([generated/theme.md](generated/theme.md#application-colors-themecolorsapplication)). Values are `#RRGGBB`.
51
+
52
+ ```json
53
+ {"colors": {
54
+ "palette": "brand",
55
+ "application": {"datama-primary-hex": "#1B2A4A", "datama-secondary-hex": "#F2A93B"},
56
+ "overrideHostBackground": true
57
+ }}
58
+ ```
59
+
60
+ - `datama-primary-hex` drives headings, active states and, with the `brand` palette, the series ramp.
61
+ - `color-bg-light` / `color-bg-dark` only apply with `"overrideHostBackground": true` (dark or colored page background). Without it the background stays transparent.
62
+
63
+ ## Style presets (shapes, typography, spacing)
64
+
65
+ A preset is the whole chart look in one key; it also applies its own palette. It is not part of `THEME`:
66
+
67
+ - Compare: module input `"stylePreset": "<key>"` ([solutions/compare.md](solutions/compare.md)).
68
+ - Explore: starts on its own default preset; keep it unless the user asks for a precise chart change.
69
+
70
+ Keys, labels and paired palettes: [generated/theme.md](generated/theme.md#style-presets-configurationplotterstylepreset). "Looks like a deck" → `presentation`; "board-ready, minimal" → `modern`; "product analytics dashboard" → `dashboard`; "corporate Excel" → `excel`. A preset activates its paired palette: for a color-only request, use `THEME` alone and leave the preset untouched.
71
+
72
+ ## Not theming
73
+
74
+ | Ask | Where |
75
+ | --- | --- |
76
+ | Chart type, layout, series | Explore chart spec ([solutions/explore.md](solutions/explore.md)) |
77
+ | Axis, legend, labels, padding of a chart | `configuration.plotter` ([plotter/embedded.md](plotter/embedded.md)) |
78
+ | Story canvas (cards, background of the story) | Story `appearance` ([studio-stories.md](studio-stories.md#appearance)) |
79
+ | Logo, fonts of the whole app | Configurable in the Datama app, not exposed to this skill |