farseer-cli 1.24.0 → 1.26.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.
- package/README.md +1 -1
- package/dist/commands/dashboards.js +2 -0
- package/dist/commands/dashboards.js.map +1 -1
- package/dist/commands/login.js +18 -7
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.js +28 -12
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/run.js +2 -3
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/sheets.js +5 -3
- package/dist/commands/sheets.js.map +1 -1
- package/dist/commands/whoami.js +12 -5
- package/dist/commands/whoami.js.map +1 -1
- package/dist/mcp/tools/authTools.js +2 -1
- package/dist/mcp/tools/authTools.js.map +1 -1
- package/dist/mcp/tools/dashboardTools.js +3 -1
- package/dist/mcp/tools/dashboardTools.js.map +1 -1
- package/dist/mcp/tools/runTools.js +2 -3
- package/dist/mcp/tools/runTools.js.map +1 -1
- package/dist/mcp/utils/helpers.js +8 -6
- package/dist/mcp/utils/helpers.js.map +2 -2
- package/dist/mcp/utils/session.js +6 -2
- package/dist/mcp/utils/session.js.map +1 -1
- package/dist/operations/dashboards.js +1 -1
- package/dist/operations/dashboards.js.map +1 -1
- package/dist/pipeline/generated-reference.json +8 -8
- package/dist/services/codefirst/layoutReadback.js +95 -0
- package/dist/services/codefirst/layoutReadback.js.map +2 -2
- package/dist/services/configService.js +33 -18
- package/dist/services/configService.js.map +1 -1
- package/dist/services/credentials.js +26 -11
- package/dist/services/credentials.js.map +1 -1
- package/dist/services/farseerService.js +34 -32
- package/dist/services/farseerService.js.map +1 -1
- package/dist/services/keycloak.js +44 -0
- package/dist/services/keycloak.js.map +6 -0
- package/dist/services/preflight.js +1 -2
- package/dist/services/preflight.js.map +1 -1
- package/dist/services/realms.js +67 -15
- package/dist/services/realms.js.map +1 -1
- package/dist/utils/serverUrl.js +42 -0
- package/dist/utils/serverUrl.js.map +6 -0
- package/docs/pipeline-reference.md +13 -3
- package/package.json +2 -2
- package/skills/farseer-build-model/SKILL.md +1 -1
- package/skills/farseer-code-tiles/SKILL.md +153 -0
- package/skills/farseer-code-tiles/anti-patterns.md +183 -0
- package/skills/farseer-code-tiles/api.md +237 -0
- package/skills/farseer-code-tiles/check-tile.mjs +521 -0
- package/skills/farseer-code-tiles/design.md +159 -0
- package/skills/farseer-code-tiles/echarts-look.md +110 -0
- package/skills/farseer-code-tiles/examples/board-deck.js +695 -0
- package/skills/farseer-code-tiles/examples/data-checks.js +475 -0
- package/skills/farseer-code-tiles/examples/kpi-cards.js +374 -0
- package/skills/farseer-code-tiles/examples/map-countries.js +377 -0
- package/skills/farseer-code-tiles/examples/month-plan.js +443 -0
- package/skills/farseer-code-tiles/examples/new-location.js +581 -0
- package/skills/farseer-code-tiles/examples/open-forecast.js +598 -0
- package/skills/farseer-code-tiles/examples/pl-sankey.js +402 -0
- package/skills/farseer-code-tiles/examples/ranked-bars.js +337 -0
- package/skills/farseer-code-tiles/examples/request-form.js +464 -0
- package/skills/farseer-code-tiles/farseer-table.md +98 -0
- package/skills/farseer-code-tiles/known-mistakes.md +178 -0
- package/skills/farseer-code-tiles/maps/europe.geo.json +1 -0
- package/skills/farseer-code-tiles/maps/pick-map.mjs +59 -0
- package/skills/farseer-code-tiles/maps/world.geo.json +1 -0
- package/skills/farseer-dashboards/SKILL.md +3 -2
- package/skills/farseer-dashboards/check.md +3 -2
- package/skills/farseer-dashboards/measures.md +3 -1
- package/skills/farseer-dashboards/reporting-period.md +1 -1
- package/skills/farseer-modify-model/SKILL.md +1 -1
- package/skills/farseer-modify-model/model-validation-pattern.md +3 -3
- package/skills/farseer-optimize-model/SKILL.md +9 -1
- package/skills/farseer-pnl/SKILL.md +3 -3
- package/skills/pipeline-authoring/SKILL.md +2 -2
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# How a Code tile looks
|
|
2
|
+
|
|
3
|
+
**Farseer's own tiles come first.** Where a general charting rule and the look of Farseer's chart and table tiles differ (rounded bar ends, thin bars, a muted axis, a bold title), Farseer's look wins: every mark, label, axis, legend, tooltip and table in a Code tile looks like the same thing on a chart or table tile, so the two stand side by side with no difference.
|
|
4
|
+
|
|
5
|
+
A Code tile sits between Farseer's chart and table tiles on a controller's dashboard. It has to look finished: as considered as the chart tiles beside it, with the same ink, notation and number formats. Correct and tidy is not enough; a tile that looks like a sketch, a prototype or a grey block fails even when every number is right. Where a client's house style says otherwise, the house style wins.
|
|
6
|
+
|
|
7
|
+
## Farseer's parameters
|
|
8
|
+
|
|
9
|
+
These are the values every tile works from. The method below is general; only this table is Farseer's.
|
|
10
|
+
|
|
11
|
+
| Parameter | Value | Use |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| Surface | `ctx.theme.tokens?.background` (`--code-tile-background`) | the tile's ground, already painted |
|
|
14
|
+
| Ink | `ctx.theme.tokens?.text` (`--code-tile-text`) | values, titles, labels, field labels, sub-panel headers, legend text, the names beside a map |
|
|
15
|
+
| Muted ink | `ctx.theme.tokens?.muted` (`--code-tile-muted`) | only units beside a value, footnotes, empty prompts and the end values of a scale; never a label or a header |
|
|
16
|
+
| Rule | `ctx.theme.tokens?.border` (`--code-tile-border`) | gridlines, table rules, card edges, a map's empty countries |
|
|
17
|
+
| AC colour | the AC colour of the `farseer-dashboards` skill (SKILL.md section 2, The AC colour): `#323232`, or a dark brand colour | every single-series chart: bars, rankings, gauge, sankey results, sparklines |
|
|
18
|
+
| AC light | the light solid tint the same chart tiles use for PY (`#A6A6A6` with `#323232`) | PY, costs in a flow, the PL line of a trend |
|
|
19
|
+
| Categorical order | the AC colour, then `#ED7D16` orange, `#1BB5D7` aqua, `#8A2FE5` violet, `#BFA812` olive, `#E52FCD` magenta | identity only: one colour per company, product group, channel |
|
|
20
|
+
| Sequential ramp | four steps of the AC colour, light to dark, made by `tint(AC, 0.45 / 0.65 / 0.8 / 1)`; Farseer blue `#81A9FF`, `#457DFF`, `#0D4BC2`, `#043288` when AC is a grey | magnitude: maps, heatmaps, a value-coloured treemap |
|
|
21
|
+
| Light tints | `tint(AC, 0.52 / 0.37 / 0.24 / 0.11)` (`TINTS`; from Farseer blue `#043288` when AC is a grey) | large areas of one family: treemap groups, with ink text on all |
|
|
22
|
+
| Light fills | AC light, then `#F5B87F`, `#82D6E9`, `#BF8DF1`, `#DCCF7D`, `#F18DE4` (`FILL`, the categorical order at a lighter step) | large areas: treemap boxes and other big blocks, always with ink text |
|
|
23
|
+
| Ramp track | `tint(AC, 0.12)` | the unfilled part of a gauge or meter |
|
|
24
|
+
| Primary button | `#1A66FF`, Farseer's own | a button that writes to the model; never a data colour |
|
|
25
|
+
| Status, good and bad | `#0CB955`, `#E21E09` | variances only (ΔPL, ΔPY), by the line's polarity |
|
|
26
|
+
| Diverging pair | `#E21E09` and `#0CB955` around the rule colour | a variance map or heatmap, centred on zero |
|
|
27
|
+
| AC notation | `#323232`, PY tint `#A6A6A6` | scenario charts in IBCS notation (below) |
|
|
28
|
+
|
|
29
|
+
All colours but AC come from Farseer's own data palettes, already checked for normal vision and red-green colour blindness, so use only the colours in the block below and never type a new list. Identity starts with AC rather than a hue of its own, because a dashboard reads as one when its first company, its bars and its chart tiles share a colour. Orange, aqua and olive are below 3:1 against white, so marks in those colours carry a visible label or sit next to a table that has the value. The light fills are for large areas only, with ink labels and a legend. The ramp, the tints and the track are mixed from AC by `tint()`, never typed in. Farseer's default chart palette starts with three blues and then reds and greens, so it doesn't work for identity: red and green belong to variances. Magnitude (a map, a heatmap) takes steps of AC; when AC is a grey the map takes Farseer blue instead, since a grey ramp turns the map into an empty grey tile. Farseer has no dark theme today; take every surface, text and rule colour from the tile's tokens, so a dark theme works when it comes.
|
|
30
|
+
|
|
31
|
+
Put the constants in the body once. Only the first two lines are written per dashboard; the rest is derived from them (the examples carry the same block):
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
// AC: the dashboards' AC colour (SKILL.md section 2, The AC colour), never an example's
|
|
35
|
+
const AC = '#323232';
|
|
36
|
+
const AC_LIGHT = '#A6A6A6';
|
|
37
|
+
function tint(hex, share) { // mixes a colour with white: 1 is the colour, 0 is white
|
|
38
|
+
const n = parseInt(hex.slice(1), 16);
|
|
39
|
+
const mix = (c) => Math.round(c * share + 255 * (1 - share)).toString(16).padStart(2, '0');
|
|
40
|
+
return `#${mix(n >> 16)}${mix((n >> 8) & 255)}${mix(n & 255)}`.toUpperCase();
|
|
41
|
+
}
|
|
42
|
+
const isGrey = (hex) => { const n = parseInt(hex.slice(1), 16); const c = [n >> 16, (n >> 8) & 255, n & 255]; return Math.max(...c) - Math.min(...c) < 24; };
|
|
43
|
+
const PALETTE = [AC, '#ED7D16', '#1BB5D7', '#8A2FE5', '#BFA812', '#E52FCD'];
|
|
44
|
+
const FILL = [AC_LIGHT, '#F5B87F', '#82D6E9', '#BF8DF1', '#DCCF7D', '#F18DE4'];
|
|
45
|
+
const RAMP = isGrey(AC) ? ['#81A9FF', '#457DFF', '#0D4BC2', '#043288'] : [0.45, 0.65, 0.8, 1].map((s) => tint(AC, s));
|
|
46
|
+
const TINTS = [0.52, 0.37, 0.24, 0.11].map((s) => tint(isGrey(AC) ? '#043288' : AC, s));
|
|
47
|
+
const TRACK = tint(AC, 0.12);
|
|
48
|
+
const PRIMARY = '#1A66FF';
|
|
49
|
+
const GOOD = '#0CB955';
|
|
50
|
+
const BAD = '#E21E09';
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Form first
|
|
54
|
+
|
|
55
|
+
Decide what the reader has to do before choosing a chart, and prefer the plainest form that does it. Sometimes that isn't a chart.
|
|
56
|
+
|
|
57
|
+
| The reader needs | Form |
|
|
58
|
+
|---|---|
|
|
59
|
+
| one current number and how it compares | a KPI card: value, ΔPL or ΔPY, no chart |
|
|
60
|
+
| a few headline numbers | a row of KPI cards |
|
|
61
|
+
| magnitude across members, ranked | horizontal bars through `ctx.charts.farseer` (`BAR_CHART`, `layout: 'VERTICAL'`), largest first, one colour |
|
|
62
|
+
| a ranking and its change | the bars and a `PIN_CHART` of the variance beside them, same row order (the IBCS ranking) |
|
|
63
|
+
| change over months | columns or a line through `ctx.charts.farseer` (IBCS notation) |
|
|
64
|
+
| a variance | a variance bar or pin chart through `ctx.charts.farseer` |
|
|
65
|
+
| how a total breaks into its parts and flows | a sankey, or a waterfall through `ctx.charts.farseer` |
|
|
66
|
+
| one ratio against its target | a bar against a PL outline; a gauge (`echarts-look.md`) only when the user insists |
|
|
67
|
+
| a value per country | a map with real outlines (`api.md`, Maps); without outlines for the area, ranked bars |
|
|
68
|
+
| a whole split into groups and parts | a treemap, or ranked bars when the reader must compare parts exactly |
|
|
69
|
+
| exact figures to read | a table tile; inside a Code tile, a table in the table tile's look (`farseer-table.md`) |
|
|
70
|
+
|
|
71
|
+
- Tiles first. A plain bar chart or table that a chart or table tile can show is that tile; propose it. Inside a Code tile, standard types still go through `ctx.charts.farseer` (pass it a result with its rows filtered and sorted as needed), so they are the chart tile exactly. Every other chart goes through `ctx.charts.echarts` with the base option in `echarts-look.md`.
|
|
72
|
+
- Never draw a chart by hand: no SVG, canvas or HTML boxes standing in for bars, arcs, map shapes or flows, and no second series bent into a shape echarts has no component for. HTML is for what isn't a chart: cards, tables, forms, buttons, titles, notes.
|
|
73
|
+
- Sort what is ranked: bars, the rows of a table beside them and the companies of a comparison go largest first, the same order everywhere on the tile. A colour still follows the member, not its place.
|
|
74
|
+
- One value axis per chart. Two measures on different scales are two charts side by side.
|
|
75
|
+
- No pie or donut unless the user asks, then at most six slices; a sorted bar reads more exactly.
|
|
76
|
+
- A chart of one series is drawn in the AC colour, as the chart tiles draw theirs. When one series is the story among several, it takes AC and the rest the AC light tint.
|
|
77
|
+
- More than six members: show the top five and fold the rest into "Other", or make it a table.
|
|
78
|
+
|
|
79
|
+
## Colour by its job
|
|
80
|
+
|
|
81
|
+
Every colour has one job, and the job decides where it comes from.
|
|
82
|
+
|
|
83
|
+
- **Scenario** (AC, PL, PY, FC): IBCS notation, the same as the chart tiles. AC solid `#323232`, PY a light solid tint `#A6A6A6`, PL no fill with a thin AC outline, FC hatched AC. In `ctx.charts.farseer` settings these are `{ solid, pattern: 'SOLID' }`, `{ pattern: 'NONE', border, borderStyle: 'THIN' }` and `{ solid, pattern: 'HATCHED', border }`. Use the client's dark brand colour for AC where the dashboard already does.
|
|
84
|
+
- **Variance**: green `GOOD` when better, red `BAD` when worse, by the line's polarity (more cost is worse). A variance with no direction (a balance, headcount) takes the muted ink. Green and red are never a series' identity.
|
|
85
|
+
- **Identity** (companies, product groups, channels): `PALETTE` in its fixed order, assigned by the member's place in the model's own member list, never by rank or by what the filter left. Keep the map in the code keyed by member name, so a filter that removes one company repaints nothing. Past six identities, fold into "Other".
|
|
86
|
+
- **Parts of one whole** (cost categories in a stack, the parts of a treemap group, the lines a total splits into): steps of AC (`TINTS` for large areas, `RAMP` for bars), the largest part the deepest and the smallest the lightest. These parts have no identity of their own across charts, so a row of unrelated hues only shouts; save `PALETTE` for members that are things (companies, channels).
|
|
87
|
+
- **Magnitude** (map, heatmap, a treemap coloured by value): `RAMP`, light to dark, one hue, through `visualMap`, with a scale legend. Never a rainbow, never the diverging pair for something that has no zero to diverge from.
|
|
88
|
+
- **Gauge or meter**: the filled part AC, the track the lightest step of AC, the plan as a dark needle.
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
## Composition
|
|
92
|
+
|
|
93
|
+
- **The header is the tile's header.** Farseer draws a chart or table tile's name in 12 px ink, regular weight, 10 px above the content, inside the card's 8 px padding. A Code tile's `name` isn't shown (its `subtitle` and `footnotes` are, only when `style.showSubtitle` or `style.showFootnotes` is on), so the code draws its header in exactly that style: one title line written the way Farseer names its tiles, `<what> by <what>, <period word> (<unit>)` ("Net sales by region, year to date (kEUR)"), with the scope added after a comma only when the filter bar narrows it (", Acme Serbia"). Parts of a title are joined by commas, never by a middle dot or a dash. No subtitle under it; the filter bar already shows the period. A note the reader needs (a substitution) goes to the bottom in the footnote style (11 px muted), as a tile's footnote does. The frame already sits inside the card's padding, so the tile's content has no outer padding of its own. The examples' `heading()` does this.
|
|
94
|
+
- **Sizes by form** (absolute grid, 30 px a unit; the frame is 30 × w − 24 px wide):
|
|
95
|
+
|
|
96
|
+
| Form | w × h | Narrow (w14) |
|
|
97
|
+
|---|---|---|
|
|
98
|
+
| KPI row, four cards | 36 × 7 (36 × 8 with trends) | h13 (h15) |
|
|
99
|
+
| Gauge with its figures | 18 × 8 | h11 |
|
|
100
|
+
| Map of a few countries | 18 × 12 | h11 |
|
|
101
|
+
| Sankey with the chain table | 36 × 10 | h12 (ranked bars) |
|
|
102
|
+
| Treemap | 24 × 12 | h15 |
|
|
103
|
+
| Ranked bars | 18 × (rows × 28 px + 60 px) / 30, about h10 for ten | same h |
|
|
104
|
+
| Ranking with its change (bars and pins) | 24 × 10 for five | h17 |
|
|
105
|
+
| Charts and table side by side | 36 × 7 for three members | h20 |
|
|
106
|
+
| Table | as wide as its columns (about 18 to 24); h = (rows × 24 + 70) / 30 | same h |
|
|
107
|
+
| Form with its context table | 24 × 10 | h15 |
|
|
108
|
+
| Button and full-year table | 18 × 9 | h10 |
|
|
109
|
+
|
|
110
|
+
- **Legend and key numbers stay with what they explain**: a chart tile's legend sits under the chart (`legend.bottom: 0`), and so does a Code tile's; a map's scale and its exact values sit in the map's own empty corner; a gauge's figures stand beside it (under it when narrow); a sankey's small tail is a table beside the flow. Never a legend or list across the tile from its chart.
|
|
111
|
+
|
|
112
|
+
- **Three text levels, as on Farseer's tiles**: the title (12 px ink, regular), body and values (12 to 13 px, a KPI value 28 px semibold), and footnotes (11 px muted). A sub-panel is named by a table-style header (12 px regular with its rule), not by another heading style; labels 12 px regular ink, in sentence case (muted ink is only for units, footnotes and empty prompts, so the tile doesn't turn pale); body and form text 13 px; table text 12 px (`farseer-table.md`); a KPI value 28 px semibold with its unit in 12 px muted beside it, not in the label. Nothing else. The font is the page's (Inter).
|
|
113
|
+
- **Space with grid and gap**, no outer padding (the card has it), `gap` between groups (10 px under the header, 12 to 20 px between blocks), never stacked margins. Cards in a row share width, padding and baseline (`grid-template-columns: repeat(auto-fit, minmax(160px, 1fr))`), and the same element sits in the same place on each.
|
|
114
|
+
- **No frames inside the tile**: Farseer's tiles draw no boxes round their parts, and the tile is already the frame. KPIs in a row stand apart by space and a 1 px divider in the rule colour between them, not by bordered cards.
|
|
115
|
+
- **Dense, not stretched**: the content fills the tile or the tile gets smaller. Every example in `examples/` states its tile size (`// Tile size: w… h…`); pick the size from the content (rows × row height, plus title) and the narrow size for when a user makes it 14 wide. Tables are as wide as their content; on a wide tile put two charts and a table side by side rather than one stretched across the width. A gauge, a map of a few countries or a top 5 is a third or half of the page (w12 to w24), not the whole width.
|
|
116
|
+
- **A grid of checks or statuses** (data checks, who has submitted): Farseer's own icons, drawn by CSS, a black `Tick` where it agrees and a red `Close` where it doesn't, with the value on hover in Farseer's tooltip (`examples/data-checks.js`). What a row checks goes behind a muted `CircledQuestionMark` beside its name, shown on hover, not as grey text under every row. The summary above the grid is plain ink; the red is for the crosses alone. The detail stays on hover; a list of exceptions under the grid only repeats it and makes the tile loud.
|
|
117
|
+
- **Forms**: fields in a grid of two (or three) equal columns, each a label (12 px, regular, ink) over Farseer's own form control: 32 px high, 12 px text, the `#EDF2F7` fill with an 8 px radius, a `#C1CEDE` border on hover and a blue one on focus, and on a select Farseer's chevron 8 px from the right edge. A select starts on a muted prompt ("Choose a cost centre"), never on a value that looks chosen; inputs carry a muted placeholder that is a description, never a number that looks typed. The button that runs the form is Farseer's primary button, under the grid at its right edge or at the end of a one-row form: 32 px, solid `#1966FF` with white 12 px text at weight 500, an 8 px radius, grey (`#E6EBF2` with muted text) while it can't run, with a short muted hint beside it saying what is still missing. A second action takes the secondary button (`fs-secondary`, light blue with blue text), and navigation such as back and next takes the tertiary one (`fs-tertiary`, outlined) with Farseer's own chevrons beside its text (`chevron()` in `examples/board-deck.js`, drawn by the control block's `fs-chevron` classes). Never a hand-made arrow, an emoji or a text arrow (‹ ›, → ). Context the form needs (the budget it adds to) is a small table beside it, not a sentence. The block's `control()` gives controls and buttons this look. Every select and input on the tile is made by `control()`, so they share one chevron, border and height; a native select beside a styled one looks unfinished. Picking one of a few (a business reason, a scenario) is a select, or Farseer's tabs: plain text on one row with an AC underline under the chosen one; never rounded pill buttons, and never tabs that wrap onto a second row (switch to the select instead).
|
|
118
|
+
- **A grid of inputs** (a month by month planner) carries a placeholder in the first empty row at most; the other empty cells stay blank, since the column header already says what goes there. A header aligns with its content: left over selects and text, right over numbers. A preview panel with nothing to preview yet isn't shown; one line where it will be says how to get it.
|
|
119
|
+
- **The title and the form tell the same state**: a member named in the title ("for Commercial") is the member the form already has, prefilled from the filter bar (`picks()`, `api.md`); if the field still shows its prompt, the title doesn't name a member.
|
|
120
|
+
- **Fields that belong together sit together**: a range (From and To) is one field with two selects side by side, an amount and its unit one field; no field stands alone on the last row of the grid (make the free text span the whole row instead).
|
|
121
|
+
- **Forms that fit any width**: the field grid is `repeat(auto-fit, minmax(180px, 1fr))` and the form and its side table sit in a wrapping flex row, so at a narrow width the table goes under the form, never past the tile's edge. A button's text never wraps (`white-space: nowrap`); the row of controls wraps instead. A focused control takes Farseer's own focus, a blue border with a 1 px blue outline, which stays inside the tile's edge. A long choice in a select ends in an ellipsis and the select's `title` carries the full text. The button is disabled exactly while the hint beside it says something is missing, and every field the hint names is required.
|
|
122
|
+
- **Fit the tile to its content**: the grid keeps a tile's width on every screen, and you may not see the tile before the user does, so count its height rather than guess it. Add up the content in px: the title line 26, a row of fields 60 (label, control and the gap under it), a button row 40, a table 28 for its header and 24 a row, a footnote 24, 12 between blocks, and each chart at the height you give it. A field grid of `minmax(180px, 1fr)` holds (frame width + 12) / 192 fields a row, rounded down, and a form with a side table gets only its share of the width, so count the rows the fields really make. Count at the tile's own `w`, not at the narrow width a user may resize it to. Then `h` = (content + 24) / 30, rounded up, so the tile neither cuts its button off nor ends in an empty third. Give every chart element a pixel height computed from the tile, and include the axis labels in it.
|
|
123
|
+
- **Nothing cut off or overlapping**, at the tile's size and at about 400 px wide, the narrowest a user resizes a tile to. Long names truncate with an ellipsis and a `title`; labels that don't fit move outside the mark or into the tooltip, never crop.
|
|
124
|
+
- **Draw charts last**: build every box of the layout first, then call `ctx.charts.*`, so each chart measures its final size.
|
|
125
|
+
- **Both themes**: every surface, text and rule colour from the tokens (`var(--code-tile-…)` in CSS, `ctx.theme.tokens` in chart options), so the tile follows the viewer's theme. Only data marks take typed colours.
|
|
126
|
+
|
|
127
|
+
## Text and numbers
|
|
128
|
+
|
|
129
|
+
- A Code tile shows no title of its own, so the code draws one in the tile header style. It says what the tile answers and for which period and scope ("Where net sales go, January to August 2026, whole group"), not what it is ("Sankey"). Take the period and the scope from `picks()` in the draw function, so the title follows the filter bar. The unit goes in brackets at the end of the title; a substitution goes to a footnote, said the way a reader thinks of it ("No map: sales regions have no outlines"), not the way it was built.
|
|
130
|
+
- One number format per unit across the dashboard: kEUR whole thousands (`'#,##0,'`) everywhere, so the same net sales never reads 45,514 on one tile and 45,514.1 on the next. Format every number with `ctx.format` and the column's `numberFormat`: amounts in thousands `'#,##0,'` with the unit in a header ("Net sales (kEUR)"), variances signed `'+#,##0,;-#,##0,'`, percentages `'0.0%'`, points `'+0.0 pp'`. Never `toFixed` or `toLocaleString`.
|
|
131
|
+
- A value that rounds to zero shows `0` with no sign (never `-0` or `-0,1 %` for a rounding of almost nothing); the base block's `unsigned0()` takes the sign off a formatted zero.
|
|
132
|
+
- Columns of numbers align right with `font-variant-numeric: tabular-nums`; a large standalone value (a KPI) keeps proportional figures.
|
|
133
|
+
- Text is always ink or muted ink, never the series colour. A coloured swatch, dot or line beside the text carries identity. A variance number is the one text that takes colour: red when it hurts; in a table ink when it helps (as the table tile does), on a KPI card green. Text set inside a coloured fill (a treemap box, a map country) is white on the dark fills (blue, violet, the darker ramp steps) and ink on the light ones (orange, aqua, olive, the lightest ramp step).
|
|
134
|
+
- Scenario names are AC, PL, PY and FC; variances ΔPL, ΔPY, ΔPL %. Name rows the way the model does; when the model's closest thing differs from the user's word (brands for products), the title or subtitle says so.
|
|
135
|
+
- A comparison shows its variance as a number (ΔPL, ΔPY and the % where it reads well), not only the two values. On a KPI the variance is one line that never wraps, the amount and the % in their colour (`−31 (−0.1 %) ΔPL`), and the plan on the next line in muted ink (`PL 45,545`). Every KPI tile uses this one format.
|
|
136
|
+
- A footnote says what the reader needs, never how the tile was built ("drawn with…", "ranked bars, since…", "each company keeps its colour"). A substitution the reader must know is said in a few words ("sales regions have no map outlines").
|
|
137
|
+
|
|
138
|
+
## Interaction
|
|
139
|
+
|
|
140
|
+
- Charts animate once, about 300 ms, when they first draw; a redraw (a filter, new data) changes in place without a new entrance. The examples' `drawChart()` does this.
|
|
141
|
+
- A KPI card may carry a trend under its value (AC as a 2 px line in the AC colour ending in a 6 px dot on the last month with a value, PL as a 1 px line in AC light, no axes, 30 px high, as wide as the card, the month in the tooltip) when the months add something; drop it when the card is about a balance at one date.
|
|
142
|
+
- Every chart mark has a tooltip (the value first, then the name, in the base option's style), and marks, rows and cards answer the pointer quietly: a slightly lighter mark, a faint row wash, a darker card edge. Every value a tooltip shows is also readable without it: a label, the axis, or a table beside the chart.
|
|
143
|
+
- Every chart names its own rows: a second chart beside the first (EBITDA beside net sales) carries its category labels too, or the two share one axis of labels between them.
|
|
144
|
+
- A legend for two series or more; none for one. The legend's swatches look like the marks they name: when the colour belongs to the member (each company its colour) and the series differ only by shade (this year full, last year light), drop the echarts legend and say it in the subtitle ("the full bar is this year, the light one last year"). With two series (AC and PY, AC and PL) only AC carries value labels; the other is read against it or in the table beside it. Direct labels sparingly: the end of a line, the bar ends of a single ranking, the one point the title talks about.
|
|
145
|
+
- Buttons and inputs are real `<button>` and `<input>` elements with the focus ring the page already styles. A button that writes says what it will write, shows its state while writing, is disabled meanwhile, and says afterwards what it wrote or why it couldn't.
|
|
146
|
+
- A choice inside the tile (a tab, Net sales or EBITDA) keeps its value in `ctx.snapshot` and calls `ctx.render()`. A choice that other tiles must follow belongs in the dashboard's filters.
|
|
147
|
+
- The member a form changes the plan of (the department, domain or company whose budget it adds to) comes from the filter bar through `picks()`, never from a dropdown inside the tile, so the form and the tiles beside it show the same member. What the form creates or copies from is a field of the form: the version a forecast is copied from, the location a new one is staffed like, the company a new investment belongs to (`examples/open-forecast.js`, `examples/new-location.js`). If the dashboard has no filter on that table, ask the user before adding one to `rows.filters` (single select, `"multiselect": false`) with `farseer dashboards update <dashboard> --input dashboard.json` (it replaces `rows` whole, so start from `farseer dashboards show <dashboard> --json`; each filter needs `displayColumns`). Never change a filter the dashboard already has (how it selects, or its picked members): the other tiles use it too. Then the tile says which member to pick instead. With none or several picked, say which to pick and disable the button.
|
|
148
|
+
- **A what-if simulator** (sliders for price, volume, headcount) may compute in the code, and only there: what it shows is the change against the model's own numbers, written as a change ("EBITDA +1.2 m against the plan if price +3 %"), labelled "Simulation" and drawn apart from model numbers (outlined or hatched, never solid AC). The model's figure beside it stays the model's. A button ("Save as scenario") writes the assumptions into the model; the real number appears only when the model has computed it after the write, and the tile then shows that one, never its own estimate as if it were the plan.
|
|
149
|
+
- A form keeps what the user typed in `ctx.snapshot`. Typing must not redraw the tile (a redraw drops the focus); the input's handler stores the value and updates only what depends on it.
|
|
150
|
+
|
|
151
|
+
## States
|
|
152
|
+
|
|
153
|
+
Every tile handles all four, in muted 13 px text centred in the tile:
|
|
154
|
+
|
|
155
|
+
- **Loading.** Before the first answer, nothing or one quiet line. After that keep drawing `current` while a new answer loads.
|
|
156
|
+
- **Failed.** The handle's `error.message`, and the last good result if there was one.
|
|
157
|
+
- **A column with no number in any row** (a plan nobody has entered yet) is left out of a table and named in the footnote ("No Budget 2027 wages yet"); a column of blanks reads as a broken tile.
|
|
158
|
+
- **Empty.** No rows, or every value null: "No data for this selection". A planner with nothing planned yet says so in one line where its list will be, and still shows the context the user plans against (the budget per department); a large hero 0 is not content.
|
|
159
|
+
- **Column or row error.** Draw the rest and say which part failed.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# The Farseer look in echarts
|
|
2
|
+
|
|
3
|
+
The values below are measured from Farseer's chart tile (`components/chart/chartOption.ts` and `series.ts` in the app): square bars with no radius, bars of one category touching (`barGap: '0%'`), the category axis an ink line without ticks and 12 px ink labels, no value axis and no gridlines, value labels 12 px ink at the bar end with a 4 px halo in the surface colour, the legend at the bottom, the tooltip with a 6 px radius and a soft shadow, a 500 ms entrance. A Code tile's echarts chart uses the same, so it stands next to a chart tile with no difference.
|
|
4
|
+
|
|
5
|
+
Every custom chart in a Code tile is drawn by `ctx.charts.echarts`, and every one starts from the same base option, so the tiles on a page read as one family and sit quietly next to Farseer's own chart tiles. Copy the block below into the tile's body, then build each chart's option on top of it with `merge`. Standard chart types (bars, lines, waterfall, combo in IBCS notation) go through `ctx.charts.farseer` instead, which already has this look.
|
|
6
|
+
|
|
7
|
+
## The base option
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
// The Farseer look: put once in the body (the colours are in design.md), then draw every echarts chart with drawChart.
|
|
11
|
+
const INK = () => ctx.theme.tokens?.text ?? '#020810';
|
|
12
|
+
const MUTED = () => ctx.theme.tokens?.muted ?? '#687C95';
|
|
13
|
+
const LINE = () => ctx.theme.tokens?.border ?? '#E6EBF2';
|
|
14
|
+
const SURFACE = () => ctx.theme.tokens?.background ?? '#FFFFFF';
|
|
15
|
+
const FONT = 'Inter, system-ui, sans-serif';
|
|
16
|
+
let drawnOnce = false;
|
|
17
|
+
// draws one echarts chart in the look; the first chart that draws ends the entrance animation for the rest
|
|
18
|
+
function drawChart(element, option) {
|
|
19
|
+
ctx.charts.echarts(element, option);
|
|
20
|
+
drawnOnce = true;
|
|
21
|
+
}
|
|
22
|
+
// the chart tile's look, measured from it: square bars, 12 px ink labels with a surface-coloured halo, an ink
|
|
23
|
+
// category axis with ticks, no value axis or gridlines, the legend at the bottom, its tooltip and margins
|
|
24
|
+
const LABEL = { show: true, fontFamily: FONT, fontSize: 12, color: INK(), textBorderColor: SURFACE(), textBorderWidth: 4 };
|
|
25
|
+
function look() {
|
|
26
|
+
return {
|
|
27
|
+
animation: !drawnOnce,
|
|
28
|
+
animationDuration: 500,
|
|
29
|
+
textStyle: { fontFamily: FONT, fontSize: 12, color: INK() },
|
|
30
|
+
grid: { left: 10, right: 10, top: 20, bottom: 10, containLabel: true },
|
|
31
|
+
legend: { bottom: 0, textStyle: { fontFamily: FONT, color: INK() } },
|
|
32
|
+
tooltip: {
|
|
33
|
+
trigger: 'item', confine: true, backgroundColor: SURFACE(), borderColor: '#EDF2F7', borderWidth: 1,
|
|
34
|
+
padding: [6, 10], textStyle: { color: INK(), fontSize: 12, fontFamily: FONT },
|
|
35
|
+
extraCssText: 'border-radius:6px;box-shadow:0 4px 16px rgba(107,131,160,0.15)',
|
|
36
|
+
},
|
|
37
|
+
categoryAxis: {
|
|
38
|
+
axisLine: { show: true, lineStyle: { color: INK(), width: 1 } },
|
|
39
|
+
axisTick: { show: true, alignWithLabel: true, lineStyle: { color: INK() } },
|
|
40
|
+
axisLabel: { color: INK(), fontFamily: FONT, fontSize: 12, hideOverlap: true },
|
|
41
|
+
splitLine: { show: false },
|
|
42
|
+
},
|
|
43
|
+
valueAxis: { show: false, splitLine: { show: false } },
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function merge(base, extra) {
|
|
47
|
+
if (Array.isArray(extra) || typeof extra !== 'object' || extra === null) return extra;
|
|
48
|
+
const out = { ...base };
|
|
49
|
+
for (const [key, value] of Object.entries(extra)) {
|
|
50
|
+
out[key] = typeof value === 'object' && value !== null && !Array.isArray(value) && typeof base?.[key] === 'object' ? merge(base[key], value) : value;
|
|
51
|
+
}
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
// for an axis chart:
|
|
55
|
+
const { categoryAxis, valueAxis, ...base } = look();
|
|
56
|
+
drawChart(chartElement, merge(base, {
|
|
57
|
+
yAxis: merge(categoryAxis, { type: 'category', inverse: true, data: names }),
|
|
58
|
+
xAxis: merge(valueAxis, { type: 'value' }),
|
|
59
|
+
series: [{ type: 'bar', data: values, itemStyle: { color: AC }, label: { ...LABEL, position: 'right', formatter } }],
|
|
60
|
+
}));
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The colours are read from `ctx.theme` while drawing, so a change of theme redraws the chart in the new one. The grid margins and the legend at the bottom are the chart tile's own, so a Code tile's plot lines up with the chart tiles beside it.
|
|
64
|
+
|
|
65
|
+
## Marks
|
|
66
|
+
|
|
67
|
+
| Mark | echarts, as the chart tile draws it |
|
|
68
|
+
|---|---|
|
|
69
|
+
| Column or bar | square (no `borderRadius`), the echarts default width (`barCategoryGap` about 20 to 30 %), bars of one category touching (`barGap: '0%'`), AC colour for a single series |
|
|
70
|
+
| Stacked segment | the same; segments separated only by their colours, as on the chart tile |
|
|
71
|
+
| Line | 2 px, the AC colour for the one that matters, AC light for a comparison line; no symbols except where a point is labelled |
|
|
72
|
+
| Value label | `LABEL`: 12 px ink with a 4 px halo in the surface colour, at the bar end (`position: 'right'` or `'top'`); on the one series or the bars of a single ranking |
|
|
73
|
+
| Category axis | an ink baseline, no ticks, 12 px ink labels |
|
|
74
|
+
| Value axis | hidden, with no gridlines: the labels carry the values, as on the chart tile |
|
|
75
|
+
| Legend | at the bottom, echarts' own marker; only for two series or more |
|
|
76
|
+
| Tooltip | the base option's: surface background, `#EDF2F7` edge, 6 px radius, soft shadow; `trigger: 'axis'` with a shadow pointer on bar charts |
|
|
77
|
+
|
|
78
|
+
Text is always ink or muted ink, never the series colour. A label set inside a coloured fill (a treemap box, a map region) is white or ink by the fill's lightness.
|
|
79
|
+
|
|
80
|
+
## Recipes
|
|
81
|
+
|
|
82
|
+
**Ranked bars** (top N, share of a total): a standard chart, so `ctx.charts.farseer` (`BAR_CHART`, `layout: 'VERTICAL'`, `transposeData: true`) with the rows sorted, AC colour, values at the bar ends, no legend.
|
|
83
|
+
|
|
84
|
+
**Gauge** (one ratio against its plan): the gauge and its figures side by side (Actual large, Budget and ΔPL under it), stacked under the gauge below 480 px; a half circle (`startAngle: 180`, `endAngle: 0`) sized from the box in pixels, leaving about 24 px above the arc for the PL label, which stands on the arc at the plan's angle and must never reach the tile's title or edge (radius at most the chart's height less 40 px). Two `gauge` series on the same centre, radius and angles.
|
|
85
|
+
- The first draws the scale and AC: `progress: { show: true, width: 16, roundCap: true, itemStyle: { color: AC } }`, `axisLine: { roundCap: true, lineStyle: { width: 16, color: [[1, TRACK]] } }` where `TRACK` is the lightest step of the ramp, `pointer: { show: false }`, `axisTick: { show: false }`, `splitLine: { show: false }`, `axisLabel` at four or five round values in `MUTED()`, `detail` with the AC value at 28 px in `INK()`.
|
|
86
|
+
- The second draws PL as a pointer and nothing else: `pointer: { show: true, length: '14%', width: 3, offsetCenter: [0, '-74%'], itemStyle: { color: INK() } }` (a short needle across the track at the plan value), every other part `show: false`, `detail: { show: false }`, `title: { show: false }`.
|
|
87
|
+
- The scale's two ends (0 and the max) are written under the ends of the arc as small HTML labels laid over the chart's element (echarts' graphic component isn't in the frame). The PL value is written beside the needle: the second series' `detail` placed at the needle's angle just outside the arc (`offsetCenter` from `cos` and `sin` of the angle). The ends of the scale carry `0%` and the max, nothing between.
|
|
88
|
+
- The scale's `max` is a round value above both (`Math.ceil(max(AC, PL) * 1.3 / step) * step`), so the arc isn't mostly empty. The variance is text under the gauge: `ΔPL −0.2 pp`, red or green by polarity.
|
|
89
|
+
|
|
90
|
+
**Fading an edge** (a map, or anything the tile's edge would cut straight, such as the context countries round a map): put a mask on the chart's element, so the drawing fades into the tile within about 14 % of each edge, and keep the scale and the values in that faded margin, outside the masked element, so they stay crisp and never lie over an outline:
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
const FADE = 'linear-gradient(to right, transparent, #000 14%, #000 86%, transparent), linear-gradient(to bottom, transparent, #000 14%, #000 86%, transparent)';
|
|
94
|
+
chartElement.style.cssText += `;-webkit-mask-image:${FADE};mask-image:${FADE};-webkit-mask-composite:source-in;mask-composite:intersect`;
|
|
95
|
+
// the key and the values: absolutely placed siblings of chartElement in a position:relative box
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
A `visualMap` drawn by echarts would fade with the map, so hide it (`show: false`, it still colours) and draw the scale as a small key: a 96 × 8 px bar with square ends and `linear-gradient(90deg, RAMP…)`, the 0 and maximum under it in muted ink.
|
|
99
|
+
|
|
100
|
+
**Map** (a value per country): real outlines only, from `maps/` (`api.md`, Maps). The map's box is the whole area under the title, never a cut-out beside a list. Zoom to the countries with data, so the map fills its box: `boundingCoords` from their outlines plus about 12 %, `aspectScale: 0.72` for Europe. The scale (a small key, see Fading an edge) and a compact list of the exact values (names and values in ink) sit in the map's faded, empty corner, never over a country with data, not across the tile; below 480 px the list goes in one line under the map. `series: [{ type: 'map', map: 'tile', roam: false, boundingCoords, data, label: { show: false }, itemStyle: { areaColor: EMPTY, borderColor: SURFACE(), borderWidth: 1 }, emphasis: { label: { show: false }, itemStyle: { areaColor: RAMP[3] } } }]`, `visualMap: { type: 'continuous', show: false, min: 0, max, inRange: { color: RAMP } }`. `EMPTY` (a country without a value, and the neighbours drawn for context) is `ctx.theme.tokens?.border`. A ranked list beside the map carries the exact values. No outlines for the area asked (regions, cities, sales territories): draw ranked bars instead and say why in a note.
|
|
101
|
+
|
|
102
|
+
**Treemap** (a whole split into groups and their parts): every part in its group's one light tint of the brand colour (`TINTS`, the largest group the deepest, ink text on all of them; never a grey group, never shades that mean nothing), the 2 px surface gaps telling the parts apart; the groups' names and totals as a swatch legend above the chart (square 8 px swatches like the boxes, names in ink, totals in semibold ink), the chart taking all the height the title and legend leave, since a narrow group can't hold its name; a part's label (its name broken onto lines of about 16 characters, and its value) only when it fits the box, judged from its area; the parts too small for one fold into one labelled "Other <group> (n)" box per group (a single leftover part keeps its own name), so no box is anonymous; an "Other" box too thin for its label is left out of the chart and named in the footnote with its value; text white or ink by the fill. Then: `type: 'treemap'`, `roam: false`, `nodeClick: false`, `breadcrumb: { show: false }`, every parent with its own `value` from a query, `levels: [{ itemStyle: { gapWidth: 4, borderColor: SURFACE() } }, { itemStyle: { gapWidth: 1, borderColor: SURFACE() } }]` (the gap between groups wider than the gap between parts, so a group reads as one block), the value in semibold under the regular name, one `TINTS` step per group in a fixed order, `upperLabel` for the groups, `label` only on boxes wide enough for it (`label.formatter` returns `''` when the box is small; the tooltip carries it).
|
|
103
|
+
|
|
104
|
+
**Sankey** (where a total goes): at most three columns of nodes, two in the usual case, so the flow fills its box and every label has room (net sales into COGS, each cost line and EBITDA), and the short way from EBITDA to net profit as a small table beside it, where the flow would otherwise leave an empty corner; `nodeAlign: 'justify'`, the chart as tall as the tile, and below 640 px the same parts as ranked bars. Then: `type: 'sankey'`, `nodeAlign: 'left'`, `nodeWidth: 10`, `nodeGap: 12`, `layoutIterations: 0` (keeps the order given), `lineStyle: { color: 'target', opacity: 0.35, curveness: 0.5 }` (flows take the colour of where they go, visible but light), results in AC, costs in AC light, labels `INK()` with the value in `MUTED()` (`rich` text). Size the chart from the tile so nodes keep at least 12 px apart, and leave about 12 px under the last node so its label isn't cut.
|
|
105
|
+
|
|
106
|
+
**Stacked bars** (the parts of a total, month by month): the parts in steps of AC, the largest part deepest (`RAMP` reversed), a 1 px surface border between segments (`itemStyle: { borderColor: SURFACE(), borderWidth: 1 }`), the total as a label above each stack (an invisible last series with `label.position: 'top'`, or `ctx.charts.farseer` with its total labels), no value axis and no gridlines, and a legend of square swatches with the parts' totals above or under the chart.
|
|
107
|
+
|
|
108
|
+
**Waterfall** (a total stepping down to a result): when the smallest steps would be hairlines (under about 3 % of the largest bar), chart only the big steps down to the result that matters (EBITDA) and put the small tail (D&A, financial result, the result) in a `farseerTable` beside it, as the sankey recipe does. Category labels sit right under the axis; a negative step's value sits at its bar's end inside the plot. A plain P&L waterfall with nothing a chart tile can't do is a chart tile.
|
|
109
|
+
|
|
110
|
+
**Heatmap** (a grid of values): `visualMap` with `RAMP` (diverging pair only for a variance), cells with `itemStyle: { borderColor: SURFACE(), borderWidth: 2 }`, a label in a cell only when it fits.
|