@praxisui/charts 9.0.0-beta.1 → 9.0.0-beta.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.
Files changed (2) hide show
  1. package/README.md +57 -357
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,30 +1,8 @@
1
1
  # @praxisui/charts
2
2
 
3
- > Metadata-driven charting for Praxis UI Angular, with a stable public contract and an engine adapter boundary.
3
+ Metadata-driven charting for Praxis UI Angular applications. Install `@praxisui/charts` when a host needs declarative analytics widgets aligned with the Praxis runtime instead of passing raw chart-engine options through the public API.
4
4
 
5
- ## Documentation
6
-
7
- - Official documentation: https://praxisui.dev/components/charts
8
- - Quickstart reference app: https://github.com/codexrodrigues/praxis-ui-quickstart
9
- - Live Praxis UI demo: https://praxis-ui-4e602.web.app
10
- - Recommended for: Angular hosts that need declarative analytics widgets aligned with the `@praxisui/*` runtime
11
-
12
- ## What this package provides
13
-
14
- - `PraxisChartComponent` for standalone chart rendering
15
- - `PraxisChartConfigEditor` as the initial authoring shell for canonical `x-ui.chart` documents
16
- - optional runtime authoring bridge from `PraxisChartComponent` into the chart config editor when the host provides a settings-panel bridge
17
- - typed chart contracts for config, datasets, events and widget mapping
18
- - internal Apache ECharts adapter behind a Praxis engine interface
19
- - built-in `loading`, `empty` and `error` states
20
- - mapping from canonical `x-ui.chart` contracts into Praxis widget/page structures
21
- - support services for backend payload adaptation, stats requests and chart option building
22
-
23
- ## Why this package exists
24
-
25
- - keep the public API business-oriented instead of exposing raw engine options as the main contract
26
- - preserve the option to swap the rendering engine later without rewriting host integrations
27
- - align charts with the same metadata-driven model used by the rest of the Praxis UI platform
5
+ The package renders `PraxisChartConfig` and canonical `x-ui.chart` documents through a Praxis engine boundary. Apache ECharts is the current adapter implementation, but host integrations should depend on Praxis contracts.
28
6
 
29
7
  ## Install
30
8
 
@@ -33,25 +11,37 @@ npm i @praxisui/charts@latest
33
11
  ```
34
12
 
35
13
  Peer dependencies:
36
- - `@angular/core` `^21.0.0`
37
- - `@angular/common` `^21.0.0`
38
- - `@angular/forms` `^21.0.0`
39
- - `@angular/material` `^21.0.0`
14
+
15
+ - `@angular/common`, `@angular/core`, `@angular/forms`, `@angular/material` `^21.0.0`
40
16
  - `@praxisui/core` `^9.0.0-beta.1`
41
17
  - `@praxisui/table` `^9.0.0-beta.1`
42
18
  - `rxjs` `~7.8.0`
43
19
 
44
- Runtime dependency included by this package:
20
+ Runtime dependency included by the package:
21
+
45
22
  - `echarts` `^6.0.0`
46
23
 
47
- ## Quick Start
24
+ ## App Providers
25
+
26
+ Register the chart engine and component metadata once in the host application.
27
+
28
+ ```ts
29
+ import { ApplicationConfig } from '@angular/core';
30
+ import { providePraxisCharts } from '@praxisui/charts';
31
+
32
+ export const appConfig: ApplicationConfig = {
33
+ providers: [providePraxisCharts()],
34
+ };
35
+ ```
36
+
37
+ ## Standalone Chart
48
38
 
49
39
  ```ts
50
40
  import { Component } from '@angular/core';
51
41
  import {
52
42
  PraxisChartComponent,
53
- type PraxisChartPointEvent,
54
43
  type PraxisChartConfig,
44
+ type PraxisChartPointEvent,
55
45
  } from '@praxisui/charts';
56
46
 
57
47
  @Component({
@@ -62,14 +52,12 @@ import {
62
52
  <praxis-chart
63
53
  [config]="config"
64
54
  (pointClick)="onPointClick($event)"
65
- (selectionChange)="onSelectionChange($event)"
66
- (crossFilter)="onCrossFilter($event)"
67
- ></praxis-chart>
55
+ />
68
56
  `,
69
57
  })
70
58
  export class ChartDemoComponent {
71
59
  readonly config: PraxisChartConfig = {
72
- title: 'Employees by Department',
60
+ title: 'Employees by department',
73
61
  type: 'bar',
74
62
  dataSource: {
75
63
  kind: 'local',
@@ -80,365 +68,77 @@ export class ChartDemoComponent {
80
68
  ],
81
69
  },
82
70
  axes: {
83
- x: {
84
- field: 'department',
85
- type: 'category',
86
- label: 'Department',
87
- },
88
- y: {
89
- field: 'total',
90
- type: 'value',
91
- label: 'Employees',
92
- },
71
+ x: { field: 'department', type: 'category', label: 'Department' },
72
+ y: { field: 'total', type: 'value', label: 'Employees' },
93
73
  },
94
74
  series: [
95
75
  {
96
76
  id: 'employees',
97
77
  type: 'bar',
98
- metric: {
99
- field: 'total',
100
- aggregation: 'sum',
101
- },
78
+ metric: { field: 'total', aggregation: 'sum' },
102
79
  name: 'Employees',
103
80
  },
104
81
  ],
105
- interactions: {
106
- pointClick: true,
107
- selection: true,
108
- crossFilter: true,
109
- eventActions: {
110
- selectionChange: {
111
- action: 'emit',
112
- mapping: {
113
- department: 'department',
114
- },
115
- },
116
- crossFilter: {
117
- action: 'filter-widget',
118
- target: 'employeesTable',
119
- mapping: {
120
- department: 'department',
121
- },
122
- },
123
- },
124
- },
125
82
  };
126
83
 
127
- onPointClick(event: PraxisChartPointEvent) {
84
+ onPointClick(event: PraxisChartPointEvent): void {
128
85
  console.log('chart point', event);
129
86
  }
130
-
131
- onSelectionChange(event: unknown) {
132
- console.log('chart selection', event);
133
- }
134
-
135
- onCrossFilter(event: unknown) {
136
- console.log('chart filters', event);
137
- }
138
87
  }
139
88
  ```
140
89
 
141
- ## Public Surface Highlights
142
-
143
- - standalone components for charts, drilldown panel and runtime probe
144
- - the initial standalone chart config editor shell for `x-ui.chart`
145
- - chart contracts such as `PraxisChartConfig`, `PraxisChartDataSource`, `PraxisChartPointEvent`, `PraxisChartSelectionEvent` and `PraxisChartCrossFilterEvent`
146
- - providers and tokens for chart engine composition
147
- - services for canonical mapping, backend payload adaptation and option building
148
-
149
- See the public exports in `projects/praxis-charts/src/public-api.ts`.
90
+ ## Runtime Contract
150
91
 
151
- ## Runtime Model
92
+ Use the component with either local data or governed remote execution:
152
93
 
153
- O runtime de `@praxisui/charts` opera em duas trilhas principais:
94
+ - `dataSource.kind = 'local'`: the chart consumes rows supplied in `dataSource.items` or the `data` input.
95
+ - `dataSource.kind = 'remote'`: the chart emits `queryRequest`, then uses a host `remoteDataResolver` or the default `PraxisChartStatsApiService` path for `praxis.stats`.
96
+ - `queryContext`: primary input for dynamic-page orchestration; filters, sort and limit are merged into remote requests where supported.
97
+ - `filterCriteria`: accepted as a compatibility bridge, but new integrations should use `queryContext`.
154
98
 
155
- - `dataSource.kind = "local"` para datasets entregues diretamente ao componente
156
- - `dataSource.kind = "remote"` para datasets remotos, com foco canônico em `praxis.stats`
157
-
158
- No modo remoto, o componente:
159
-
160
- - emite `queryRequest`
161
- - usa `remoteDataResolver` quando o host fornece um resolvedor governado
162
- - usa `PraxisChartStatsApiService` como resolvedor padrão para `praxis.stats`
163
- - transforma a resposta agregada em `PraxisChartDataRow[]`
164
- - renderiza o estado `loading`, `empty`, `error` ou `ready`
165
-
166
- ## Sizing Modes
167
-
168
- Charts expose sizing as canonical contract, not as host CSS. New chart documents
169
- should use `sizing` instead of the legacy top-level `height` property.
170
-
171
- ```ts
172
- const chartDocument: PraxisXUiChartContract = {
173
- version: '0.1.0',
174
- kind: 'bar',
175
- chartId: 'status-by-team',
176
- sizing: {
177
- mode: 'fill-container',
178
- minHeight: 160,
179
- },
180
- source: { kind: 'derived' },
181
- dimensions: [{ field: 'team' }],
182
- metrics: [{ field: 'total', aggregation: 'count' }],
183
- };
99
+ ```html
100
+ <praxis-chart
101
+ [config]="chartConfig"
102
+ [queryContext]="{
103
+ filters: { departmentId: 10, status: 'ACTIVE' },
104
+ sort: ['competencia,asc'],
105
+ limit: 12
106
+ }"
107
+ />
184
108
  ```
185
109
 
186
- Supported modes:
187
-
188
- - `fixed`: uses `sizing.height`; use it for standalone charts with deliberate fixed height.
189
- - `fill-container`: fills the usable body of a widget shell or another container with a defined height.
190
- - `auto`: lets the chart content define its natural height.
191
-
192
- Sizing values may be numbers or CSS lengths. Numeric editor input is normalized
193
- to pixels before the runtime applies styles, so `height: 320` and an editor
194
- value of `320` both resolve to `320px`. `minHeight` and `maxHeight` constrain
195
- the chart shell, and `aspectRatio` may be a positive number or CSS ratio such
196
- as `16 / 9`.
197
-
198
- For corporate dashboards and resizable widget canvases, prefer
199
- `sizing.mode = "fill-container"` plus a documented `minHeight`. The containing
200
- widget shell should provide a fill body layout, otherwise the chart cannot infer
201
- a stable vertical area from CSS alone. Legacy `height` is normalized as
202
- `sizing: { mode: "fixed", height }` in the canonical mapper only as a migration
203
- bridge for existing beta payloads.
110
+ The public contract is `PraxisChartConfig` or the canonical `PraxisXUiChartContract`; raw ECharts options are adapter detail, not the host-facing model.
204
111
 
205
- ## Surface Modes
112
+ ## Canonical Chart Documents
206
113
 
207
- Chart visual surface is also part of the canonical contract. Hosts should not
208
- override the internal chart shell with ad hoc CSS when the intent is business
209
- semantics such as embedded dashboard rendering versus standalone rendering.
114
+ New `x-ui.chart` documents should describe sizing, surface mode, source, dimensions and metrics declaratively.
210
115
 
211
116
  ```ts
212
117
  const chartDocument: PraxisXUiChartContract = {
213
118
  version: '0.1.0',
214
119
  kind: 'bar',
215
120
  chartId: 'status-by-team',
216
- sizing: {
217
- mode: 'fill-container',
218
- minHeight: 160,
219
- },
220
- theme: {
221
- surface: {
222
- mode: 'embedded',
223
- },
224
- },
121
+ sizing: { mode: 'fill-container', minHeight: 160 },
122
+ theme: { surface: { mode: 'embedded' } },
225
123
  source: { kind: 'derived' },
226
124
  dimensions: [{ field: 'team' }],
227
125
  metrics: [{ field: 'total', aggregation: 'count' }],
228
126
  };
229
127
  ```
230
128
 
231
- Supported surface modes:
232
-
233
- - `auto`: default; standalone charts use a contained neutral surface, while charts inside `WidgetShell` render embedded.
234
- - `embedded`: no internal card chrome; use it for corporate dashboards where `WidgetShell` owns the card, header, border and fullscreen behavior.
235
- - `contained`: the chart owns its visual surface; use it only for standalone chart placement outside a widget shell.
236
-
237
- For enterprise dashboards, prefer `theme.surface.mode = "embedded"` or the
238
- default `auto` inside `WidgetShell`. This avoids nested cards, duplicated
239
- rounded corners and decorative gradients competing with operational data.
240
-
241
- ## Declarative Query Contract
242
-
243
- For dynamic pages and widget orchestration, the primary public input for remote chart queries is `queryContext`.
244
-
245
- ```html
246
- <praxis-chart
247
- [config]="chartConfig"
248
- [queryContext]="{
249
- filters: { departmentId: 10, status: 'ACTIVE' },
250
- sort: ['competencia,asc'],
251
- limit: 12
252
- }"
253
- ></praxis-chart>
254
- ```
255
-
256
- Current rules:
257
-
258
- - `queryContext.filters` is merged into remote datasource requests
259
- - `queryContext.sort` and `queryContext.limit` are also propagated when the datasource path supports them
260
- - `filterCriteria` is still accepted as a legacy compatibility bridge
261
- - for new authoring, `DynamicPage` connections and examples, prefer `queryContext`
262
-
263
- ### Versão Pedagógica de Alto Nível
264
-
265
- Esta é a leitura adequada para documentação pública e landing pages.
266
-
267
- ```mermaid
268
- sequenceDiagram
269
- participant Host as Host
270
- participant Chart as praxis-chart
271
- participant Stats as PraxisChartStatsApiService
272
- participant Backend as API Praxis Stats
273
-
274
- Host->>Chart: fornece config local ou remote
275
- alt fonte local
276
- Chart->>Chart: transforma dados locais e renderiza
277
- else fonte remota
278
- Chart-->>Host: emite queryRequest
279
- Chart->>Stats: executa consulta praxis.stats
280
- Stats->>Backend: POST /stats/*
281
- Backend-->>Stats: retorna buckets/pontos agregados
282
- Stats-->>Chart: entrega linhas canônicas
283
- Chart->>Chart: renderiza loading, ready, empty ou error
284
- end
285
- ```
286
-
287
- Leitura pedagógica:
288
-
289
- 1. **O host entrega um contrato declarativo**, não opções brutas do engine.
290
- 2. **O componente resolve a fonte de dados**: local ou remota.
291
- 3. **Quando a fonte é remota, a integração canônica é `praxis.stats`**.
292
- 4. **O chart renderiza estados de UX e a visualização final a partir de linhas canônicas**.
293
-
294
- ### Versão Detalhada do Fluxo Canônico
295
-
296
- ```mermaid
297
- sequenceDiagram
298
- participant Host as Host
299
- participant Chart as PraxisChartComponent
300
- participant Mapper as Canonical Mapper / config remoto
301
- participant Stats as PraxisChartStatsApiService
302
- participant Backend as API /stats
303
- participant Engine as Chart Engine Adapter
304
-
305
- Host->>Chart: [config] e opcionalmente [data]
306
- alt data explicito fornecido
307
- Chart->>Chart: resolvedData = data input
308
- else fonte local
309
- Chart->>Chart: resolvedData = dataSource.items
310
- else fonte remote
311
- Chart->>Chart: buildRemoteSignature(config)
312
- Chart-->>Host: queryRequest({ chartId, dataSource, query })
313
- Chart->>Stats: execute(event, config)
314
- Stats->>Stats: valida statsPath + statsRequest
315
- Stats->>Backend: POST {statsPath}
316
- Backend-->>Stats: envelope com data agregada
317
- Stats->>Stats: converte buckets/points em PraxisChartDataRow[]
318
- Stats-->>Chart: rows remotas resolvidas
319
- end
320
-
321
- Chart->>Chart: resolve loadState (loading/empty/error/ready)
322
- alt ready
323
- Chart->>Engine: render(host, { config, data })
324
- else not ready
325
- Chart->>Engine: destroy()
326
- end
327
- ```
328
-
329
- ### Restrições do Contrato Canônico
330
-
331
- O mapper `x-ui.chart -> PraxisChartConfig` aplica as restrições públicas abaixo:
332
-
333
- - `source.kind` aceitos: `praxis.stats` e `derived`
334
- - `source.kind = "praxis.stats"` exige `source.resource` e `source.operation`
335
- - agregações aceitas: `count`, `distinct-count`, `sum`, `avg`, `min`, `max`
336
- - `source.options.granularity` em `timeseries` aceita `day`, `week` e `month`
337
- - charts `pie` e `donut` aceitam apenas uma métrica
338
- - charts cartesianos `praxis.stats` podem declarar múltiplas métricas apenas em `group-by` e `timeseries`
339
- - `distribution` aceita apenas uma métrica
340
- - `combo` exige pelo menos duas métricas e, no modo `praxis.stats`, suporta apenas `group-by` ou `timeseries`
341
- - `axis: "secondary"` é exclusivo de `combo`
342
- - `selectionChange` e `crossFilter` declarativos geram payloads canônicos derivados da seleção de ponto
343
- - `events.*.mapping` remapeia campos do ponto selecionado para os nomes de filtro esperados pelo host
344
- - `theme.variant` aceita `default`, `compact` e `executive`
345
- - `theme.palette` aceita array explícito de cores ou os tokens registrados `brand-primary`, `brand-balanced`, `status` e `executive`
346
- - campos explícitos de `theme.surface` têm precedência sobre os defaults aplicados por `theme.variant`
347
-
348
- ## Fluxo Canonico de `praxis.stats`
349
-
350
- Quando o contrato remoto vem do mapper canônico, o caminho gerado segue a forma:
351
-
352
- - `{resourcePath}/stats/group-by`
353
- - `{resourcePath}/stats/timeseries`
354
- - `{resourcePath}/stats/distribution`
355
-
356
- O `PraxisChartStatsApiService`:
357
-
358
- - monta a URL final usando `API_URL`
359
- - normaliza o path remoto
360
- - envia `statsRequest` via `POST`
361
- - converte buckets/pontos em linhas canônicas para o runtime do chart
362
-
363
- Observação importante:
364
-
365
- - a integração remota usa envelope com `data`
366
- - `queryRequest` é emitido para observabilidade do host antes da execução remota
367
- - `remoteDataResolver` permite que o host assuma a execução remota e entregue `PraxisChartDataRow[]`
368
- - sem `remoteDataResolver`, a execução remota padrão permanece limitada a `praxis.stats`
369
- - a trilha canônica `x-ui.chart -> PraxisChartConfig -> praxis.stats` já promove múltiplas métricas para charts cartesianos suportados; para evitar semântica enganosa, `combo` segue sendo o único caso com eixo secundário e mistura heterogênea de séries
370
-
371
- ## Current Scope
372
-
373
- This first published version is focused on the core runtime:
374
-
375
- - the `praxis-chart` component
376
- - canonical chart contracts and runtime models
377
- - the initial ECharts-based engine adapter
378
- - metadata and mapping hooks for registry and dynamic widget composition
379
- - remote execution focused on canonical `praxis.stats`
380
- - basic settings-panel-compatible authoring shell focused on canonical `x-ui.chart`
381
- - optional runtime edit affordance in `PraxisChartComponent` when `chartDocument` and a settings-panel bridge are available
382
- - canonical theme variants and registered palette tokens for `x-ui.chart`
383
- - declarative `selectionChange` and `crossFilter` actions emitted from selected chart points
384
- - `distinct-count` aggregation mapped to canonical `praxis.stats` `DISTINCT_COUNT`
385
- - host-owned remote data resolution through `remoteDataResolver`
386
- - executable agentic authoring manifest for `praxis-chart`, exported as `PRAXIS_CHARTS_AUTHORING_MANIFEST`
387
-
388
- ## Agentic Authoring Contract
389
-
390
- `@praxisui/charts` publishes a component-level authoring manifest for `praxis-chart`.
391
- The manifest is an executable backend/tooling contract for canonical
392
- `PraxisXUiChartContract` documents, not prompt-routing documentation.
393
-
394
- The governed authoring targets are:
395
-
396
- - `chartType`
397
- - `series`
398
- - `axis`
399
- - `dataBinding`
400
- - `queryContext`
401
- - `crossFilter`
402
- - `drilldown`
403
- - `selection`
404
- - `legend`
405
- - `tooltip`
406
-
407
- Remote resource and field binding must come from governed API metadata,
408
- `availableResources` and `availableFields`. Cross-filter, drilldown and
409
- selection authoring persists structured `events.*` actions instead of command
410
- strings or raw prompt examples. The visual editor remains the canonical
411
- round-trip surface for this document: open, edit, apply/save, reset and reopen
412
- must preserve the same `x-ui.chart` shape consumed by the runtime.
413
-
414
- Each manifest operation declares its own editable target, resolver,
415
- ambiguity policy, preconditions, validators, affected paths, effects and
416
- `submissionImpact`. Chart document, type, series and axis changes are
417
- `config-only`; remote data binding, query context and event mappings
418
- `affect-remote-binding`; legend and tooltip changes are `visual-only`.
419
-
420
- ## Current Non-Goals
421
-
422
- The public chart contract keeps these concerns outside the stable surface:
423
-
424
- - direct host control over raw ECharts options as the primary contract
129
+ Supported sizing modes are `fixed`, `fill-container` and `auto`. Prefer `fill-container` inside dashboard widget shells. Supported surface modes are `auto`, `embedded` and `contained`; prefer `embedded` when another shell owns the card, header or border.
425
130
 
426
- ## Notes for Hosts
131
+ ## Authoring Surface
427
132
 
428
- - the package is designed for the Praxis platform model, where chart semantics live in canonical contracts and not in engine-specific payloads
429
- - if you are integrating charts into dynamic pages or widget shells, prefer the exported Praxis contracts and mappers over direct engine customization
430
- - if you need raw ECharts tuning, treat it as adapter-level implementation detail unless the contract is promoted to the public surface intentionally
133
+ `PraxisChartConfigEditor` is the initial editor shell for canonical `x-ui.chart` documents. It expects governed resources, fields and targets from the host and emits structured apply/save/reset events. The authoring manifest is exported as `PRAXIS_CHARTS_AUTHORING_MANIFEST` for backend/tooling workflows that need executable chart-edit operations.
431
134
 
432
- ## Reusable `x-ui.analytics` Runtime Pattern
135
+ ## Public API Snapshot
433
136
 
434
- When the backend publishes `x-ui.analytics.projections[]`, the reusable platform path is now:
137
+ Main exports include `PraxisChartComponent`, `PraxisChartConfigEditor`, chart event/config models, `PraxisXUiChartContract`, engine adapter tokens, `providePraxisCharts`, canonical mapping/normalization/validation services, analytics chart services, chart metadata and `PRAXIS_CHARTS_AUTHORING_MANIFEST`.
435
138
 
436
- 1. `@praxisui/core` resolves the contract with `AnalyticsSchemaContractService`
437
- 2. `AnalyticsPresentationResolver` chooses the presentation family
438
- 3. `AnalyticsChartContractService` in `@praxisui/charts` materializes the selected projection into `PraxisChartConfig`
139
+ ## Official Links
439
140
 
440
- This keeps chart hosts out of the business of:
441
- - calling `/schemas/filtered` manually
442
- - parsing `x-ui.analytics` by hand
443
- - selecting projections ad hoc
444
- - rebuilding the chart contract pipeline inside each app
141
+ - Documentation: https://praxisui.dev/components/charts
142
+ - Live demo: https://praxis-ui-4e602.web.app
143
+ - Quickstart repository: https://github.com/codexrodrigues/praxis-ui-quickstart
144
+ - Source and issues: https://github.com/codexrodrigues/praxis-ui-angular
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@praxisui/charts",
3
- "version": "9.0.0-beta.1",
3
+ "version": "9.0.0-beta.2",
4
4
  "description": "Metadata-driven charts library for Praxis UI Angular with engine adapters and Apache ECharts as the initial renderer.",
5
5
  "peerDependencies": {
6
6
  "@angular/common": "^21.0.0",
7
7
  "@angular/core": "^21.0.0",
8
- "@praxisui/core": "^9.0.0-beta.1",
8
+ "@praxisui/core": "^9.0.0-beta.2",
9
9
  "@angular/forms": "^21.0.0",
10
10
  "@angular/material": "^21.0.0",
11
- "@praxisui/table": "^9.0.0-beta.1",
11
+ "@praxisui/table": "^9.0.0-beta.2",
12
12
  "rxjs": "~7.8.0"
13
13
  },
14
14
  "dependencies": {