@jarenjs/charts 0.67.0 → 0.72.2

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 CHANGED
@@ -302,14 +302,14 @@ Measured (`npm run benchmark:charts`, one appended point):
302
302
  <!--fact:charts.sessionTable-->
303
303
  | points × series | session tick | wholesale tick | frames incremental |
304
304
  |---|---:|---:|---:|
305
- | 100 × 5 | 6.26 µs | 301 µs | 1100 of 1100 |
306
- | 1,000 × 5 | 4.84 µs | 1.1 ms | 1100 of 1100 |
307
- | 10,000 × 5 | 4.44 µs | 8.61 ms | 1100 of 1100 |
308
- | 10,000 × 5 *(sampled)* | 3.25 ms | 2.53 ms | 0 of 1100 |
305
+ | 100 × 5 | 5.82 µs | 306 µs | 1100 of 1100 |
306
+ | 1,000 × 5 | 5.5 µs | 1 ms | 1100 of 1100 |
307
+ | 10,000 × 5 | 7.9 µs | 8.41 ms | 1100 of 1100 |
308
+ | 10,000 × 5 *(sampled)* | 2.5 ms | 2.52 ms | 0 of 1100 |
309
309
  <!--/fact-->
310
310
 
311
311
  The session tick is *flat* in n — it
312
- moves <!--fact:charts.sessionFlatness-->0.7× while the wholesale tick grows 28.6×<!--/fact-->. Supported types: `line` (appends
312
+ moves <!--fact:charts.sessionFlatness-->1.4× while the wholesale tick grows 27.4×<!--/fact-->. Supported types: `line` (appends
313
313
  and ring-buffer evictions), `bar` (live counts and sums) and
314
314
  `candlestick` (keyed kline upserts — one candle group re-renders). The
315
315
  website's Binance demo runs on it.
@@ -382,14 +382,14 @@ Measured (`npm run benchmark:charts`, one series):
382
382
  <!--fact:charts.samplingTable-->
383
383
  | source points | drawn | method | source → AST | source → svg |
384
384
  |---:|---:|---|---:|---:|
385
- | 2,000 | 2,000 | none | 73.4 µs → 72.3 µs | 587 µs → 515 µs |
386
- | 20,000 | 560 | lttb | 838 µs → 1.28 ms | 5.84 ms → 1.05 ms |
387
- | 100,000 | 560 | lttb | 4.35 ms → 5.36 ms | 27.8 ms → 5.42 ms |
385
+ | 2,000 | 2,000 | none | 77.1 µs → 71.5 µs | 512 µs → 518 µs |
386
+ | 20,000 | 560 | lttb | 672 µs → 911 µs | 5.94 ms → 1.06 ms |
387
+ | 100,000 | 560 | lttb | 4.08 ms → 5.33 ms | 28.3 ms → 6.61 ms |
388
388
  <!--/fact-->
389
389
 
390
390
  Choosing the points costs about what mapping them costs — the sampler
391
391
  reads every reading either way — so the AST column is a small **loss**.
392
- What it buys is the render — <!--fact:charts.samplingWin-->100,000 points draw as 560 and render 5.1× faster<!--/fact-->. The invariants above are asserted in the benchmark
392
+ What it buys is the render — <!--fact:charts.samplingWin-->100,000 points draw as 560 and render 4.3× faster<!--/fact-->. The invariants above are asserted in the benchmark
393
393
  before a single timing is printed.
394
394
 
395
395
  **Sampling is not retention.** `createStreamAdapter`'s `maxPoints`
@@ -427,3 +427,6 @@ Every subpath a consumer can import, derived from the manifest by
427
427
  | `@jarenjs/charts/schemas/chart-definition.schema.json` | schema | — |
428
428
  | `@jarenjs/charts/package.json` | metadata | — |
429
429
  <!--/fact-->
430
+
431
+ Author definitions in code with the typed [chart pen](../../packages/linq/docs/CHARTS-PEN.md),
432
+ then pass its `.schema` directly to `compileChart`.
@@ -177,6 +177,14 @@ export declare function lineVertex(p: any, xDrop: number | null, xScale: (v: num
177
177
  * @returns {LineAST}
178
178
  */
179
179
  export declare function buildLineAST(data: any, config?: any): LineAST;
180
+ /** Build from the same resolved domains a session already used for its frame decision.
181
+ * Internal to the chart engine; public builds always scan their own input.
182
+ * @param {{name?: string, points: any[]}[]} input @param {any} config
183
+ * @param {ReturnType<typeof resolveLineDomains>} domains @returns {LineAST} */
184
+ export declare function buildLineASTResolved(input: {
185
+ name?: string;
186
+ points: any[];
187
+ }[], config: any, domains: ReturnType<typeof resolveLineDomains>): LineAST;
180
188
  export type LineSeriesRender = {
181
189
  /**
182
190
  * the series' `<g>` vnode
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jarenjs/charts",
3
3
  "private": false,
4
- "version": "0.67.0",
4
+ "version": "0.72.2",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
7
7
  "types": "./dist/types/index.d.ts",
@@ -70,7 +70,7 @@
70
70
  "prepack": "npm run build:types"
71
71
  },
72
72
  "dependencies": {
73
- "@jarenjs/core": "^0.67.0",
74
- "@jarenjs/view": "^0.67.0"
73
+ "@jarenjs/core": "^0.72.2",
74
+ "@jarenjs/view": "^0.72.2"
75
75
  }
76
76
  }
@@ -38,7 +38,7 @@ import {
38
38
  scanBarExtremes, resolveBarDomains, barScale,
39
39
  } from '../types/bar.js';
40
40
  import {
41
- buildLineAST, buildLineRender, scanLineExtremes, resolveLineDomains,
41
+ buildLineASTResolved, buildLineRender, scanLineExtremes, resolveLineDomains,
42
42
  lineScales, lineVertex, lineSeriesRender, lineSeriesChildren,
43
43
  } from '../types/line.js';
44
44
  import {
@@ -206,9 +206,10 @@ function createLineSession(config, source, options) {
206
206
  const input = (data?.series ?? []).filter((s) => Array.isArray(s.points));
207
207
  filteredSeries = input.length !== (data?.series ?? []).length;
208
208
  ext = scanLineExtremes(input, policy, log);
209
- ast = buildLineAST(data, config);
209
+ const domains = resolveLineDomains(ext, policy, time, log);
210
+ ast = buildLineASTResolved(input, config, domains);
210
211
  render = buildLineRender(ast, theme, hash, options);
211
- xDrop = resolveLineDomains(ext, policy, time, log).xDrop;
212
+ xDrop = domains.xDrop;
212
213
  vnode = render.svg;
213
214
  return { vnode, mode: /** @type {const} */ ('rebuilt') };
214
215
  }
package/src/types/line.js CHANGED
@@ -219,6 +219,16 @@ export function buildLineAST(data, config = {}) {
219
219
  const log = config.log === true;
220
220
  const policy = normalizeDomainPolicy(config.domain);
221
221
  const domains = resolveLineDomains(scanLineExtremes(input, policy, log), policy, time, log);
222
+ return buildLineASTResolved(input, config, domains);
223
+ }
224
+
225
+ /** Build from the same resolved domains a session already used for its frame decision.
226
+ * Internal to the chart engine; public builds always scan their own input.
227
+ * @param {{name?: string, points: any[]}[]} input @param {any} config
228
+ * @param {ReturnType<typeof resolveLineDomains>} domains @returns {LineAST} */
229
+ export function buildLineASTResolved(input, config, domains) {
230
+ const time = config.x === 'time';
231
+ const log = config.log === true;
222
232
  const { xScale, yScale } = lineScales(domains, time, log);
223
233
  const timeLabel = time
224
234
  ? compileTimeTickFormat({ dateNames: config.dateNames, timeFormats: config.timeFormats })