farseer-cli 1.25.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/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 +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-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,695 @@
|
|
|
1
|
+
// A board deck inside one tile, in the client's brand: one claim, one big number or one chart per slide, every
|
|
2
|
+
// number live from the model and every sentence built from those numbers. Back and forward by buttons, arrow keys or
|
|
3
|
+
// dots; speaker notes fold out. Best shown in the tile's focus view (#/dashboard/<dashboard>/<tile>).
|
|
4
|
+
// Tile size: w36 h20 on the dashboard; it grows with the focus view.
|
|
5
|
+
export default function (ctx) {
|
|
6
|
+
// readTable: a table of numbers from the model, in the shape ctx.charts.farseer draws
|
|
7
|
+
// ({ columns: [{ label, numberFormat }], rows: [{ label, cells: [{ value }] }] }). Call it in the body.
|
|
8
|
+
// rows: { table: 'Entity' } every member of a table, listed live by name
|
|
9
|
+
// rows: { table, includeDashboardFilters: true } the members the filter bar leaves, even when the numbers ignore it
|
|
10
|
+
// rows: { table: 'Months', members: ['M1', …] } the members named here, in this order
|
|
11
|
+
// rows: [{ label, formula, numberFormat }] one line per formula (a P&L)
|
|
12
|
+
// no rows one row, labelled '', for KPIs
|
|
13
|
+
// columns: [{ label, formula, numberFormat }] with member rows, [{ label, filter }] with formula lines
|
|
14
|
+
// Member rows and every number follow the filter bar and timeline, unless the spec turns them off.
|
|
15
|
+
const quote = (name) => `"${String(name).replace(/(["\\])/g, '\\$1')}"`;
|
|
16
|
+
// a table's members from a DTABLE answer, by name, without its NULL member
|
|
17
|
+
const namesOf = (answer) => (answer?.value ?? []).map(String).filter((name) => !name.startsWith('NULL ('));
|
|
18
|
+
function withFilter(formula, filter) {
|
|
19
|
+
let out = '', depth = [], quoted = false;
|
|
20
|
+
for (let i = 0; i < formula.length; i++) {
|
|
21
|
+
const c = formula[i];
|
|
22
|
+
if (c === '"' && formula[i - 1] !== '\\') quoted = !quoted;
|
|
23
|
+
if (!quoted && c === '(') depth.push(/sum\s*$/i.test(formula.slice(0, i)));
|
|
24
|
+
if (!quoted && c === ')' && depth.pop()) out += `, ${filter}`;
|
|
25
|
+
out += c;
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
function readTable(spec) {
|
|
30
|
+
// includeDashboardFilters: false / includeDashboardTimeline: false in the spec leave one out (say so on the tile)
|
|
31
|
+
const options = { includeDashboardFilters: spec.includeDashboardFilters !== false, includeDashboardTimeline: spec.includeDashboardTimeline !== false };
|
|
32
|
+
const { columns } = spec;
|
|
33
|
+
const rows = spec.rows ?? [{ label: '' }];
|
|
34
|
+
const memberRows = !Array.isArray(rows);
|
|
35
|
+
const listOptions = { ...options, ...(memberRows && rows.includeDashboardFilters !== undefined ? { includeDashboardFilters: rows.includeDashboardFilters } : {}) };
|
|
36
|
+
const list = memberRows && !rows.members ? ctx.query([{ type: 'DTABLE', table: rows.table }], listOptions) : null;
|
|
37
|
+
let names = memberRows ? rows.members ?? null : null;
|
|
38
|
+
let listed = null;
|
|
39
|
+
let values = null;
|
|
40
|
+
const open = () => {
|
|
41
|
+
values?.close();
|
|
42
|
+
const formulas = memberRows
|
|
43
|
+
? names.flatMap((name) => columns.map((c) => withFilter(c.formula, `${quote(rows.table)}>${quote(name)}`)))
|
|
44
|
+
: rows.flatMap((r) => columns.map((c) => (r.formula ? withFilter(r.formula, c.filter) : c.formula)));
|
|
45
|
+
values = formulas.length ? ctx.query(formulas.map((formula) => ({ type: 'VARIABLE', formula })), options) : null;
|
|
46
|
+
};
|
|
47
|
+
if (!list) open();
|
|
48
|
+
const refresh = () => {
|
|
49
|
+
if (list.loading && !list.current.length) return;
|
|
50
|
+
const now = namesOf(list.current[0]);
|
|
51
|
+
const key = now.join('\u0001');
|
|
52
|
+
if (key !== listed) {
|
|
53
|
+
listed = key;
|
|
54
|
+
names = now;
|
|
55
|
+
open();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
get loading() {
|
|
60
|
+
if (list) refresh();
|
|
61
|
+
return (list?.loading ?? false) || (values?.loading ?? false);
|
|
62
|
+
},
|
|
63
|
+
get error() {
|
|
64
|
+
return list?.error ?? values?.error ?? null;
|
|
65
|
+
},
|
|
66
|
+
get current() {
|
|
67
|
+
if (list) refresh();
|
|
68
|
+
const cells = values?.current ?? [];
|
|
69
|
+
const labels = memberRows ? names ?? [] : rows.map((r) => r.label);
|
|
70
|
+
return {
|
|
71
|
+
columns: columns.map((c) => ({ label: c.label, numberFormat: c.numberFormat ?? (memberRows ? null : rows[0]?.numberFormat) ?? null })),
|
|
72
|
+
rows: labels.map((label, j) => ({
|
|
73
|
+
label,
|
|
74
|
+
numberFormat: memberRows ? null : rows[j].numberFormat ?? null,
|
|
75
|
+
cells: columns.map((_, i) => ({ value: cells[j * columns.length + i]?.value ?? null })),
|
|
76
|
+
})),
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
// picks(['Entity', 'Year to date']): what the filter bar picked on these tables, for a title or a form.
|
|
82
|
+
// current.Entity is { members: ['Acme Croatia'], all: false }; all is true when the bar doesn't narrow that table.
|
|
83
|
+
function picks(tables) {
|
|
84
|
+
const picked = ctx.query(tables.map((table) => ({ type: 'DTABLE', table })));
|
|
85
|
+
const every = ctx.query(tables.map((table) => ({ type: 'DTABLE', table })), { includeDashboardFilters: false, includeDashboardTimeline: false });
|
|
86
|
+
return {
|
|
87
|
+
get loading() {
|
|
88
|
+
return picked.loading || every.loading;
|
|
89
|
+
},
|
|
90
|
+
get error() {
|
|
91
|
+
return picked.error ?? every.error ?? null;
|
|
92
|
+
},
|
|
93
|
+
get current() {
|
|
94
|
+
return Object.fromEntries(tables.map((table, i) => {
|
|
95
|
+
const members = namesOf(picked.current[i]);
|
|
96
|
+
return [table, { members, all: members.length === namesOf(every.current[i]).length }];
|
|
97
|
+
}));
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
// what the filter bar picked, for the title
|
|
102
|
+
const bar = picks(['Entity', 'Year to date']);
|
|
103
|
+
// the year to date, as the filter bar narrows it: AC, plan and last year
|
|
104
|
+
// the period comes from Reporting period and the filter bar's Year to date: the timeline's year would leave
|
|
105
|
+
// "Prior year" empty
|
|
106
|
+
const kpi = readTable({
|
|
107
|
+
includeDashboardTimeline: false,
|
|
108
|
+
columns: [
|
|
109
|
+
{ label: 'Net sales AC', formula: 'sum("Net sales", "Versions">"Actual", "Reporting period">"Current year")' },
|
|
110
|
+
{ label: 'Net sales PL', formula: 'sum("Net sales", "Versions">"Budget 2026", "Reporting period">"Current year")' },
|
|
111
|
+
{ label: 'Net sales PY', formula: 'sum("Net sales", "Versions">"Actual", "Reporting period">"Prior year")' },
|
|
112
|
+
{ label: 'Gross profit AC', formula: 'sum("Gross profit", "Versions">"Actual", "Reporting period">"Current year")' },
|
|
113
|
+
{ label: 'Gross profit PL', formula: 'sum("Gross profit", "Versions">"Budget 2026", "Reporting period">"Current year")' },
|
|
114
|
+
{ label: 'Margin AC', formula: 'sum("Gross margin %", "Versions">"Actual", "Reporting period">"Current year")' },
|
|
115
|
+
{ label: 'Margin PL', formula: 'sum("Gross margin %", "Versions">"Budget 2026", "Reporting period">"Current year")' },
|
|
116
|
+
{ label: 'Margin PY', formula: 'sum("Gross margin %", "Versions">"Actual", "Reporting period">"Prior year")' },
|
|
117
|
+
{ label: 'EBITDA AC', formula: 'sum("EBITDA", "Versions">"Actual", "Reporting period">"Current year")' },
|
|
118
|
+
{ label: 'EBITDA PL', formula: 'sum("EBITDA", "Versions">"Budget 2026", "Reporting period">"Current year")' },
|
|
119
|
+
{ label: 'EBITDA PY', formula: 'sum("EBITDA", "Versions">"Actual", "Reporting period">"Prior year")' },
|
|
120
|
+
{ label: 'OpEx AC', formula: 'sum("OpEx", "Versions">"Actual", "Reporting period">"Current year")' },
|
|
121
|
+
{ label: 'OpEx PL', formula: 'sum("OpEx", \"Versions\">\"Budget 2026\", \"Reporting period\">\"Current year\")' },
|
|
122
|
+
{ label: 'OpEx PY', formula: 'sum("OpEx", "Versions">"Actual", "Reporting period">"Prior year")' },
|
|
123
|
+
{ label: 'Personnel AC', formula: 'sum("Personnel costs", "Versions">"Actual", "Reporting period">"Current year")' },
|
|
124
|
+
{ label: 'Personnel PL', formula: 'sum("Personnel costs", "Versions">"Budget 2026", "Reporting period">"Current year")' },
|
|
125
|
+
],
|
|
126
|
+
});
|
|
127
|
+
// revenue month by month, the closed months against plan
|
|
128
|
+
const months = readTable({
|
|
129
|
+
includeDashboardTimeline: false,
|
|
130
|
+
rows: { table: 'Months', members: ['M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8', 'M9', 'M10', 'M11', 'M12'] },
|
|
131
|
+
columns: [
|
|
132
|
+
{ label: 'AC', formula: 'sum("Net sales", "Versions">"Actual", "Reporting period">"Current year")' },
|
|
133
|
+
{ label: 'PL', formula: 'sum("Net sales", "Versions">"Budget 2026", "Reporting period">"Current year")' },
|
|
134
|
+
],
|
|
135
|
+
});
|
|
136
|
+
// the full year, forecast against plan: it can't follow a year-to-date filter, so it says so on the slide
|
|
137
|
+
const outlook = readTable({
|
|
138
|
+
includeDashboardFilters: false,
|
|
139
|
+
rows: [
|
|
140
|
+
{ label: 'Net sales', formula: 'sum("Net sales", "Year to date">"M12")' },
|
|
141
|
+
{ label: 'Gross profit', formula: 'sum("Gross profit", "Year to date">"M12")' },
|
|
142
|
+
{ label: 'EBITDA', formula: 'sum("EBITDA", "Year to date">"M12")' },
|
|
143
|
+
],
|
|
144
|
+
columns: [
|
|
145
|
+
{ label: 'FC', filter: '"Reporting period">"Current forecast", "Reporting period">"Current year"' },
|
|
146
|
+
{ label: 'PL', filter: '"Versions">"Budget 2026", "Reporting period">"Current year"' },
|
|
147
|
+
],
|
|
148
|
+
});
|
|
149
|
+
const slide = ctx.snapshot('slide', 0);
|
|
150
|
+
let refocus = false; // after a move the new deck takes the focus back, so the arrow keys keep working
|
|
151
|
+
const notes = ctx.snapshot('notes', false);
|
|
152
|
+
// --- The Farseer look (echarts-look.md, design.md): the same block in every tile ---
|
|
153
|
+
// AC: the dashboards' AC colour (SKILL.md section 2, The AC colour): #323232, or the company's
|
|
154
|
+
// darkest brand colour when it is dark enough, never an example's. AC_LIGHT is its PY tint.
|
|
155
|
+
// Everything else below is derived from them, so nothing else needs changing.
|
|
156
|
+
const AC = '#323232';
|
|
157
|
+
const AC_LIGHT = '#A6A6A6';
|
|
158
|
+
// mixes a colour with white: share 1 is the colour itself, 0 is white
|
|
159
|
+
function tint(hex, share) {
|
|
160
|
+
const n = parseInt(hex.slice(1), 16);
|
|
161
|
+
const mix = (c) => Math.round(c * share + 255 * (1 - share)).toString(16).padStart(2, '0');
|
|
162
|
+
return `#${mix(n >> 16)}${mix((n >> 8) & 255)}${mix(n & 255)}`.toUpperCase();
|
|
163
|
+
}
|
|
164
|
+
// a colour with almost no hue (graphite, grey): its ramp would turn a map grey, so magnitude takes Farseer blue
|
|
165
|
+
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; };
|
|
166
|
+
const PALETTE = [AC, '#ED7D16', '#1BB5D7', '#8A2FE5', '#BFA812', '#E52FCD']; // identity: AC first, then distinct hues
|
|
167
|
+
const FILL = [AC_LIGHT, '#F5B87F', '#82D6E9', '#BF8DF1', '#DCCF7D', '#F18DE4']; // the light step, for large areas
|
|
168
|
+
// magnitude (maps, heatmaps), light to dark: steps of AC, or Farseer blue when AC is a grey
|
|
169
|
+
const RAMP = isGrey(AC) ? ['#81A9FF', '#457DFF', '#0D4BC2', '#043288'] : [0.45, 0.65, 0.8, 1].map((s) => tint(AC, s));
|
|
170
|
+
// light tints of AC for large areas that need ink text (treemap groups), clearly apart from each other
|
|
171
|
+
// (from Farseer blue when AC is a grey, as the ramp: grey tints would make a grey block)
|
|
172
|
+
const TINTS = [0.52, 0.37, 0.24, 0.11].map((s) => tint(isGrey(AC) ? '#043288' : AC, s));
|
|
173
|
+
const TRACK = tint(AC, 0.12); // the unfilled part of a gauge
|
|
174
|
+
const PRIMARY = '#1A66FF'; // Farseer's own primary button, not a data colour
|
|
175
|
+
const GOOD = '#0CB955';
|
|
176
|
+
const BAD = '#E21E09';
|
|
177
|
+
const INK = () => ctx.theme.tokens?.text ?? '#020810';
|
|
178
|
+
const MUTED = () => ctx.theme.tokens?.muted ?? '#687C95';
|
|
179
|
+
const LINE = () => ctx.theme.tokens?.border ?? '#E6EBF2';
|
|
180
|
+
const SURFACE = () => ctx.theme.tokens?.background ?? '#FFFFFF';
|
|
181
|
+
const FONT = 'Inter, system-ui, sans-serif';
|
|
182
|
+
let drawnOnce = false;
|
|
183
|
+
// draws one echarts chart in the look; the first chart that draws ends the entrance animation for the rest
|
|
184
|
+
function drawChart(element, option) {
|
|
185
|
+
ctx.charts.echarts(element, option);
|
|
186
|
+
drawnOnce = true;
|
|
187
|
+
}
|
|
188
|
+
// the chart tile's look, measured from it: square bars, 12 px ink labels with a surface-coloured halo, an ink
|
|
189
|
+
// category axis with ticks, no value axis or gridlines, the legend at the bottom, its tooltip and margins
|
|
190
|
+
const LABEL = { show: true, fontFamily: FONT, fontSize: 12, color: INK(), textBorderColor: SURFACE(), textBorderWidth: 4 };
|
|
191
|
+
function look() {
|
|
192
|
+
return {
|
|
193
|
+
animation: !drawnOnce,
|
|
194
|
+
animationDuration: 500,
|
|
195
|
+
textStyle: { fontFamily: FONT, fontSize: 12, color: INK() },
|
|
196
|
+
grid: { left: 10, right: 10, top: 20, bottom: 10, containLabel: true },
|
|
197
|
+
legend: { bottom: 0, textStyle: { fontFamily: FONT, color: INK() } },
|
|
198
|
+
tooltip: {
|
|
199
|
+
trigger: 'item', confine: true, backgroundColor: SURFACE(), borderColor: '#EDF2F7', borderWidth: 1,
|
|
200
|
+
padding: [6, 10], textStyle: { color: INK(), fontSize: 12, fontFamily: FONT },
|
|
201
|
+
extraCssText: 'border-radius:6px;box-shadow:0 4px 16px rgba(107,131,160,0.15)',
|
|
202
|
+
},
|
|
203
|
+
categoryAxis: {
|
|
204
|
+
axisLine: { show: true, lineStyle: { color: INK(), width: 1 } },
|
|
205
|
+
axisTick: { show: false },
|
|
206
|
+
axisLabel: { color: INK(), fontFamily: FONT, fontSize: 12, hideOverlap: true },
|
|
207
|
+
splitLine: { show: false },
|
|
208
|
+
},
|
|
209
|
+
valueAxis: { show: false, splitLine: { show: false } },
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function merge(base, extra) {
|
|
213
|
+
if (Array.isArray(extra) || typeof extra !== 'object' || extra === null) return extra;
|
|
214
|
+
const out = { ...base };
|
|
215
|
+
for (const [key, value] of Object.entries(extra)) {
|
|
216
|
+
out[key] = typeof value === 'object' && value !== null && !Array.isArray(value) && typeof base?.[key] === 'object' ? merge(base[key], value) : value;
|
|
217
|
+
}
|
|
218
|
+
return out;
|
|
219
|
+
}
|
|
220
|
+
// form controls and buttons in Farseer's toolbar look: 28 px high, 12 px text, the focus ring drawn inside the
|
|
221
|
+
// control (so a control at the tile's edge never loses it), button text that never wraps, a long choice ending in …
|
|
222
|
+
// Farseer's own form controls and buttons (the app's input, select and button), the same in every tile
|
|
223
|
+
const CONTROL_CSS = `
|
|
224
|
+
.fs-control { font: 400 12px/20px ${FONT}; height: 32px; padding: 0 8px; border: 1px solid #EDF2F7; border-radius: 8px;
|
|
225
|
+
background-color: #EDF2F7; color: var(--code-tile-text); min-width: 0; max-width: 100%; box-sizing: border-box; outline: none;
|
|
226
|
+
overflow: hidden; white-space: nowrap; text-overflow: ellipsis; transition: border-color 100ms; }
|
|
227
|
+
select.fs-control { appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
|
|
228
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23020810' fill-rule='evenodd' d='M4.17 6.124a.5.5 0 01.706.047L8 9.74l3.124-3.57a.5.5 0 01.752.658l-3.5 4a.5.5 0 01-.752 0l-3.5-4a.5.5 0 01.047-.705z'/%3E%3C/svg%3E");
|
|
229
|
+
background-repeat: no-repeat; background-position: right 8px center; background-size: 16px 16px; }
|
|
230
|
+
.fs-control:hover { border-color: #C1CEDE; }
|
|
231
|
+
.fs-control:focus, .fs-control:focus-visible { border-color: #1966FF; outline: 1px solid #1966FF; outline-offset: 0; }
|
|
232
|
+
.fs-control.fs-empty, .fs-control::placeholder { color: var(--code-tile-muted); }
|
|
233
|
+
.fs-control:disabled { background-color: var(--code-tile-background); color: var(--code-tile-muted); cursor: not-allowed; }
|
|
234
|
+
.fs-button { font: 500 12px/14px ${FONT}; height: 32px; min-width: 32px; padding: 0 12px; white-space: nowrap; flex: none; border: none;
|
|
235
|
+
border-radius: 8px; cursor: pointer; background-color: #1966FF; color: #FFFFFF; transition: background-color 100ms, color 100ms; }
|
|
236
|
+
.fs-button:hover { background-color: #0942B2; }
|
|
237
|
+
.fs-button.fs-secondary { background-color: #E8F0FF; color: #1966FF; }
|
|
238
|
+
.fs-button.fs-secondary:hover { background-color: #C5D9FF; }
|
|
239
|
+
.fs-button.fs-tertiary { background-color: transparent; color: var(--code-tile-text); font-weight: 400; box-shadow: 0 0 0 1px var(--code-tile-border) inset; }
|
|
240
|
+
.fs-button.fs-tertiary:hover { background-color: #EDF2F7; }
|
|
241
|
+
.fs-button:disabled, .fs-button:disabled:hover { background-color: var(--code-tile-border); color: var(--code-tile-muted); box-shadow: none; cursor: not-allowed; }
|
|
242
|
+
.fs-button:focus-visible { outline: 1px solid var(--code-tile-text); outline-offset: 1px; }
|
|
243
|
+
.fs-button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
|
|
244
|
+
.fs-chevron { width: 16px; height: 16px; flex: none; background-color: currentColor; -webkit-mask: center / 16px no-repeat; mask: center / 16px no-repeat; }
|
|
245
|
+
.fs-chevron-left { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M10.376 4.67a.5.5 0 01-.047.706L6.76 8.5l3.57 3.124a.5.5 0 11-.658.752l-4-3.5a.5.5 0 010-.752l4-3.5a.5.5 0 01.705.047z'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M10.376 4.67a.5.5 0 01-.047.706L6.76 8.5l3.57 3.124a.5.5 0 11-.658.752l-4-3.5a.5.5 0 010-.752l4-3.5a.5.5 0 01.705.047z'/%3E%3C/svg%3E"); }
|
|
246
|
+
.fs-chevron-right { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M5.624 12.33a.5.5 0 01.047-.706L9.24 8.5 5.67 5.376a.5.5 0 11.658-.752l4 3.5a.5.5 0 010 .752l-4 3.5a.5.5 0 01-.705-.047z'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M5.624 12.33a.5.5 0 01.047-.706L9.24 8.5 5.67 5.376a.5.5 0 11.658-.752l4 3.5a.5.5 0 010 .752l-4 3.5a.5.5 0 01-.705-.047z'/%3E%3C/svg%3E"); }
|
|
247
|
+
.fs-button.fs-icon-only { padding: 0; width: 32px; }`;
|
|
248
|
+
// Farseer's own chevrons (the app's ChevronLeft and ChevronRight) for Back and Next, drawn by the control block's CSS
|
|
249
|
+
function chevron(direction) {
|
|
250
|
+
const icon = el('span');
|
|
251
|
+
icon.className = `fs-chevron fs-chevron-${direction}`;
|
|
252
|
+
icon.setAttribute('aria-hidden', 'true');
|
|
253
|
+
return icon;
|
|
254
|
+
}
|
|
255
|
+
function control(tag, className = 'fs-control') {
|
|
256
|
+
if (!document.getElementById('fs-control-style')) {
|
|
257
|
+
const style = document.createElement('style');
|
|
258
|
+
style.id = 'fs-control-style';
|
|
259
|
+
style.textContent = CONTROL_CSS;
|
|
260
|
+
document.head.append(style);
|
|
261
|
+
}
|
|
262
|
+
const node = document.createElement(tag);
|
|
263
|
+
node.className = className;
|
|
264
|
+
return node;
|
|
265
|
+
}
|
|
266
|
+
// Farseer's table look (farseer-table.md): the same font, row height, header and rules as a table tile
|
|
267
|
+
const TABLE_CSS = `
|
|
268
|
+
.fs-table-wrap { width: fit-content; max-width: 100%; overflow: hidden; }
|
|
269
|
+
.fs-table { width: max-content; max-width: calc(100% + 12px); border-collapse: separate; border-spacing: 12px 0; margin: 0 0 0 -12px; font: 12px/1.2 ${FONT}; color: var(--code-tile-text); font-variant-numeric: tabular-nums; }
|
|
270
|
+
.fs-table th { height: 24px; padding: 0 0 5px; font-weight: 400; text-align: right; vertical-align: bottom; white-space: nowrap; background: linear-gradient(var(--code-tile-text), var(--code-tile-text)) bottom / 100% 1px no-repeat; }
|
|
271
|
+
.fs-table td { height: 24px; padding: 0; text-align: right; white-space: nowrap; background: linear-gradient(var(--code-tile-border), var(--code-tile-border)) bottom / 100% 1px no-repeat; }
|
|
272
|
+
.fs-table th:first-child, .fs-table td:first-child { text-align: left; }
|
|
273
|
+
.fs-table td:first-child { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
|
|
274
|
+
.fs-table tr.fs-total td { font-weight: 700; background-image: linear-gradient(var(--code-tile-text), var(--code-tile-text)); }
|
|
275
|
+
.fs-table tbody tr:hover td { background-color: color-mix(in srgb, var(--code-tile-muted) 8%, transparent); }
|
|
276
|
+
.fs-table .fs-good { color: ${GOOD}; } .fs-table .fs-bad { color: ${BAD}; } .fs-table .fs-muted { color: var(--code-tile-muted); }
|
|
277
|
+
.fs-table .fs-key { display: inline-block; width: 8px; height: 8px; margin-right: 8px; vertical-align: 0; }
|
|
278
|
+
.fs-table th.fs-AC, .fs-table tr:last-child td.fs-AC { background: linear-gradient(${AC}, ${AC}) bottom / 100% 3px no-repeat; }
|
|
279
|
+
.fs-table th.fs-PY, .fs-table tr:last-child td.fs-PY { background: linear-gradient(${AC_LIGHT}, ${AC_LIGHT}) bottom / 100% 3px no-repeat; }
|
|
280
|
+
.fs-table th.fs-PL, .fs-table tr:last-child td.fs-PL { background: linear-gradient(${AC}, ${AC}) bottom / 100% 1px no-repeat, linear-gradient(${AC}, ${AC}) 0 calc(100% - 3px) / 100% 1px no-repeat; }
|
|
281
|
+
.fs-table th.fs-FC, .fs-table tr:last-child td.fs-FC { background: repeating-linear-gradient(90deg, ${AC} 0 3px, transparent 3px 5px) bottom / 100% 3px no-repeat; }`;
|
|
282
|
+
function farseerTable(head, rows) {
|
|
283
|
+
// head: [{ label, key?, scenario?: 'AC' | 'PL' | 'PY' | 'FC' }] (a scenario column gets the table tile's rule
|
|
284
|
+
// under its header and its last row: AC thick, PL double, PY light, FC dotted);
|
|
285
|
+
// rows: [{ cells: [text or node, …], total?, tone?: [null | 'good' | 'bad' | 'muted', …] }]
|
|
286
|
+
if (!document.getElementById('fs-table-style')) {
|
|
287
|
+
const style = document.createElement('style');
|
|
288
|
+
style.id = 'fs-table-style';
|
|
289
|
+
style.textContent = TABLE_CSS;
|
|
290
|
+
document.head.append(style);
|
|
291
|
+
}
|
|
292
|
+
const table = el('table');
|
|
293
|
+
table.className = 'fs-table';
|
|
294
|
+
const tr = table.createTHead().insertRow();
|
|
295
|
+
for (const h of head) {
|
|
296
|
+
const th = el('th');
|
|
297
|
+
if (h.scenario) th.className = `fs-${h.scenario}`;
|
|
298
|
+
if (h.key) th.append(h.key);
|
|
299
|
+
th.append(h.label);
|
|
300
|
+
tr.append(th);
|
|
301
|
+
}
|
|
302
|
+
const body = table.createTBody();
|
|
303
|
+
for (const row of rows) {
|
|
304
|
+
const line = body.insertRow();
|
|
305
|
+
if (row.total) line.className = 'fs-total';
|
|
306
|
+
row.cells.forEach((cell, i) => {
|
|
307
|
+
const td = line.insertCell();
|
|
308
|
+
const classes = [row.tone?.[i] ? `fs-${row.tone[i]}` : '', head[i]?.scenario ? `fs-${head[i].scenario}` : ''].filter(Boolean);
|
|
309
|
+
if (classes.length) td.className = classes.join(' ');
|
|
310
|
+
if (cell instanceof Node) td.append(cell);
|
|
311
|
+
else td.textContent = cell ?? '';
|
|
312
|
+
if (i === 0 && typeof cell === 'string') td.title = cell;
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
// the first column gap reaches 12 px past the left edge, so the text lines up with the title; a clipping box keeps it inside the tile
|
|
316
|
+
const box = el('div');
|
|
317
|
+
box.className = 'fs-table-wrap';
|
|
318
|
+
box.append(table);
|
|
319
|
+
return box;
|
|
320
|
+
}
|
|
321
|
+
// a variance number in a table, as the table tile shows it: red when it hurts, ink when it helps
|
|
322
|
+
const tone = (delta, costLine) => (delta === null || delta === undefined ? 'muted' : (costLine ? delta > 0 : delta < 0) ? 'bad' : null);
|
|
323
|
+
// small HTML helpers for titles, notes and states, all in the theme's ink
|
|
324
|
+
function el(tag, css, text) {
|
|
325
|
+
const node = document.createElement(tag);
|
|
326
|
+
if (css) node.style.cssText = css;
|
|
327
|
+
if (text !== undefined) node.textContent = text;
|
|
328
|
+
return node;
|
|
329
|
+
}
|
|
330
|
+
// the tile header exactly as Farseer draws a chart or table tile's name: 12 px ink, regular, 10 px above the content;
|
|
331
|
+
// a note under it in the footnote style (11 px muted). The frame already sits inside the card's 8 px padding, so the
|
|
332
|
+
// tile's own content has no outer padding of its own
|
|
333
|
+
const TITLE = 'font-size:12px;font-weight:400;line-height:1.25;color:var(--code-tile-text)';
|
|
334
|
+
const NOTE = 'font-size:11px;line-height:1.35;color:var(--code-tile-muted)'; // footnotes and units only
|
|
335
|
+
const PAGE = 'display:grid;gap:10px;height:100%;padding:0;align-content:start';
|
|
336
|
+
const MESSAGE = 'display:grid;place-items:center;height:100%;font-size:13px;color:var(--code-tile-muted)';
|
|
337
|
+
// one title line, the way Farseer names tiles ("Net sales by region, year to date (kEUR)"); the scope only when the
|
|
338
|
+
// filter bar narrows it. A note the reader needs goes to the bottom in the footnote style, never under the title
|
|
339
|
+
// a value that rounds to zero carries no sign: "-0,0%" and "+0" become "0,0%" and "0"
|
|
340
|
+
const unsigned0 = (text) => String(text).replace(/^[+\-−](?=0(?:[.,]0+)?(?:\s?%|\s?pp)?$)/, '');
|
|
341
|
+
function heading(wrap, title) {
|
|
342
|
+
wrap.append(el('div', TITLE, title));
|
|
343
|
+
}
|
|
344
|
+
function footnote(wrap, text) {
|
|
345
|
+
wrap.append(el('div', `${NOTE};padding-top:2px`, text));
|
|
346
|
+
}
|
|
347
|
+
// the scope the filter bar sets, for titles: nothing for the whole group, the company, or "2 companies"
|
|
348
|
+
// (bar is the picks() the body opened for the tables a title names)
|
|
349
|
+
function scope(table, all, one) {
|
|
350
|
+
const pick = bar.current[table];
|
|
351
|
+
if (!pick || pick.all) return all;
|
|
352
|
+
if (pick.members.length === 1) return pick.members[0];
|
|
353
|
+
return `${pick.members.length} ${one}`;
|
|
354
|
+
}
|
|
355
|
+
function period() {
|
|
356
|
+
const ytd = bar.current['Year to date'];
|
|
357
|
+
const MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
358
|
+
if (!ytd || ytd.all || ytd.members.length !== 1) return 'year to date';
|
|
359
|
+
const m = Number(ytd.members[0].replace('M', ''));
|
|
360
|
+
return m === 1 ? 'January' : `January to ${MONTHS[m - 1]}`;
|
|
361
|
+
}
|
|
362
|
+
// --- end of the look ---
|
|
363
|
+
// headlines in the brand colour; take a darker step of it when it is under 4.5:1 on white
|
|
364
|
+
const BRAND_DARK = AC;
|
|
365
|
+
const LOGO = ''; // the client's logo as a data URI, only when they give one (SKILL.md section 1)
|
|
366
|
+
const MONTH = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
367
|
+
const DECK_CSS = `
|
|
368
|
+
.deck { display: grid; grid-template-rows: auto 1fr auto; height: 100%; outline: none; }
|
|
369
|
+
.deck-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
|
|
370
|
+
.deck-slide { display: grid; min-height: 0; overflow: hidden; }
|
|
371
|
+
.deck-bottom { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding-top: 8px; }
|
|
372
|
+
.deck-dots { display: flex; gap: 6px; }
|
|
373
|
+
.deck-dot { width: 8px; height: 8px; border-radius: 50%; border: 0; padding: 0; background: var(--code-tile-border); cursor: pointer; transition: background-color 100ms; }
|
|
374
|
+
.deck-dot:hover { background: var(--code-tile-muted); }
|
|
375
|
+
.deck-dot[aria-current="true"] { background: ${AC}; }
|
|
376
|
+
.deck-dot:focus-visible { outline: 1px solid var(--code-tile-text); outline-offset: 2px; }
|
|
377
|
+
.deck-notes { font-size: 12px; line-height: 1.5; color: var(--code-tile-text); border-top: 1px solid var(--code-tile-border); padding-top: 6px; }`;
|
|
378
|
+
|
|
379
|
+
const m = (v) => (v === null ? '–' : ctx.format(v, '#,##0.0,,'));
|
|
380
|
+
const pct = (v) => (v === null ? '–' : ctx.format(Math.abs(v), '0%'));
|
|
381
|
+
const pp = (v) => (v === null ? '–' : ctx.format(Math.abs(v) * 100, '0.0'));
|
|
382
|
+
// a variance of two cells of the same line, in words: the only arithmetic the deck does
|
|
383
|
+
// "3% above plan", "in line with plan" when the change rounds to zero, null when there's nothing to compare with
|
|
384
|
+
const versus = (ac, ref, what) => {
|
|
385
|
+
if (ac === null || ref === null || ref === 0) return null;
|
|
386
|
+
// over |ref|, so a smaller loss than planned reads as above plan, as kpi-cards does
|
|
387
|
+
const change = (ac - ref) / Math.abs(ref);
|
|
388
|
+
if (Math.abs(change) < 0.005) return `in line with ${what}`;
|
|
389
|
+
return `${pct(change)} ${change >= 0 ? 'above' : 'below'} ${what}`;
|
|
390
|
+
};
|
|
391
|
+
// a claim from the comparisons that have numbers: "Net sales are 7% above last year and in line with plan"
|
|
392
|
+
const claimOf = (subject, ...parts) => {
|
|
393
|
+
const said = parts.filter(Boolean);
|
|
394
|
+
return said.length ? `${subject} ${said.join(' and ')}` : `${subject}: no plan or last year to compare with`;
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
function value(result, label) {
|
|
398
|
+
const i = result.columns.findIndex((c) => c.label === label);
|
|
399
|
+
return i < 0 ? null : result.rows[0]?.cells[i]?.value ?? null;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// one slide: a label, a claim, a big number with its unit, a sentence, and a chart or a second figure
|
|
403
|
+
function slideBody(s, size) {
|
|
404
|
+
const box = el('div', `display:grid;grid-template-columns:${size.w > 720 ? 'minmax(0,1fr) minmax(0,1.25fr)' : 'minmax(0,1fr)'};gap:${Math.round(24 * size.s)}px;align-items:center;min-height:0;padding:${Math.round(12 * size.s)}px 0`);
|
|
405
|
+
const text = el('div', `display:grid;gap:${Math.round(10 * size.s)}px;align-content:center;min-width:0`);
|
|
406
|
+
text.append(
|
|
407
|
+
el('div', `font-size:${Math.round(13 * size.s)}px;font-weight:600;color:${BRAND_DARK}`, s.label),
|
|
408
|
+
el('div', `font-size:${Math.round(26 * size.s)}px;font-weight:600;line-height:1.2;letter-spacing:-0.01em;color:var(--code-tile-text);text-wrap:balance`, s.claim),
|
|
409
|
+
);
|
|
410
|
+
if (s.big) {
|
|
411
|
+
const big = el('div', 'display:flex;align-items:baseline;gap:8px');
|
|
412
|
+
big.append(
|
|
413
|
+
el('span', `font-size:${Math.round(60 * size.s)}px;font-weight:600;line-height:1;letter-spacing:-0.03em;color:${AC}`, s.big),
|
|
414
|
+
el('span', `font-size:${Math.round(14 * size.s)}px;color:var(--code-tile-muted)`, s.unit),
|
|
415
|
+
);
|
|
416
|
+
text.append(big);
|
|
417
|
+
}
|
|
418
|
+
text.append(el('div', `font-size:${Math.round(15 * size.s)}px;line-height:1.45;color:var(--code-tile-text);max-width:46ch`, s.sentence));
|
|
419
|
+
box.append(text);
|
|
420
|
+
if (s.multi) {
|
|
421
|
+
// lines of very different size: one small chart each, on its own scale, so none becomes a hairline
|
|
422
|
+
const side = el('div', `display:grid;gap:${Math.round(6 * size.s)}px;min-width:0`);
|
|
423
|
+
box.append(side);
|
|
424
|
+
for (const part of s.multi) {
|
|
425
|
+
const one = el('div', `height:${Math.max(70, Math.round((size.h * 0.6) / s.multi.length))}px;min-width:0`);
|
|
426
|
+
side.append(one);
|
|
427
|
+
queueMicrotask(() => drawChart(one, part(size)));
|
|
428
|
+
}
|
|
429
|
+
} else if (s.chart || s.second) {
|
|
430
|
+
// bars keep the chart tile's thickness: a comparison is as tall as its few bars, a month chart takes the room
|
|
431
|
+
const tall = s.bars ? Math.round(s.bars * 52 * size.s + 24) : Math.round(size.h * 0.62);
|
|
432
|
+
const side = el('div', `min-width:0;height:${Math.max(120, tall)}px`);
|
|
433
|
+
box.append(side);
|
|
434
|
+
if (s.second) {
|
|
435
|
+
side.style.cssText += ';display:grid;align-content:center;gap:6px';
|
|
436
|
+
side.append(
|
|
437
|
+
el('div', `font-size:${Math.round(13 * size.s)}px;color:var(--code-tile-text)`, s.second.label),
|
|
438
|
+
el('div', `font-size:${Math.round(44 * size.s)}px;font-weight:600;line-height:1;color:var(--code-tile-text)`, s.second.value),
|
|
439
|
+
el('div', `font-size:${Math.round(14 * size.s)}px;color:var(--code-tile-text)`, s.second.note),
|
|
440
|
+
);
|
|
441
|
+
} else queueMicrotask(() => drawChart(side, s.chart(size)));
|
|
442
|
+
}
|
|
443
|
+
return box;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// AC solid in the brand colour, PL an outline of it, PY its light tint, FC hatched: the IBCS keys
|
|
447
|
+
const PL_STYLE = { color: SURFACE(), borderColor: AC, borderWidth: 1.5 };
|
|
448
|
+
const FC_STYLE = { color: AC, decal: { color: SURFACE(), dashArrayX: [3, 4], dashArrayY: [1, 0], rotation: Math.PI / 4 } };
|
|
449
|
+
function comparison(items, format, size) {
|
|
450
|
+
// horizontal bars in a fixed reading order (PY, PL, AC), each with its value at the end
|
|
451
|
+
const { categoryAxis, valueAxis, ...base } = look();
|
|
452
|
+
const label = { ...LABEL, fontSize: Math.round(13 * size.s), position: 'right', formatter: (p) => format(p.value) };
|
|
453
|
+
return merge(base, {
|
|
454
|
+
grid: { left: 10, right: 70, top: 10, bottom: 10, containLabel: true },
|
|
455
|
+
yAxis: merge(categoryAxis, { type: 'category', inverse: true, data: items.map((i) => i.name), axisLabel: { fontSize: Math.round(13 * size.s) } }),
|
|
456
|
+
xAxis: merge(valueAxis, { type: 'value', min: 0 }),
|
|
457
|
+
series: [{ type: 'bar', barCategoryGap: '30%', label, data: items.map((i) => ({ value: i.value, itemStyle: i.style })) }],
|
|
458
|
+
tooltip: { show: false },
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function slides() {
|
|
463
|
+
const k = kpi.current;
|
|
464
|
+
const v = (label) => value(k, label);
|
|
465
|
+
const acAt = months.current.columns.findIndex((c) => c.label === 'AC');
|
|
466
|
+
const plAt = months.current.columns.findIndex((c) => c.label === 'PL');
|
|
467
|
+
const rows = months.current.rows.filter((r) => r.cells[acAt]?.value !== null && r.cells[acAt]?.value !== undefined);
|
|
468
|
+
const out = outlook.current;
|
|
469
|
+
const fy = (line, col) => {
|
|
470
|
+
const row = out.rows.find((r) => r.label === line);
|
|
471
|
+
const i = out.columns.findIndex((c) => c.label === col);
|
|
472
|
+
return row && i >= 0 ? row.cells[i]?.value ?? null : null;
|
|
473
|
+
};
|
|
474
|
+
const when = period();
|
|
475
|
+
return [
|
|
476
|
+
{ title: true, note: `Numbers are live from the plan in Farseer for ${when}. Each slide states one result and the figure behind it.` },
|
|
477
|
+
{
|
|
478
|
+
label: 'Net sales',
|
|
479
|
+
claim: claimOf('Net sales are', versus(v('Net sales AC'), v('Net sales PY'), 'last year'), versus(v('Net sales AC'), v('Net sales PL'), 'plan')),
|
|
480
|
+
big: m(v('Net sales AC')), unit: 'm EUR',
|
|
481
|
+
sentence: `${when}: ${m(v('Net sales AC'))} m EUR against ${m(v('Net sales PL'))} m planned and ${m(v('Net sales PY'))} m last year.`,
|
|
482
|
+
note: 'The bars are the closed months; the outline is the plan for the same month.',
|
|
483
|
+
chart: (size) => {
|
|
484
|
+
const { categoryAxis, valueAxis, ...base } = look();
|
|
485
|
+
return merge(base, {
|
|
486
|
+
grid: { left: 10, right: 10, top: 24, bottom: 30, containLabel: true },
|
|
487
|
+
legend: { bottom: 0, itemWidth: 10, itemHeight: 10, data: ['AC', 'PL'] },
|
|
488
|
+
xAxis: merge(categoryAxis, { type: 'category', data: rows.map((r) => MONTH[Number(r.label.slice(1)) - 1]), axisLabel: { fontSize: Math.round(12 * size.s) } }),
|
|
489
|
+
yAxis: merge(valueAxis, { type: 'value', min: 0 }),
|
|
490
|
+
series: [
|
|
491
|
+
{ name: 'AC', type: 'bar', barGap: '0%', itemStyle: { color: AC }, data: rows.map((r) => r.cells[acAt].value),
|
|
492
|
+
label: { ...LABEL, position: 'top', formatter: (p) => (p.dataIndex === rows.length - 1 ? m(p.value) : '') } },
|
|
493
|
+
{ name: 'PL', type: 'bar', itemStyle: PL_STYLE, data: rows.map((r) => r.cells[plAt]?.value ?? null) },
|
|
494
|
+
],
|
|
495
|
+
tooltip: { trigger: 'axis', valueFormatter: (x) => `${m(x)} m EUR` },
|
|
496
|
+
});
|
|
497
|
+
},
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
label: 'Gross profit',
|
|
501
|
+
claim: `Gross margin is ${pp((v('Margin AC') ?? 0) - (v('Margin PL') ?? 0))} pp ${(v('Margin AC') ?? 0) >= (v('Margin PL') ?? 0) ? 'above' : 'below'} plan`,
|
|
502
|
+
big: v('Margin AC') === null ? '–' : ctx.format(v('Margin AC') * 100, '0.0'), unit: '% of net sales',
|
|
503
|
+
sentence: `Gross profit of ${m(v('Gross profit AC'))} m EUR, against a planned ${m(v('Gross profit PL'))} m. Last year the margin was ${v('Margin PY') === null ? '–' : ctx.format(v('Margin PY') * 100, '0.0')} %.`,
|
|
504
|
+
note: 'Gross profit is net sales less the cost of goods sold.',
|
|
505
|
+
bars: 3,
|
|
506
|
+
chart: (size) => comparison([
|
|
507
|
+
{ name: 'PY', value: v('Margin PY'), style: { color: AC_LIGHT } },
|
|
508
|
+
{ name: 'PL', value: v('Margin PL'), style: PL_STYLE },
|
|
509
|
+
{ name: 'AC', value: v('Margin AC'), style: { color: AC } },
|
|
510
|
+
], (x) => `${ctx.format(x * 100, '0.0')} %`, size),
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
label: 'EBITDA',
|
|
514
|
+
claim: claimOf('EBITDA is', versus(v('EBITDA AC'), v('EBITDA PL'), 'plan')),
|
|
515
|
+
big: m(v('EBITDA AC')), unit: 'm EUR',
|
|
516
|
+
sentence: `Planned ${m(v('EBITDA PL'))} m EUR for ${when}; last year ${m(v('EBITDA PY'))} m.`,
|
|
517
|
+
note: 'The gap to plan follows the gross profit gap; operating costs are on the next slides.',
|
|
518
|
+
bars: 3,
|
|
519
|
+
chart: (size) => comparison([
|
|
520
|
+
{ name: 'PY', value: v('EBITDA PY'), style: { color: AC_LIGHT } },
|
|
521
|
+
{ name: 'PL', value: v('EBITDA PL'), style: PL_STYLE },
|
|
522
|
+
{ name: 'AC', value: v('EBITDA AC'), style: { color: AC } },
|
|
523
|
+
], m, size),
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
label: 'Operating costs',
|
|
527
|
+
claim: claimOf('Operating costs are', versus(v('OpEx AC'), v('OpEx PL'), 'plan')),
|
|
528
|
+
big: m(v('OpEx AC')), unit: 'm EUR',
|
|
529
|
+
sentence: `Planned ${m(v('OpEx PL'))} m EUR for ${when}; last year ${m(v('OpEx PY'))} m.`,
|
|
530
|
+
note: 'Operating costs are personnel, rent, marketing and other OpEx. More cost than planned is worse.',
|
|
531
|
+
bars: 3,
|
|
532
|
+
chart: (size) => comparison([
|
|
533
|
+
{ name: 'PY', value: v('OpEx PY'), style: { color: AC_LIGHT } },
|
|
534
|
+
{ name: 'PL', value: v('OpEx PL'), style: PL_STYLE },
|
|
535
|
+
{ name: 'AC', value: v('OpEx AC'), style: { color: AC } },
|
|
536
|
+
], m, size),
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
label: 'Personnel costs',
|
|
540
|
+
claim: claimOf('Personnel costs are', versus(v('Personnel AC'), v('Personnel PL'), 'plan')),
|
|
541
|
+
big: m(v('Personnel AC')), unit: 'm EUR',
|
|
542
|
+
sentence: `Planned ${m(v('Personnel PL'))} m EUR for ${when}.`,
|
|
543
|
+
note: 'More cost than planned is worse: the variance is read with the cost sign.',
|
|
544
|
+
bars: 2,
|
|
545
|
+
chart: (size) => comparison([
|
|
546
|
+
{ name: 'PL', value: v('Personnel PL'), style: PL_STYLE },
|
|
547
|
+
{ name: 'AC', value: v('Personnel AC'), style: { color: AC } },
|
|
548
|
+
], m, size),
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
label: 'Outlook, full year',
|
|
552
|
+
claim: `${claimOf('The forecast puts net sales', versus(fy('Net sales', 'FC'), fy('Net sales', 'PL'), 'plan'))} for the year`,
|
|
553
|
+
big: m(fy('Net sales', 'FC')), unit: 'm EUR net sales, forecast',
|
|
554
|
+
sentence: `EBITDA forecast ${m(fy('EBITDA', 'FC'))} m EUR${fy('EBITDA', 'PL') === null ? '; the model holds no EBITDA plan' : ` against ${m(fy('EBITDA', 'PL'))} m planned`}. Full year, whole company: this slide doesn't follow the filter bar.`,
|
|
555
|
+
note: 'FC is the current forecast: actual for the closed months and forecast for the rest.',
|
|
556
|
+
multi: ['Net sales', 'Gross profit', 'EBITDA'].map((line) => (size) => {
|
|
557
|
+
const { categoryAxis, valueAxis, ...base } = look();
|
|
558
|
+
const label = { ...LABEL, fontSize: Math.round(12 * size.s), position: 'right', formatter: (p) => m(p.value) };
|
|
559
|
+
return merge(base, {
|
|
560
|
+
grid: { left: 10, right: 60, top: 18, bottom: 0, containLabel: true },
|
|
561
|
+
title: { text: line, left: 0, top: 0, textStyle: { fontFamily: FONT, fontSize: Math.round(12 * size.s), fontWeight: 400, color: INK() } },
|
|
562
|
+
legend: { show: false },
|
|
563
|
+
yAxis: merge(categoryAxis, { type: 'category', inverse: true, data: ['PL', 'FC'], axisLabel: { hideOverlap: false, interval: 0 } }),
|
|
564
|
+
xAxis: merge(valueAxis, { type: 'value' }),
|
|
565
|
+
series: [{ type: 'bar', barCategoryGap: '25%', label, data: [
|
|
566
|
+
{ value: fy(line, 'PL'), itemStyle: PL_STYLE },
|
|
567
|
+
{ value: fy(line, 'FC'), itemStyle: FC_STYLE },
|
|
568
|
+
] }],
|
|
569
|
+
tooltip: { trigger: 'item', valueFormatter: (x) => `${m(x)} m EUR` },
|
|
570
|
+
});
|
|
571
|
+
}),
|
|
572
|
+
},
|
|
573
|
+
];
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
return (element) => {
|
|
577
|
+
if (!document.getElementById('deck-style')) {
|
|
578
|
+
const style = document.createElement('style');
|
|
579
|
+
style.id = 'deck-style';
|
|
580
|
+
style.textContent = DECK_CSS;
|
|
581
|
+
document.head.append(style);
|
|
582
|
+
}
|
|
583
|
+
if (kpi.loading && !kpi.current.rows.length) {
|
|
584
|
+
element.replaceChildren(el('div', MESSAGE, ''));
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
const failed = kpi.error ?? months.error ?? outlook.error;
|
|
588
|
+
if (failed && !kpi.current.rows.length) {
|
|
589
|
+
element.replaceChildren(el('div', MESSAGE, failed.message));
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
const all = slides();
|
|
593
|
+
const at = Math.min(Math.max(slide.value, 0), all.length - 1);
|
|
594
|
+
const go = (next) => {
|
|
595
|
+
refocus = true;
|
|
596
|
+
slide.set(Math.min(Math.max(next, 0), all.length - 1));
|
|
597
|
+
ctx.render();
|
|
598
|
+
};
|
|
599
|
+
// the type grows with the tile: 1 at the dashboard size, more in the focus view
|
|
600
|
+
const w = element.clientWidth;
|
|
601
|
+
const h = element.clientHeight;
|
|
602
|
+
const size = { w, h, s: Math.min(Math.max(Math.min(w / 1056, h / 576), 0.75), 2) };
|
|
603
|
+
|
|
604
|
+
const deck = el('div');
|
|
605
|
+
deck.className = 'deck';
|
|
606
|
+
deck.tabIndex = 0;
|
|
607
|
+
deck.setAttribute('aria-roledescription', 'slides');
|
|
608
|
+
const top = el('div');
|
|
609
|
+
top.className = 'deck-top';
|
|
610
|
+
top.append(el('div', TITLE, `Board review, ${period()} (live from the plan)`));
|
|
611
|
+
|
|
612
|
+
const area = el('div');
|
|
613
|
+
area.className = 'deck-slide';
|
|
614
|
+
const s = all[at];
|
|
615
|
+
if (s.title) {
|
|
616
|
+
const cover = el('div', 'display:grid;align-content:center;min-height:0');
|
|
617
|
+
const block = el('div', `display:grid;justify-items:start;gap:${Math.round(14 * size.s)}px;padding-left:${Math.round(8 * size.s)}px`);
|
|
618
|
+
// the logo only when the client gave one: never a drawn wordmark
|
|
619
|
+
if (LOGO) {
|
|
620
|
+
const logo = el('img', `height:${Math.round(64 * size.s)}px;width:auto`);
|
|
621
|
+
logo.src = LOGO;
|
|
622
|
+
logo.alt = '';
|
|
623
|
+
block.append(logo);
|
|
624
|
+
}
|
|
625
|
+
block.append(
|
|
626
|
+
el('div', `font-size:${Math.round(44 * size.s)}px;font-weight:600;letter-spacing:-0.02em;line-height:1.1;color:var(--code-tile-text)`, 'Board review'),
|
|
627
|
+
el('div', `font-size:${Math.round(18 * size.s)}px;color:var(--code-tile-text)`, `${period()[0].toUpperCase()}${period().slice(1)} 2026: net sales, gross profit, EBITDA, operating and personnel costs, and the outlook`),
|
|
628
|
+
el('div', `font-size:${Math.round(13 * size.s)}px;color:var(--code-tile-muted)`, 'Live from the plan in Farseer'),
|
|
629
|
+
);
|
|
630
|
+
// the cover already says the result: the headline figures with their variance, so the tile is worth a
|
|
631
|
+
// look on the dashboard before anyone opens the deck
|
|
632
|
+
const strip = el('div', `display:flex;flex-wrap:wrap;gap:${Math.round(12 * size.s)}px ${Math.round(40 * size.s)}px;margin-top:${Math.round(10 * size.s)}px`);
|
|
633
|
+
for (const [label, ac, pl] of [['Net sales', 'Net sales AC', 'Net sales PL'], ['Gross profit', 'Gross profit AC', 'Gross profit PL'], ['EBITDA', 'EBITDA AC', 'EBITDA PL']]) {
|
|
634
|
+
const a = value(kpi.current, ac);
|
|
635
|
+
const p = value(kpi.current, pl);
|
|
636
|
+
const fig = el('div', 'display:grid;gap:2px');
|
|
637
|
+
const delta = a !== null && p !== null ? a - p : null;
|
|
638
|
+
fig.append(
|
|
639
|
+
el('div', `font-size:${Math.round(12 * size.s)}px;color:var(--code-tile-text)`, label),
|
|
640
|
+
el('div', `font-size:${Math.round(28 * size.s)}px;font-weight:600;line-height:1.1;color:var(--code-tile-text)`, `${m(a)} m`),
|
|
641
|
+
// a variance that rounds to zero is neither good nor bad, and carries no sign
|
|
642
|
+
el('div', `font-size:${Math.round(13 * size.s)}px;font-weight:600;color:${delta === null || m(Math.abs(delta)) === m(0) ? 'var(--code-tile-muted)' : delta >= 0 ? GOOD : BAD}`, delta === null ? 'no plan' : m(Math.abs(delta)) === m(0) ? 'in line with PL' : `${delta >= 0 ? '+' : '−'}${m(Math.abs(delta))} m ΔPL`),
|
|
643
|
+
);
|
|
644
|
+
strip.append(fig);
|
|
645
|
+
}
|
|
646
|
+
block.append(strip);
|
|
647
|
+
cover.append(block);
|
|
648
|
+
area.append(cover);
|
|
649
|
+
} else area.append(slideBody(s, size));
|
|
650
|
+
|
|
651
|
+
const bottom = el('div');
|
|
652
|
+
bottom.className = 'deck-bottom';
|
|
653
|
+
const toggle = control('button', 'fs-button fs-tertiary');
|
|
654
|
+
toggle.textContent = notes.value ? 'Hide notes' : 'Speaker notes';
|
|
655
|
+
toggle.onclick = () => {
|
|
656
|
+
notes.set(!notes.value);
|
|
657
|
+
ctx.render();
|
|
658
|
+
};
|
|
659
|
+
const dots = el('div');
|
|
660
|
+
dots.className = 'deck-dots';
|
|
661
|
+
all.forEach((_, i) => {
|
|
662
|
+
const dot = el('button');
|
|
663
|
+
dot.className = 'deck-dot';
|
|
664
|
+
dot.setAttribute('aria-label', `Slide ${i + 1}`);
|
|
665
|
+
dot.setAttribute('aria-current', String(i === at));
|
|
666
|
+
dot.onclick = () => go(i);
|
|
667
|
+
dots.append(dot);
|
|
668
|
+
});
|
|
669
|
+
const nav = el('div', 'display:flex;gap:8px');
|
|
670
|
+
const back = control('button', 'fs-button fs-tertiary');
|
|
671
|
+
back.append(chevron('left'), 'Back');
|
|
672
|
+
back.disabled = at === 0;
|
|
673
|
+
back.onclick = () => go(at - 1);
|
|
674
|
+
const next = control('button', 'fs-button fs-tertiary');
|
|
675
|
+
next.append('Next', chevron('right'));
|
|
676
|
+
next.disabled = at === all.length - 1;
|
|
677
|
+
next.onclick = () => go(at + 1);
|
|
678
|
+
// the slide number sits with the controls: the tile's own menu covers the top right corner on hover
|
|
679
|
+
nav.prepend(el('div', 'align-self:center;font-size:12px;color:var(--code-tile-text);font-variant-numeric:tabular-nums;padding-right:4px', `${at + 1} / ${all.length}`));
|
|
680
|
+
nav.append(back, next);
|
|
681
|
+
bottom.append(toggle, dots, nav);
|
|
682
|
+
|
|
683
|
+
deck.append(top, area, bottom);
|
|
684
|
+
if (notes.value) deck.append(el('div', 'deck-notes', s.note ?? ''));
|
|
685
|
+
deck.style.gridTemplateRows = notes.value ? 'auto 1fr auto auto' : 'auto 1fr auto';
|
|
686
|
+
// arrow keys while the deck has the focus (a click in the tile gives it)
|
|
687
|
+
deck.addEventListener('keydown', (event) => {
|
|
688
|
+
if (event.key === 'ArrowRight' || event.key === 'PageDown') go(at + 1);
|
|
689
|
+
if (event.key === 'ArrowLeft' || event.key === 'PageUp') go(at - 1);
|
|
690
|
+
});
|
|
691
|
+
element.replaceChildren(deck);
|
|
692
|
+
if (refocus) deck.focus({ preventScroll: true });
|
|
693
|
+
refocus = false;
|
|
694
|
+
};
|
|
695
|
+
}
|