@veyforma/charts 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Veyforma (https://www.veyforma.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,187 @@
1
- # Temporary Holding Version
1
+ # Veyforma Charts
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Zero-dependency JavaScript charts for finance and risk teams.** Accessible, readable enough to edit, and nothing is sent to a server.
4
+
5
+ [![npm](https://img.shields.io/npm/v/@veyforma/charts)](https://www.npmjs.com/package/@veyforma/charts)
6
+ [![gzip size](https://img.shields.io/badge/gzip-42%20KB%20all%20three-informational)](dist/)
7
+ [![license](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
8
+
9
+ [![Exposure heatmap and risk-factor tornado](docs/hero.png)](https://veyforma.github.io/veyforma-charts/examples/)
10
+
11
+ General charting libraries give you bars and lines. Risk and finance teams need charts built around the questions they actually ask: *where is credit exposure concentrated?*, *which risk factors move P&L?*, *why doesn't the risk model's P&L match the front office's?* This package answers those three, in plain JavaScript, with no build step.
12
+
13
+ **[See the live demos →](https://veyforma.github.io/veyforma-charts/examples/)**
14
+
15
+ ## Charts
16
+
17
+ | Chart | Answers | Size (gzip) | Demo |
18
+ |---|---|---|---|
19
+ | **Exposure Heatmap** | Where is exposure concentrated, by sector × country, sector × rating or any two fields? Sums loan-level records in the browser and outlines cells above your limit. | 12.5 KB | [Live](https://veyforma.github.io/veyforma-charts/examples/heatmap.html) |
20
+ | **Risk-Factor Tornado** | Which risk factors move P&L, economic value or capital the most? Down and up shocks, convexity, loss limits, groups and correlated contributions. | 15.3 KB | [Live](https://veyforma.github.io/veyforma-charts/examples/tornado.html) |
21
+ | **P&L Attribution** | Does the desk pass the FRTB P&L attribution test? HPL vs RTPL by factor, Spearman and KS zones, and the shortest path of fixes back to green. | 15.3 KB | [Live](https://veyforma.github.io/veyforma-charts/examples/pla-attribution.html) |
22
+
23
+ Every chart has keyboard-usable controls, tooltips on hover, tap and focus, a screen-reader description, and a built-in "How to read this chart" note.
24
+
25
+ **Fast:** in our tests the heatmap summed and drew 1,000,000 records in about 0.1 s (Chrome). [Try it in the demo](https://veyforma.github.io/veyforma-charts/examples/heatmap.html).
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ npm install @veyforma/charts
31
+ ```
32
+
33
+ Or with no install, from a CDN: load all three, or only the chart you need.
34
+
35
+ ```html
36
+ <!-- all three charts -->
37
+ <script src="https://cdn.jsdelivr.net/npm/@veyforma/charts/dist/veyforma-charts.min.js"></script>
38
+
39
+ <!-- or one chart -->
40
+ <script src="https://cdn.jsdelivr.net/npm/@veyforma/charts/dist/veyforma-heatmap.min.js"></script>
41
+ ```
42
+
43
+ ## Quick start
44
+
45
+ ```html
46
+ <div id="chart"></div>
47
+ <script src="https://cdn.jsdelivr.net/npm/@veyforma/charts/dist/veyforma-heatmap.min.js"></script>
48
+ <script>
49
+ VeyHeatmap.create("#chart", {
50
+ data: {
51
+ title: "Loan exposure by sector and country",
52
+ prefix: "$", suffix: "m",
53
+ rowTitle: "Sector", columnTitle: "Country",
54
+ rowLabels: ["Real estate", "Energy", "Retail", "Technology"],
55
+ columnLabels: ["United Kingdom", "Germany", "France", "United States"],
56
+ values: [
57
+ [820, 310, 150, 240],
58
+ [120, 260, 90, 610],
59
+ [300, 180, 220, 60],
60
+ [140, 90, 70, 380]
61
+ ],
62
+ limit: { share: 0.1 } // outline any cell above 10% of the total
63
+ }
64
+ });
65
+ </script>
66
+ ```
67
+
68
+ With a bundler:
69
+
70
+ ```js
71
+ import VeyformaCharts from "@veyforma/charts";
72
+
73
+ const chart = VeyformaCharts.heatmap(document.getElementById("chart"), { data });
74
+ chart.update({ valueMode: "shareOfRow" }); // change any option
75
+ chart.destroy(); // remove listeners and DOM
76
+ ```
77
+
78
+ Pass any DOM element or CSS selector, so it works in plain HTML, React, Vue, Angular and Svelte. Importing on the server is safe: nothing touches the DOM until you call `create`.
79
+
80
+ ## The three charts
81
+
82
+ ### Exposure Heatmap: `VeyHeatmap.create(el, options)`
83
+
84
+ Give either a ready-made grid (`values`, `rowLabels`, `columnLabels`) or loan-level `records` with any fields. The chart sums the records for whichever two fields you choose, and caches the sums so switching views is instant.
85
+
86
+ ```js
87
+ VeyHeatmap.create("#chart", {
88
+ data: {
89
+ prefix: "$", suffix: "m",
90
+ records: loans, // [{ sector: "Energy", country: "Germany", rating: "BBB", value: 12.5 }, …]
91
+ rows: "sector", columns: "country",
92
+ dimensions: { rating: { label: "Rating", order: ["AAA", "AA", "A", "BBB", "BB", "B", "CCC"], ordered: true } },
93
+ limit: { share: 0.08 }
94
+ },
95
+ valueMode: "amount" // "amount", "shareOfTotal", "shareOfRow" or "shareOfColumn"
96
+ });
97
+ ```
98
+
99
+ | Option | Default | What it does |
100
+ |---|---|---|
101
+ | `rows`, `columns` | from `data` | Fields to show as rows and columns |
102
+ | `valueMode` | `"amount"` | Amount, or share of total, row or column |
103
+ | `scale` | `"linear"` | `"sqrt"` brings out small values |
104
+ | `limit` | from `data` | Concentration limit as a share of total, e.g. `0.05` |
105
+ | `topRows`, `topColumns` | `0` | Keep the largest N and group the rest as "Other" |
106
+ | `sortRows`, `sortColumns` | `"auto"` | `"total"` or `"natural"` |
107
+ | `theme` | `"veyforma"` | Theme name or object; add your own with `VeyHeatmap.registerTheme` |
108
+ | `onClick` | none | `function (cell, event)` |
109
+
110
+ ### Risk-Factor Tornado: `VeyRiskTornado.create(el, options)`
111
+
112
+ Each factor gives either a delta and gamma with a shock size (Taylor), or the down and up results of a full revaluation.
113
+
114
+ ```js
115
+ VeyRiskTornado.create("#chart", {
116
+ data: {
117
+ prefix: "$", suffix: "m", decimals: 2, limit: 1.5,
118
+ correlation: { within: 0.7, across: 0.25 }, // for the contribution view
119
+ factors: [
120
+ { label: "USD 10Y rate", group: "Rates", unit: "bp", shock: 25, delta: -0.064, gamma: 0.0006 },
121
+ { label: "EUR/USD", group: "FX", unit: "%", shockDown: -5, shockUp: 5, down: -0.48, up: 0.39 }
122
+ ]
123
+ }
124
+ });
125
+ ```
126
+
127
+ | Option | Default | What it does |
128
+ |---|---|---|
129
+ | `view` | `"factors"` | `"factors"`, `"groups"` or `"contribution"` |
130
+ | `sort` | `"swing"` | Rank by `"swing"` or `"worst"` result |
131
+ | `top` | `15` | Rows shown before the rest are summed into "Other" |
132
+ | `shockScale` | `1` | Multiply every shock, e.g. `2` for double |
133
+ | `whatIf` | none | Scale positions by factor or group, e.g. `{ "FX": 0 }` |
134
+ | `onItemClick` | none | `function (detail, event)` |
135
+
136
+ For capital, where lower is better, add `higherIsBetter: false` to `data`. `VeyRiskTornado.compute(data, opts)` returns every figure without drawing.
137
+
138
+ ### P&L Attribution: `VeyPlaAttribution.create(el, options)`
139
+
140
+ Give one HPL and one RTPL value per date for each risk factor. Leave `rtpl` out for a factor the risk model doesn't have.
141
+
142
+ ```js
143
+ VeyPlaAttribution.create("#chart", {
144
+ window: 250,
145
+ data: {
146
+ prefix: "$", suffix: "m", decimals: 2,
147
+ dates: ["2026-09-28", "2026-09-29", "2026-09-30" /* … */],
148
+ factors: [
149
+ { label: "EUR 10Y", hpl: [0.42, -0.31, 0.18], rtpl: [0.40, -0.30, 0.19] },
150
+ { label: "Vol smile", hpl: [0.05, 0.07, -0.03] }
151
+ ]
152
+ }
153
+ });
154
+ ```
155
+
156
+ | Option | Default | What it does |
157
+ |---|---|---|
158
+ | `view` | `"factors"` | `"factors"`, `"daily"` or `"distribution"` |
159
+ | `window` | `250` | Test window in days (the most recent ones) |
160
+ | `fix` | none | Factors to treat as fixed (RTPL = HPL), e.g. `["Basis"]` |
161
+ | `thresholds` | Basel | `{ spearmanGreen, spearmanRed, ksGreen, ksRed }` |
162
+
163
+ Zones follow the Basel PLA test: green if Spearman > 0.80 and KS < 0.09, red if Spearman < 0.70 or KS > 0.12, otherwise amber. `VeyPlaAttribution.test(hpl, rtpl)` runs the test on two series.
164
+
165
+ ### Shared methods
166
+
167
+ Every chart returns an instance with `update(options)`, `setData(data)`, `setTheme(theme)`, `describe()` (a plain-language summary), `createTable()` (an accessible data table) and `destroy()`.
168
+
169
+ ## Chart menu and exports
170
+
171
+ The charts work fully on their own. The optional **Veyforma Toolkit** adds a chart menu with full screen, print, PNG, JPEG, SVG, PDF, CSV and Excel downloads, copy to clipboard and pinned notes. It's included in the free downloads on [veyforma.com](https://www.veyforma.com) (sign-in required), together with more sample data and a developer manual for each chart. Load it before the chart script and the menu appears automatically.
172
+
173
+ ## Browser support
174
+
175
+ All evergreen browsers: Chrome, Edge, Firefox and Safari.
176
+
177
+ ## More from Veyforma
178
+
179
+ These charts come from the [Veyforma Chart Library](https://www.veyforma.com), which has more risk and finance charts and complete dashboard prototypes for credit risk, market risk, capital and liquidity.
180
+
181
+ ## Contributing
182
+
183
+ Bug reports and chart requests are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md).
184
+
185
+ ## License
186
+
187
+ [MIT](LICENSE) © 2026 Veyforma