@aiconstructions/graficos 0.0.0-stage → 0.2.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/ALTERACOES.md +57 -0
- package/LICENSE-BKLIT +21 -0
- package/LICENSE-visx-pattern +21 -0
- package/README.md +189 -2
- package/dist/aic/cores.js +83 -0
- package/dist/aic/index.js +22 -0
- package/dist/aic/interacao.js +55 -0
- package/dist/charts/animation.js +55 -0
- package/dist/charts/arc-geometry.js +58 -0
- package/dist/charts/arc-path.js +15 -0
- package/dist/charts/area-chart-loading.js +89 -0
- package/dist/charts/area-chart.js +149 -0
- package/dist/charts/area-gradient-defs.js +90 -0
- package/dist/charts/area-value-label-layout.js +70 -0
- package/dist/charts/area-value-labels.js +211 -0
- package/dist/charts/area.js +272 -0
- package/dist/charts/background.js +198 -0
- package/dist/charts/band-config.js +82 -0
- package/dist/charts/band-geometry.js +186 -0
- package/dist/charts/band.js +346 -0
- package/dist/charts/bar-chart-loading.js +27 -0
- package/dist/charts/bar-chart.js +545 -0
- package/dist/charts/bar-depth-geometry.js +18 -0
- package/dist/charts/bar-depth.js +608 -0
- package/dist/charts/bar-lollipop.js +278 -0
- package/dist/charts/bar-squares-layout.js +66 -0
- package/dist/charts/bar-squares.js +467 -0
- package/dist/charts/bar-value-label-layout.js +42 -0
- package/dist/charts/bar-x-axis.js +133 -0
- package/dist/charts/bar-y-axis.js +116 -0
- package/dist/charts/bar.js +457 -0
- package/dist/charts/bollinger.js +49 -0
- package/dist/charts/candlestick-chart.js +370 -0
- package/dist/charts/candlestick.js +368 -0
- package/dist/charts/chart-brush-handle.js +91 -0
- package/dist/charts/chart-brush-layout.js +91 -0
- package/dist/charts/chart-brush-selection-overlay.js +87 -0
- package/dist/charts/chart-brush-state.js +253 -0
- package/dist/charts/chart-brush-track-overlay.js +103 -0
- package/dist/charts/chart-brush.js +517 -0
- package/dist/charts/chart-center-typography.js +8 -0
- package/dist/charts/chart-child-passthrough.js +119 -0
- package/dist/charts/chart-config-context.js +56 -0
- package/dist/charts/chart-context.js +337 -0
- package/dist/charts/chart-crosshair.js +262 -0
- package/dist/charts/chart-data-override.js +186 -0
- package/dist/charts/chart-defs.js +56 -0
- package/dist/charts/chart-formatters.js +77 -0
- package/dist/charts/chart-legend-hover.js +27 -0
- package/dist/charts/chart-legend.js +163 -0
- package/dist/charts/chart-loading-label.js +52 -0
- package/dist/charts/chart-parent-size.js +138 -0
- package/dist/charts/chart-phase.js +29 -0
- package/dist/charts/chart-reveal-clip.js +62 -0
- package/dist/charts/chart-scale.js +19 -0
- package/dist/charts/chart-stat-flow.js +72 -0
- package/dist/charts/choropleth/choropleth-background.js +29 -0
- package/dist/charts/choropleth/choropleth-camera.js +379 -0
- package/dist/charts/choropleth/choropleth-chart.js +644 -0
- package/dist/charts/choropleth/choropleth-context.js +152 -0
- package/dist/charts/choropleth/choropleth-dot-grid.js +293 -0
- package/dist/charts/choropleth/choropleth-feature.js +291 -0
- package/dist/charts/choropleth/choropleth-graticule.js +40 -0
- package/dist/charts/choropleth/choropleth-marker.js +222 -0
- package/dist/charts/choropleth/choropleth-projection.js +37 -0
- package/dist/charts/choropleth/choropleth-tooltip.js +82 -0
- package/dist/charts/choropleth/choropleth-zoom-matrix.js +150 -0
- package/dist/charts/choropleth/index.js +44 -0
- package/dist/charts/choropleth/use-choropleth-zoom-state.js +636 -0
- package/dist/charts/composed-chart.js +346 -0
- package/dist/charts/crosshair-store.js +49 -0
- package/dist/charts/dash-tail-stroke.js +58 -0
- package/dist/charts/date-pill-store.js +50 -0
- package/dist/charts/date-ranges.js +131 -0
- package/dist/charts/deadline.js +295 -0
- package/dist/charts/decimate-time-series.js +112 -0
- package/dist/charts/fade-edges.js +171 -0
- package/dist/charts/fast-path.js +78 -0
- package/dist/charts/filter-data-by-x-domain.js +45 -0
- package/dist/charts/funnel-chart.js +773 -0
- package/dist/charts/gauge-arc-layers.js +479 -0
- package/dist/charts/gauge-dial.js +329 -0
- package/dist/charts/gauge-label-layout.js +148 -0
- package/dist/charts/gauge.js +946 -0
- package/dist/charts/generate-chart-skeleton-data.js +27 -0
- package/dist/charts/gradients.js +158 -0
- package/dist/charts/grid-lines.js +114 -0
- package/dist/charts/grid.js +225 -0
- package/dist/charts/heatmap/generate-heatmap-skeleton-data.js +13 -0
- package/dist/charts/heatmap/heatmap-animation.js +128 -0
- package/dist/charts/heatmap/heatmap-cells.js +519 -0
- package/dist/charts/heatmap/heatmap-chart-loading.js +44 -0
- package/dist/charts/heatmap/heatmap-chart.js +548 -0
- package/dist/charts/heatmap/heatmap-colors.js +127 -0
- package/dist/charts/heatmap/heatmap-context.js +107 -0
- package/dist/charts/heatmap/heatmap-legend-gradient.js +97 -0
- package/dist/charts/heatmap/heatmap-legend-swatch.js +76 -0
- package/dist/charts/heatmap/heatmap-legend.js +165 -0
- package/dist/charts/heatmap/heatmap-pattern-defs.js +37 -0
- package/dist/charts/heatmap/heatmap-rect-cells.js +39 -0
- package/dist/charts/heatmap/heatmap-resolve-separator.js +84 -0
- package/dist/charts/heatmap/heatmap-separator.js +168 -0
- package/dist/charts/heatmap/heatmap-tooltip.js +73 -0
- package/dist/charts/heatmap/heatmap-utils.js +633 -0
- package/dist/charts/heatmap/heatmap-x-axis.js +79 -0
- package/dist/charts/heatmap/heatmap-y-axis.js +72 -0
- package/dist/charts/heatmap/index.js +208 -0
- package/dist/charts/highlight-segment-bounds.js +34 -0
- package/dist/charts/highlight-segment.js +119 -0
- package/dist/charts/index.js +944 -0
- package/dist/charts/indicator-fade.js +44 -0
- package/dist/charts/legend/index.js +22 -0
- package/dist/charts/legend/legend-context.js +47 -0
- package/dist/charts/legend/legend-item.js +30 -0
- package/dist/charts/legend/legend-label.js +14 -0
- package/dist/charts/legend/legend-marker.js +18 -0
- package/dist/charts/legend/legend-progress.js +39 -0
- package/dist/charts/legend/legend-value.js +31 -0
- package/dist/charts/legend/legend.js +69 -0
- package/dist/charts/line-backdrop.js +129 -0
- package/dist/charts/line-chart-loading.js +85 -0
- package/dist/charts/line-chart.js +182 -0
- package/dist/charts/line-loading-pulse.js +185 -0
- package/dist/charts/line-loading-timing.js +12 -0
- package/dist/charts/line-path.js +58 -0
- package/dist/charts/line-series-terminal-marker.js +75 -0
- package/dist/charts/line.js +499 -0
- package/dist/charts/live-line-chart.js +494 -0
- package/dist/charts/live-line.js +277 -0
- package/dist/charts/live-x-axis.js +116 -0
- package/dist/charts/live-y-axis.js +164 -0
- package/dist/charts/loading-sweep.js +344 -0
- package/dist/charts/local-point.js +56 -0
- package/dist/charts/markers/chart-markers.js +149 -0
- package/dist/charts/markers/index.js +14 -0
- package/dist/charts/markers/marker-group.js +411 -0
- package/dist/charts/motion-utils.js +29 -0
- package/dist/charts/notch-gauge-shared.js +146 -0
- package/dist/charts/particle-line.js +1340 -0
- package/dist/charts/path-stroke-utils.js +51 -0
- package/dist/charts/pattern-area.js +127 -0
- package/dist/charts/pattern-preset.js +287 -0
- package/dist/charts/pattern-tile.js +31 -0
- package/dist/charts/patterns/circles.js +62 -0
- package/dist/charts/patterns/constants.js +9 -0
- package/dist/charts/patterns/hexagons.js +38 -0
- package/dist/charts/patterns/index.js +16 -0
- package/dist/charts/patterns/lines.js +65 -0
- package/dist/charts/patterns/path.js +37 -0
- package/dist/charts/patterns/pattern.js +16 -0
- package/dist/charts/patterns/waves.js +40 -0
- package/dist/charts/pie-center-shell.js +127 -0
- package/dist/charts/pie-center.js +87 -0
- package/dist/charts/pie-chart.js +377 -0
- package/dist/charts/pie-context.js +116 -0
- package/dist/charts/pie-slice.js +394 -0
- package/dist/charts/pie-ticks.js +332 -0
- package/dist/charts/profit-loss-legend-hover.js +18 -0
- package/dist/charts/profit-loss-legend.js +53 -0
- package/dist/charts/profit-loss-line.js +162 -0
- package/dist/charts/profit-loss-segments.js +88 -0
- package/dist/charts/projection-config.js +90 -0
- package/dist/charts/projection-line-end-marker.js +50 -0
- package/dist/charts/projection-line.js +466 -0
- package/dist/charts/projection-utils.js +303 -0
- package/dist/charts/radar-area.js +192 -0
- package/dist/charts/radar-axis.js +41 -0
- package/dist/charts/radar-chart.js +184 -0
- package/dist/charts/radar-context.js +104 -0
- package/dist/charts/radar-grid.js +121 -0
- package/dist/charts/radar-labels.js +62 -0
- package/dist/charts/radial-area.js +498 -0
- package/dist/charts/radial-axis.js +652 -0
- package/dist/charts/radial-bar.js +316 -0
- package/dist/charts/radial-center.js +67 -0
- package/dist/charts/radial-chart.js +740 -0
- package/dist/charts/radial-dot-bar-layout.js +68 -0
- package/dist/charts/radial-dot-bar.js +387 -0
- package/dist/charts/radial-geometry.js +114 -0
- package/dist/charts/radial-legend.js +66 -0
- package/dist/charts/radial-line.js +280 -0
- package/dist/charts/radial-ring-bar.js +255 -0
- package/dist/charts/radial-scrubber.js +120 -0
- package/dist/charts/radial-series-color.js +10 -0
- package/dist/charts/reference-area-config.js +43 -0
- package/dist/charts/reference-area-geometry.js +76 -0
- package/dist/charts/reference-area-registration-context.js +10 -0
- package/dist/charts/reference-area.js +241 -0
- package/dist/charts/responsive-chart-label-count.js +18 -0
- package/dist/charts/ring-center.js +78 -0
- package/dist/charts/ring-chart.js +362 -0
- package/dist/charts/ring-context.js +122 -0
- package/dist/charts/ring-grid.js +175 -0
- package/dist/charts/ring-labels.js +109 -0
- package/dist/charts/ring.js +237 -0
- package/dist/charts/sankey/index.js +22 -0
- package/dist/charts/sankey/sankey-chart.js +199 -0
- package/dist/charts/sankey/sankey-context.js +32 -0
- package/dist/charts/sankey/sankey-link.js +232 -0
- package/dist/charts/sankey/sankey-node.js +348 -0
- package/dist/charts/sankey/sankey-tooltip.js +94 -0
- package/dist/charts/scatter-chart-shell.js +279 -0
- package/dist/charts/scatter-chart.js +150 -0
- package/dist/charts/scatter-jitter.js +86 -0
- package/dist/charts/scatter-svg.js +17 -0
- package/dist/charts/scatter.js +92 -0
- package/dist/charts/segment.js +107 -0
- package/dist/charts/series-bar-layout.js +42 -0
- package/dist/charts/series-bar.js +241 -0
- package/dist/charts/series-dash-tail-overlay.js +53 -0
- package/dist/charts/series-highlight-layer.js +43 -0
- package/dist/charts/series-hover-dim.js +32 -0
- package/dist/charts/series-markers.js +239 -0
- package/dist/charts/series-path-utils.js +185 -0
- package/dist/charts/series-point-marker.js +150 -0
- package/dist/charts/sparkline-geometry.js +197 -0
- package/dist/charts/sparkline.js +910 -0
- package/dist/charts/static-chart-preview-context.js +16 -0
- package/dist/charts/sunburst-breadcrumb.js +33 -0
- package/dist/charts/sunburst-center.js +37 -0
- package/dist/charts/sunburst-chart.js +408 -0
- package/dist/charts/sunburst-context.js +140 -0
- package/dist/charts/sunburst-data.js +0 -0
- package/dist/charts/sunburst-hint.js +42 -0
- package/dist/charts/sunburst-labels.js +130 -0
- package/dist/charts/sunburst-segment.js +144 -0
- package/dist/charts/sunburst.js +419 -0
- package/dist/charts/time-series-chart-shell.js +688 -0
- package/dist/charts/tooltip/chart-tooltip.js +516 -0
- package/dist/charts/tooltip/cursor-tooltip-box.js +183 -0
- package/dist/charts/tooltip/date-ticker.js +376 -0
- package/dist/charts/tooltip/index.js +32 -0
- package/dist/charts/tooltip/liquid-glass.js +142 -0
- package/dist/charts/tooltip/tooltip-box.js +502 -0
- package/dist/charts/tooltip/tooltip-content.js +59 -0
- package/dist/charts/tooltip/tooltip-dot.js +170 -0
- package/dist/charts/tooltip/tooltip-indicator.js +175 -0
- package/dist/charts/tooltip/use-delayed-tooltip-data.js +41 -0
- package/dist/charts/tooltip/use-velocity-stretch.js +52 -0
- package/dist/charts/trend-line-utils.js +64 -0
- package/dist/charts/trend-line.js +318 -0
- package/dist/charts/use-animated-band.js +175 -0
- package/dist/charts/use-animated-series-path.js +208 -0
- package/dist/charts/use-animated-y-domains.js +192 -0
- package/dist/charts/use-category-slots.js +29 -0
- package/dist/charts/use-chart-interaction.js +296 -0
- package/dist/charts/use-chart-phase-orchestrator.js +183 -0
- package/dist/charts/use-enter-complete.js +18 -0
- package/dist/charts/use-grid-shimmer.js +88 -0
- package/dist/charts/use-highlight-segment.js +65 -0
- package/dist/charts/use-mount-progress.js +23 -0
- package/dist/charts/use-scatter-chart-interaction.js +364 -0
- package/dist/charts/use-scheduled-tooltip.js +84 -0
- package/dist/charts/visx-pattern.js +30 -0
- package/dist/charts/weekends.js +174 -0
- package/dist/charts/x-axis-hover.js +46 -0
- package/dist/charts/x-axis.js +523 -0
- package/dist/charts/y-axis-scales.js +71 -0
- package/dist/charts/y-axis-ticks.js +22 -0
- package/dist/charts/y-axis.js +233 -0
- package/dist/charts/y-domain-utils.js +189 -0
- package/dist/index.d.ts +7346 -0
- package/dist/index.js +2 -0
- package/dist/lib/utils.js +8 -0
- package/dist/shimmering-text.js +54 -0
- package/package.json +78 -4
- package/tema.css +202 -0
package/ALTERACOES.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Alterações
|
|
2
|
+
|
|
3
|
+
No código, tudo o que é nosso sobre a Bklit leva `AIC:` ou está em `src/aic/`.
|
|
4
|
+
Os ajustes mecânicos são reaplicados por `scripts/ajustes-aic.mjs`.
|
|
5
|
+
|
|
6
|
+
## 0.2.2 — 2026-11-24
|
|
7
|
+
**Publicação sem chave.** O workflow passa a publicar como publicador confiável do npm, sem o
|
|
8
|
+
segredo `NPM_TOKEN`. Nenhuma mudança nos gráficos.
|
|
9
|
+
|
|
10
|
+
## 0.2.1 — 2026-11-24
|
|
11
|
+
**Nome e registro.** O pacote passa a se chamar `@aiconstructions/graficos` e a ser publicado no
|
|
12
|
+
npmjs.com, público. Nenhuma mudança nos gráficos. A `0.2.0` saiu só no GitHub Packages, como
|
|
13
|
+
`@ai-constructions/graficos`, e nenhum produto chegou a usar.
|
|
14
|
+
|
|
15
|
+
## 0.2.0 — 2026-11-24
|
|
16
|
+
**Base trocada** para a Bklit atual (commit `76299da`, 2026-11-15): 255 arquivos no lugar dos 81 de
|
|
17
|
+
setembro; sai o visx (alpha), entra d3 direto. Ganhos vindos da Bklit: eixo vertical (`YAxis`),
|
|
18
|
+
valor na barra (`showValue`), legenda, mapa de calor, área, sparkline, funil, medidor, radar,
|
|
19
|
+
dispersão, e a correção das barras empilhadas. **A interface dos componentes mudou em relação à
|
|
20
|
+
0.1.0** — telas feitas na 0.1.0 precisam de revisão.
|
|
21
|
+
|
|
22
|
+
Recursos novos da AIC (`src/aic/`):
|
|
23
|
+
- **Clique que filtra:** `onBarClick` (BarChart), `onSliceClick` (PieChart), `onPointClick`
|
|
24
|
+
(LineChart, AreaChart).
|
|
25
|
+
- **Seleção com esmaecimento:** `selectedIndex` em BarChart e PieChart.
|
|
26
|
+
- **Cores derivadas da marca:** `variaveisDaMarca`, `tomDaMarca`, `textoSobre`, `contraste`.
|
|
27
|
+
- **Cor esmaecida por série:** `--chart-N-dim`; e `--chart-1-strong`.
|
|
28
|
+
|
|
29
|
+
Ajustes reaplicados sobre a base nova:
|
|
30
|
+
- **Português:** formatadores `en-US` → `pt-BR`; "Loading" → "Carregando", "Less/More" → "Menos/Mais",
|
|
31
|
+
"No data" → "Sem dados", "Value" → "Valor"; dicas do sunburst; sankey sem a palavra "sessions" depois do número; data do mapa de calor "January 20th 2026" →
|
|
32
|
+
"20 de janeiro de 2026"; "contributions" → "registros"; eixo "1.5k" → "1,5 mil"; dias da semana
|
|
33
|
+
do mapa de calor ("Mon" → "Seg") — este último achado na vitrine de validação.
|
|
34
|
+
- **Variáveis isoladas:** `--foreground`, `--background`, `--border`, `--muted-foreground`, `--popover…`
|
|
35
|
+
e cores da paleta padrão do Tailwind dentro dos componentes viraram `--chart-*`. O pacote só lê
|
|
36
|
+
`--chart-*` e `--legend-*`.
|
|
37
|
+
- **Classes de cor próprias:** `text-foreground`, `bg-zinc-900` etc. viraram `text-chart-foreground`,
|
|
38
|
+
`bg-chart-pill`…, declaradas como utilidades no `tema.css` (não dependem do tema do produto).
|
|
39
|
+
- **Rótulo das barras deitadas:** largura máxima de 70 px fixos → variável `--bar-y-label-max`.
|
|
40
|
+
- **Caminhos:** `@/lib/utils` → relativo.
|
|
41
|
+
|
|
42
|
+
Outros:
|
|
43
|
+
- `tema.css` refeito a partir da lista oficial de variáveis da Bklit, com versão **clara e escura**
|
|
44
|
+
e o padrão de cores da AIC.
|
|
45
|
+
- Tema escuro: as variáveis derivadas (as que apontam para outra variável) são repetidas no bloco
|
|
46
|
+
escuro; sem isso, o tema escuro aplicado num elemento interno ficava com cores do claro (achado
|
|
47
|
+
na vitrine, no trilho dos anéis). Há um teste que impede a regressão.
|
|
48
|
+
- Padrão de fundos, grade e textos em **cinza neutro** nos dois temas (decisão do Mateus em
|
|
49
|
+
2026-11-24: a primeira versão do tema puxava para o azul do SAT). O tom de cada produto entra
|
|
50
|
+
no CSS do produto; a receita está no README.
|
|
51
|
+
- Saída do pacote com um arquivo por módulo, para o produto carregar só o que usa.
|
|
52
|
+
- Testes: os 220 da Bklit (3 pulados, dependem da data de hoje) + 26 da camada da AIC.
|
|
53
|
+
|
|
54
|
+
## 0.1.0 — 2026-11-24
|
|
55
|
+
Primeira versão, sobre a cópia da Bklit de 2026-09-08 usada no Loggus (81 arquivos, visx).
|
|
56
|
+
Correções: barras empilhadas estourando o gráfico, rótulo deitado cortado, datas em inglês,
|
|
57
|
+
variáveis de nome genérico colidindo com o tema do produto. Substituída pela 0.2.0 no mesmo dia.
|
package/LICENSE-BKLIT
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 uixmat
|
|
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.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-2018 Harrison Shoff
|
|
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,190 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @aiconstructions/graficos
|
|
2
|
+
|
|
3
|
+
Os gráficos padrão dos produtos da AI Constructions: a **Bklit UI** transformada em pacote, com os
|
|
4
|
+
ajustes e recursos da casa. Os produtos (SAT, Loggus, NaObra…) instalam uma dependência em vez de
|
|
5
|
+
copiar o código para dentro do próprio repositório, e todos ficam com o mesmo acabamento.
|
|
6
|
+
|
|
7
|
+
- **Dono:** Mateus Bitar — revisa as mudanças e decide quando sai versão.
|
|
8
|
+
- **Versão:** 0.2.2 (2026-11-24), publicada no npmjs.com como `@aiconstructions/graficos` (pública).
|
|
9
|
+
- **Base:** Bklit UI, commit `76299da` de 2026-11-15, licença MIT (`LICENSE-BKLIT`).
|
|
10
|
+
|
|
11
|
+
## O que tem
|
|
12
|
+
Tudo o que a Bklit oferece nessa data, mais a camada da AIC.
|
|
13
|
+
|
|
14
|
+
| Família | Componentes principais |
|
|
15
|
+
|---|---|
|
|
16
|
+
| Barras (em pé, deitadas, empilhadas) | `BarChart`, `Bar`, `BarXAxis`, `BarYAxis`, `YAxis` |
|
|
17
|
+
| Linhas e áreas | `LineChart`, `Line`, `AreaChart`, `Area`, `XAxis`, `YAxis` |
|
|
18
|
+
| Pizza, rosca, anéis | `PieChart`, `PieSlice`, `PieCenter`, `RingChart` |
|
|
19
|
+
| Mapa de calor | `HeatmapChart`, `HeatmapCells`, `HeatmapLegend`… |
|
|
20
|
+
| Outros | sparkline, funil, medidor, radar, radial, dispersão, composto, sankey, mapa coroplético |
|
|
21
|
+
| Peças comuns | `Grid`, `ChartTooltip`, `Legend`, marcadores, áreas de referência, linha de projeção |
|
|
22
|
+
| **Camada da AIC** | clique que filtra, seleção com esmaecimento, cores derivadas da marca |
|
|
23
|
+
|
|
24
|
+
**O que já foi visto funcionando** (protótipo e vitrine do SAT, em `SAT/prototipos/dashboard`):
|
|
25
|
+
- *Com captura de tela e clique simulado:* barras em pé, deitadas e empilhadas; linhas; área; rosca;
|
|
26
|
+
eixos; valor na barra; clique em barra, fatia e ponto de linha/área; seleção com esmaecimento.
|
|
27
|
+
- *Com captura de tela, nos temas claro e escuro, usando o exemplo oficial da Bklit:* mapa de calor,
|
|
28
|
+
composto, sparkline, funil, medidor, anéis, radial, radar, dispersão, sankey, sunburst,
|
|
29
|
+
candlestick e linha ao vivo.
|
|
30
|
+
- *Ainda não visto:* mapa coroplético (precisa de arquivo de mapa) e os cartões de estatística.
|
|
31
|
+
|
|
32
|
+
Funil, sankey e os demais foram conferidos pelo Mateus no navegador em 2026-11-24 ("tudo muito
|
|
33
|
+
bom"); a única ressalva foi o radar (ver "O que falta").
|
|
34
|
+
Quatro exemplos oficiais da Bklit (funil, anéis, radar, linha ao vivo) não batiam com as
|
|
35
|
+
propriedades dos componentes no mesmo commit; a referência confiável são os tipos do pacote.
|
|
36
|
+
|
|
37
|
+
## Usar num produto
|
|
38
|
+
```bash
|
|
39
|
+
npm install @aiconstructions/graficos motion
|
|
40
|
+
```
|
|
41
|
+
No CSS global, logo depois do Tailwind:
|
|
42
|
+
```css
|
|
43
|
+
@import "tailwindcss";
|
|
44
|
+
@import "@aiconstructions/graficos/tema.css";
|
|
45
|
+
```
|
|
46
|
+
Na tela:
|
|
47
|
+
```tsx
|
|
48
|
+
import { Bar, BarChart, BarXAxis, ChartTooltip, Grid, YAxis } from "@aiconstructions/graficos";
|
|
49
|
+
|
|
50
|
+
<BarChart data={dados} xDataKey="mes" aspectRatio="560 / 240" margin={{ left: 48, bottom: 28 }}>
|
|
51
|
+
<Grid horizontal vertical={false} />
|
|
52
|
+
<Bar dataKey="total" fill="var(--chart-1)" lineCap={4} />
|
|
53
|
+
<YAxis />
|
|
54
|
+
<BarXAxis />
|
|
55
|
+
<ChartTooltip showDatePill={false} />
|
|
56
|
+
</BarChart>
|
|
57
|
+
```
|
|
58
|
+
Exemplo completo: `SAT/prototipos/dashboard/src/bklit/Graficos.tsx`.
|
|
59
|
+
Requisitos do produto: React 19, Tailwind 4 e `motion`. Funciona no App Router do Next (os
|
|
60
|
+
componentes já saem marcados como de navegador; a matemática de cores roda também no servidor).
|
|
61
|
+
|
|
62
|
+
## Cores: o que o produto controla
|
|
63
|
+
Tudo o que é cor passa por variáveis `--chart-*` e `--legend-*` (lista completa em `tema.css`,
|
|
64
|
+
com versão clara e escura). O pacote **só declara e só lê** essas variáveis; não toca em nenhuma
|
|
65
|
+
outra do produto. O produto pode:
|
|
66
|
+
|
|
67
|
+
1. **Não fazer nada** e ficar com o padrão (azul, laranja e verde-água validados para daltonismo).
|
|
68
|
+
2. **Sobrescrever no CSS** as que quiser:
|
|
69
|
+
```css
|
|
70
|
+
:root { --chart-1: #0f766e; --chart-grid: var(--minha-borda); }
|
|
71
|
+
```
|
|
72
|
+
3. **Passar a cor direto** num gráfico: `<Bar fill="#0f766e" />`.
|
|
73
|
+
|
|
74
|
+
Tema escuro: vale com a classe `dark` (padrão do shadcn, usado no Loggus) ou `data-theme="dark"`.
|
|
75
|
+
|
|
76
|
+
**O padrão é neutro de propósito.** Fundos, grade e textos são cinzas sem matiz, nos dois temas;
|
|
77
|
+
só as séries têm cor. O tom do produto entra no CSS dele. Exemplo, o escuro azulado do SAT:
|
|
78
|
+
```css
|
|
79
|
+
[data-theme="dark"] {
|
|
80
|
+
--chart-background: #12181f;
|
|
81
|
+
--chart-grid: #2a3541;
|
|
82
|
+
--chart-foreground: #f0f3f6;
|
|
83
|
+
--chart-foreground-muted: #a9b5c0;
|
|
84
|
+
--chart-label: #a9b5c0;
|
|
85
|
+
--chart-crosshair: #a9b5c0;
|
|
86
|
+
--chart-marker-background: #1c2630;
|
|
87
|
+
--chart-marker-border: #3b4856;
|
|
88
|
+
--legend: #1c2630;
|
|
89
|
+
--legend-muted: #243040;
|
|
90
|
+
--legend-track: #2a3541;
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
Declare no **mesmo seletor** em que o tema escuro é ligado (o `tema.css` recalcula ali as
|
|
94
|
+
variáveis derivadas, como o trilho dos anéis e as cores esmaecidas).
|
|
95
|
+
|
|
96
|
+
## Recursos da AIC
|
|
97
|
+
|
|
98
|
+
### Clique que filtra
|
|
99
|
+
```tsx
|
|
100
|
+
<BarChart data={dias} onBarClick={({ index, datum }) => filtrarPorDia(datum.dia)} … />
|
|
101
|
+
<PieChart data={categorias} onSliceClick={({ datum }) => filtrarPorCategoria(datum.label)} … />
|
|
102
|
+
<LineChart data={serie} onPointClick={({ datum }) => abrirDia(datum.data)} … /> {/* e AreaChart */}
|
|
103
|
+
```
|
|
104
|
+
O clique vale para o item sob o cursor. Quando há `on…Click`, o cursor vira "mãozinha".
|
|
105
|
+
|
|
106
|
+
### Destaque com esmaecimento
|
|
107
|
+
```tsx
|
|
108
|
+
<BarChart selectedIndex={indiceDoDiaFiltrado} … /> {/* um número, vários ([0, 3]) ou null */}
|
|
109
|
+
<PieChart selectedIndex={indiceDaCategoria} … />
|
|
110
|
+
```
|
|
111
|
+
O item selecionado continua em destaque e os demais esmaecem; o gráfico nunca "colapsa" para um
|
|
112
|
+
item só (decisão do Loggus, filtros cruzados). Passar o mouse em outro item o destaca junto.
|
|
113
|
+
Para elementos fora do gráfico (linha de lista, legenda) há a cor esmaecida de cada série:
|
|
114
|
+
`var(--chart-1-dim)` … `var(--chart-5-dim)`.
|
|
115
|
+
|
|
116
|
+
### Cores derivadas da cor do cliente
|
|
117
|
+
Receita combinada no Loggus (personalização por empresa): mantém o matiz da cor do cliente, fixa
|
|
118
|
+
a luminosidade e limita o croma, para a série continuar legível seja qual for a cor escolhida.
|
|
119
|
+
```tsx
|
|
120
|
+
import { variaveisDaMarca, textoSobre, contraste } from "@aiconstructions/graficos";
|
|
121
|
+
|
|
122
|
+
<div style={variaveisDaMarca(empresa.corPrimaria)}> {/* "#7a3cff" */}
|
|
123
|
+
…gráficos…
|
|
124
|
+
</div>
|
|
125
|
+
```
|
|
126
|
+
| Variável gerada | Luminosidade | Uso |
|
|
127
|
+
|---|---|---|
|
|
128
|
+
| `--chart-1` | 0,58 | série principal |
|
|
129
|
+
| `--chart-1-strong` | 0,42 | destaque da série principal |
|
|
130
|
+
| `--chart-tom-1`, `-2`, `-3` | 0,78 / 0,62 / 0,45 | três categorias no mesmo matiz |
|
|
131
|
+
|
|
132
|
+
Croma limitado a 0,15. Sem cor salva, não aplique nada: vale o padrão do `tema.css`.
|
|
133
|
+
`textoSobre(cor)` devolve branco ou escuro, o que contrastar mais; `contraste(a, b)` dá a razão
|
|
134
|
+
WCAG (abaixo de 4,5 avise o usuário, sem bloquear — regra do Loggus). A cor precisa vir em
|
|
135
|
+
hexadecimal.
|
|
136
|
+
|
|
137
|
+
## Mexer no pacote
|
|
138
|
+
```bash
|
|
139
|
+
npm install
|
|
140
|
+
npm run verificar # reaplica os ajustes, confere tipos, roda os testes e compila
|
|
141
|
+
npm pack # gera o .tgz para testar num produto antes de publicar
|
|
142
|
+
```
|
|
143
|
+
- **Testes:** 246 (os da própria Bklit mais os da camada da AIC). Três da Bklit ficam pulados, com
|
|
144
|
+
o motivo escrito: comparam com a data de hoje usando um "hoje" fixo de 01/07/2026 e passaram a
|
|
145
|
+
falhar depois dessa data, também na Bklit sem nenhum ajuste nosso.
|
|
146
|
+
- **TypeScript 5 de propósito:** o gerador de tipos do `tsup` não funciona com a versão 7.
|
|
147
|
+
|
|
148
|
+
### Atualizar a base da Bklit
|
|
149
|
+
1. Substituir `src/charts` por `packages/ui/src/charts` do repositório `bklit/bklit-ui` (e
|
|
150
|
+
`src/shimmering-text.tsx`, `src/lib/utils.ts`).
|
|
151
|
+
2. `npm run verificar`.
|
|
152
|
+
|
|
153
|
+
O script `scripts/ajustes-aic.mjs` reaplica tudo o que é nosso (lista em `ALTERACOES.md`). Se a
|
|
154
|
+
Bklit mudou um trecho que ele precisa, ele **para e diz qual ajuste refazer** — não aplica pela
|
|
155
|
+
metade. O teste `src/aic/__tests__/ajustes.test.ts` fica vermelho se algum ajuste faltar.
|
|
156
|
+
Depois de atualizar: conferir as telas no protótipo e subir a versão.
|
|
157
|
+
|
|
158
|
+
### Versões
|
|
159
|
+
- `0.2.1` — correção, seguro atualizar.
|
|
160
|
+
- `0.3.0` — recurso novo, sem mudar o que existe.
|
|
161
|
+
- `1.0.0`, `2.0.0` — mudança que exige mexer nas telas; o que mudou vai no `ALTERACOES.md`.
|
|
162
|
+
|
|
163
|
+
Cada produto fica preso à versão que instalou e só muda quando alguém troca o número nele.
|
|
164
|
+
|
|
165
|
+
### Publicar uma versão
|
|
166
|
+
O pacote mora em `AI-Constructions/aic-graficos` e é publicado no npmjs.com, público, na
|
|
167
|
+
organização `aiconstructions`, pelo workflow `.github/workflows/publicar.yml`. Ninguém publica da
|
|
168
|
+
própria máquina.
|
|
169
|
+
1. Subir o número em `package.json` e anotar a mudança em `ALTERACOES.md`.
|
|
170
|
+
2. Com isso na `main`: `git tag v0.2.3 && git push origin v0.2.3`.
|
|
171
|
+
3. O workflow confere que a tag bate com a versão, roda `npm run verificar` e publica.
|
|
172
|
+
|
|
173
|
+
Não há chave guardada: o repositório está cadastrado no npm como publicador confiável (página do
|
|
174
|
+
pacote → Settings → Trusted Publisher, workflow `publicar.yml`), e o GitHub prova ao npm quem está
|
|
175
|
+
publicando. Se o workflow for renomeado, é preciso apagar essa conexão no npm e criar outra.
|
|
176
|
+
|
|
177
|
+
Todo PR e todo push na `main` rodam `npm run verificar` (`.github/workflows/verificar.yml`).
|
|
178
|
+
|
|
179
|
+
### Acesso para instalar
|
|
180
|
+
O pacote é público: `npm install` comum, sem token e sem `.npmrc`, na máquina e nos builds.
|
|
181
|
+
|
|
182
|
+
## O que falta
|
|
183
|
+
- **Valor escrito fora da barra:** a Bklit só escreve dentro; em barra curta o valor some.
|
|
184
|
+
- **Clique pelo teclado:** barras e fatias não recebem foco; hoje o clique é só por mouse/toque.
|
|
185
|
+
- **Radar:** o destaque no hover é por série (o polígono inteiro); os nomes dos eixos não reagem e
|
|
186
|
+
não há valor por eixo. Com uma série só, "acende tudo junto". Se algum produto for usar radar,
|
|
187
|
+
acrescentar destaque por eixo com o valor (conferido pelo Mateus na vitrine em 2026-11-24).
|
|
188
|
+
- **Mapa coroplético:** ainda não visto numa tela.
|
|
189
|
+
- **Loggus:** migrar da cópia própria (de set/26, com visx) para o pacote — a interface mudou.
|
|
2
190
|
|
|
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.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const LUMINOSIDADE = {
|
|
2
|
+
serie: 0.58,
|
|
3
|
+
serieForte: 0.42,
|
|
4
|
+
tons: [0.78, 0.62, 0.45]
|
|
5
|
+
};
|
|
6
|
+
const CROMA_MAXIMO = 0.15;
|
|
7
|
+
function hexParaRgb(hex) {
|
|
8
|
+
const h = hex.trim().replace(/^#/, "");
|
|
9
|
+
const cheio = h.length === 3 ? [...h].map((c) => c + c).join("") : h;
|
|
10
|
+
if (!/^[0-9a-fA-F]{6}$/.test(cheio)) {
|
|
11
|
+
throw new Error(`Cor inv\xE1lida: "${hex}". Use hexadecimal, como #2a78d6.`);
|
|
12
|
+
}
|
|
13
|
+
return [0, 2, 4].map((i) => Number.parseInt(cheio.slice(i, i + 2), 16) / 255);
|
|
14
|
+
}
|
|
15
|
+
const paraLinear = (c) => c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
16
|
+
const paraGama = (c) => c <= 31308e-7 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055;
|
|
17
|
+
function rgbParaOklch([r, g, b]) {
|
|
18
|
+
const [lr, lg, lb] = [paraLinear(r), paraLinear(g), paraLinear(b)];
|
|
19
|
+
const l = Math.cbrt(0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb);
|
|
20
|
+
const m = Math.cbrt(0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb);
|
|
21
|
+
const s = Math.cbrt(0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb);
|
|
22
|
+
const L = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s;
|
|
23
|
+
const a = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;
|
|
24
|
+
const bb = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;
|
|
25
|
+
return { l: L, c: Math.hypot(a, bb), h: Math.atan2(bb, a) * 180 / Math.PI };
|
|
26
|
+
}
|
|
27
|
+
function oklchParaRgbLinear(l, c, h) {
|
|
28
|
+
const a = c * Math.cos(h * Math.PI / 180);
|
|
29
|
+
const b = c * Math.sin(h * Math.PI / 180);
|
|
30
|
+
const l_ = (l + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
31
|
+
const m_ = (l - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
32
|
+
const s_ = (l - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
33
|
+
return [
|
|
34
|
+
4.0767416621 * l_ - 3.3077115913 * m_ + 0.2309699292 * s_,
|
|
35
|
+
-1.2684380046 * l_ + 2.6097574011 * m_ - 0.3413193965 * s_,
|
|
36
|
+
-0.0041960863 * l_ - 0.7034186147 * m_ + 1.707614701 * s_
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
const dentroDoGamut = (rgb) => rgb.every((v) => v >= -5e-4 && v <= 1.0005);
|
|
40
|
+
function oklchParaHex(l, c, h) {
|
|
41
|
+
let croma = c;
|
|
42
|
+
let rgb = oklchParaRgbLinear(l, croma, h);
|
|
43
|
+
for (let i = 0; i < 40 && !dentroDoGamut(rgb); i++) {
|
|
44
|
+
croma *= 0.95;
|
|
45
|
+
rgb = oklchParaRgbLinear(l, croma, h);
|
|
46
|
+
}
|
|
47
|
+
return `#${rgb.map((v) => Math.round(Math.min(1, Math.max(0, paraGama(Math.min(1, Math.max(0, v))))) * 255)).map((v) => v.toString(16).padStart(2, "0")).join("")}`;
|
|
48
|
+
}
|
|
49
|
+
function tomDaMarca(primaria, luminosidade) {
|
|
50
|
+
const { c, h } = rgbParaOklch(hexParaRgb(primaria));
|
|
51
|
+
return oklchParaHex(luminosidade, Math.min(c, CROMA_MAXIMO), h);
|
|
52
|
+
}
|
|
53
|
+
function luminanciaRelativa(hex) {
|
|
54
|
+
const [r, g, b] = hexParaRgb(hex).map(paraLinear);
|
|
55
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
56
|
+
}
|
|
57
|
+
function contraste(a, b) {
|
|
58
|
+
const [la, lb] = [luminanciaRelativa(a), luminanciaRelativa(b)];
|
|
59
|
+
return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05);
|
|
60
|
+
}
|
|
61
|
+
function textoSobre(fundo, claro = "#ffffff", escuro = "#12202c") {
|
|
62
|
+
return contraste(fundo, claro) >= contraste(fundo, escuro) ? claro : escuro;
|
|
63
|
+
}
|
|
64
|
+
function variaveisDaMarca(primaria) {
|
|
65
|
+
const [tom1, tom2, tom3] = LUMINOSIDADE.tons.map((l) => tomDaMarca(primaria, l));
|
|
66
|
+
return {
|
|
67
|
+
"--chart-1": tomDaMarca(primaria, LUMINOSIDADE.serie),
|
|
68
|
+
"--chart-1-strong": tomDaMarca(primaria, LUMINOSIDADE.serieForte),
|
|
69
|
+
"--chart-tom-1": tom1,
|
|
70
|
+
"--chart-tom-2": tom2,
|
|
71
|
+
"--chart-tom-3": tom3
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
CROMA_MAXIMO,
|
|
76
|
+
LUMINOSIDADE,
|
|
77
|
+
contraste,
|
|
78
|
+
oklchParaHex,
|
|
79
|
+
rgbParaOklch,
|
|
80
|
+
textoSobre,
|
|
81
|
+
tomDaMarca,
|
|
82
|
+
variaveisDaMarca
|
|
83
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CROMA_MAXIMO,
|
|
3
|
+
contraste,
|
|
4
|
+
LUMINOSIDADE,
|
|
5
|
+
textoSobre,
|
|
6
|
+
tomDaMarca,
|
|
7
|
+
variaveisDaMarca
|
|
8
|
+
} from "./cores";
|
|
9
|
+
import {
|
|
10
|
+
estaEsmaecido,
|
|
11
|
+
normalizarSelecao
|
|
12
|
+
} from "./interacao";
|
|
13
|
+
export {
|
|
14
|
+
CROMA_MAXIMO,
|
|
15
|
+
LUMINOSIDADE,
|
|
16
|
+
contraste,
|
|
17
|
+
estaEsmaecido,
|
|
18
|
+
normalizarSelecao,
|
|
19
|
+
textoSobre,
|
|
20
|
+
tomDaMarca,
|
|
21
|
+
variaveisDaMarca
|
|
22
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useMemo } from "react";
|
|
4
|
+
const VAZIO = { selecionados: null };
|
|
5
|
+
const InteracaoContext = createContext(VAZIO);
|
|
6
|
+
function normalizarSelecao(selecao) {
|
|
7
|
+
if (selecao === null || selecao === void 0) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const lista = typeof selecao === "number" ? [selecao] : selecao;
|
|
11
|
+
const validos = lista.filter((i) => Number.isInteger(i) && i >= 0);
|
|
12
|
+
return validos.length > 0 ? new Set(validos) : null;
|
|
13
|
+
}
|
|
14
|
+
function estaEsmaecido(index, hoveredIndex, selecionados) {
|
|
15
|
+
const haFoco = hoveredIndex !== null || selecionados !== null;
|
|
16
|
+
if (!haFoco) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
if (hoveredIndex === index) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return !(selecionados?.has(index) ?? false);
|
|
23
|
+
}
|
|
24
|
+
function InteracaoProvider({
|
|
25
|
+
data,
|
|
26
|
+
selecao,
|
|
27
|
+
aoClicar,
|
|
28
|
+
children
|
|
29
|
+
}) {
|
|
30
|
+
const chave = selecao === null || selecao === void 0 ? "" : typeof selecao === "number" ? String(selecao) : selecao.join(",");
|
|
31
|
+
const value = useMemo(
|
|
32
|
+
() => ({
|
|
33
|
+
selecionados: normalizarSelecao(
|
|
34
|
+
chave === "" ? null : chave.split(",").map(Number)
|
|
35
|
+
),
|
|
36
|
+
aoClicar: aoClicar ? (index) => {
|
|
37
|
+
const datum = data[index];
|
|
38
|
+
if (datum !== void 0) {
|
|
39
|
+
aoClicar({ index, datum });
|
|
40
|
+
}
|
|
41
|
+
} : void 0
|
|
42
|
+
}),
|
|
43
|
+
[chave, aoClicar, data]
|
|
44
|
+
);
|
|
45
|
+
return /* @__PURE__ */ jsx(InteracaoContext.Provider, { value, children });
|
|
46
|
+
}
|
|
47
|
+
function useInteracaoAic() {
|
|
48
|
+
return useContext(InteracaoContext);
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
InteracaoProvider,
|
|
52
|
+
estaEsmaecido,
|
|
53
|
+
normalizarSelecao,
|
|
54
|
+
useInteracaoAic
|
|
55
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const DEFAULT_ANIMATION_EASING = "cubic-bezier(0.85, 0, 0.15, 1)";
|
|
2
|
+
const DEFAULT_ANIMATION_DURATION_MS = 1100;
|
|
3
|
+
const DEFAULT_CHART_ENTER_TRANSITION = {
|
|
4
|
+
type: "tween",
|
|
5
|
+
duration: DEFAULT_ANIMATION_DURATION_MS / 1e3,
|
|
6
|
+
ease: [0.85, 0, 0.15, 1]
|
|
7
|
+
};
|
|
8
|
+
function clipRevealTransition(enterTransition) {
|
|
9
|
+
if (enterTransition?.type === "tween") {
|
|
10
|
+
return {
|
|
11
|
+
...enterTransition,
|
|
12
|
+
ease: enterTransition.ease ?? DEFAULT_CHART_ENTER_TRANSITION.ease
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const duration = typeof enterTransition?.duration === "number" ? enterTransition.duration : DEFAULT_ANIMATION_DURATION_MS / 1e3;
|
|
16
|
+
return {
|
|
17
|
+
type: "tween",
|
|
18
|
+
duration,
|
|
19
|
+
ease: DEFAULT_CHART_ENTER_TRANSITION.ease
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const GRID_RING_STAGGER_S = 0.08;
|
|
23
|
+
const GRID_RING_SPRING = {
|
|
24
|
+
type: "spring",
|
|
25
|
+
stiffness: 100,
|
|
26
|
+
damping: 15,
|
|
27
|
+
mass: 1
|
|
28
|
+
};
|
|
29
|
+
const GRID_SPOKE_STAGGER_S = 0.05;
|
|
30
|
+
const GRID_SPOKE_SPRING = {
|
|
31
|
+
type: "spring",
|
|
32
|
+
stiffness: 80,
|
|
33
|
+
damping: 15,
|
|
34
|
+
mass: 1
|
|
35
|
+
};
|
|
36
|
+
const GRID_VALUE_LABEL_STAGGER_S = 0.06;
|
|
37
|
+
const GRID_ANGLE_LABEL_STAGGER_S = 0.08;
|
|
38
|
+
const GRID_ANGLE_LABEL_FADE_S = 0.5;
|
|
39
|
+
function gridLabelDelay(ringCount, ringStagger = GRID_RING_STAGGER_S) {
|
|
40
|
+
return ringCount * ringStagger * 0.5;
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
DEFAULT_ANIMATION_DURATION_MS,
|
|
44
|
+
DEFAULT_ANIMATION_EASING,
|
|
45
|
+
DEFAULT_CHART_ENTER_TRANSITION,
|
|
46
|
+
GRID_ANGLE_LABEL_FADE_S,
|
|
47
|
+
GRID_ANGLE_LABEL_STAGGER_S,
|
|
48
|
+
GRID_RING_SPRING,
|
|
49
|
+
GRID_RING_STAGGER_S,
|
|
50
|
+
GRID_SPOKE_SPRING,
|
|
51
|
+
GRID_SPOKE_STAGGER_S,
|
|
52
|
+
GRID_VALUE_LABEL_STAGGER_S,
|
|
53
|
+
clipRevealTransition,
|
|
54
|
+
gridLabelDelay
|
|
55
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const TAU = Math.PI * 2;
|
|
2
|
+
function polarToCartesian(angle, radius) {
|
|
3
|
+
return { x: radius * Math.sin(angle), y: -radius * Math.cos(angle) };
|
|
4
|
+
}
|
|
5
|
+
function isFullArc(startAngle, endAngle) {
|
|
6
|
+
return Math.abs(endAngle - startAngle) >= TAU - 1e-6;
|
|
7
|
+
}
|
|
8
|
+
function radialArcPath(radius, startAngle, endAngle) {
|
|
9
|
+
if (isFullArc(startAngle, endAngle)) {
|
|
10
|
+
return `M0,${-radius}A${radius},${radius},0,1,1,0,${radius}A${radius},${radius},0,1,1,0,${-radius}Z`;
|
|
11
|
+
}
|
|
12
|
+
const a = polarToCartesian(startAngle, radius);
|
|
13
|
+
const b = polarToCartesian(endAngle, radius);
|
|
14
|
+
const large = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0;
|
|
15
|
+
const sweep = endAngle > startAngle ? 1 : 0;
|
|
16
|
+
return `M${a.x},${a.y}A${radius},${radius},0,${large},${sweep},${b.x},${b.y}`;
|
|
17
|
+
}
|
|
18
|
+
function arcStartLabelLayout(startAngle, endAngle, offset) {
|
|
19
|
+
const direction = endAngle >= startAngle ? 1 : -1;
|
|
20
|
+
const tx = Math.cos(startAngle) * direction;
|
|
21
|
+
const ty = Math.sin(startAngle) * direction;
|
|
22
|
+
const vertical = Math.abs(tx) <= 0.3;
|
|
23
|
+
let anchor = "middle";
|
|
24
|
+
if (vertical) {
|
|
25
|
+
anchor = ty < 0 ? "end" : "start";
|
|
26
|
+
} else if (tx > 0.3) {
|
|
27
|
+
anchor = "end";
|
|
28
|
+
} else if (tx < -0.3) {
|
|
29
|
+
anchor = "start";
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
anchor,
|
|
33
|
+
vertical,
|
|
34
|
+
/** Label position for a ring whose band centre is at `radius`. */
|
|
35
|
+
position(radius) {
|
|
36
|
+
const p = polarToCartesian(startAngle, radius);
|
|
37
|
+
const x = p.x - tx * offset;
|
|
38
|
+
const y = p.y - ty * offset;
|
|
39
|
+
return {
|
|
40
|
+
x,
|
|
41
|
+
y,
|
|
42
|
+
transform: vertical ? `rotate(-90 ${x} ${y})` : void 0
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function outsideArcLabelPoint(angle, radius, gap, width, height) {
|
|
48
|
+
const extent = Math.abs(Math.sin(angle)) * (width / 2) + Math.abs(Math.cos(angle)) * (height / 2);
|
|
49
|
+
return polarToCartesian(angle, radius + gap + extent);
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
TAU,
|
|
53
|
+
arcStartLabelLayout,
|
|
54
|
+
isFullArc,
|
|
55
|
+
outsideArcLabelPoint,
|
|
56
|
+
polarToCartesian,
|
|
57
|
+
radialArcPath
|
|
58
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { arc } from "d3-shape";
|
|
2
|
+
const generator = arc().innerRadius((d) => d.innerRadius).outerRadius((d) => d.outerRadius).startAngle((d) => d.startAngle).endAngle((d) => d.endAngle).cornerRadius((d) => d.cornerRadius).padAngle((d) => d.padAngle);
|
|
3
|
+
function arcPath(innerRadius, outerRadius, startAngle, endAngle, cornerRadius = 0, padAngle = 0) {
|
|
4
|
+
return generator({
|
|
5
|
+
innerRadius,
|
|
6
|
+
outerRadius,
|
|
7
|
+
startAngle,
|
|
8
|
+
endAngle,
|
|
9
|
+
cornerRadius,
|
|
10
|
+
padAngle
|
|
11
|
+
}) || "";
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
arcPath
|
|
15
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { curveNatural } from "d3-shape";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { Area } from "./area";
|
|
6
|
+
import { AreaChart } from "./area-chart";
|
|
7
|
+
import {
|
|
8
|
+
DEFAULT_SKELETON_DATA_KEY,
|
|
9
|
+
DEFAULT_SKELETON_POINT_COUNT,
|
|
10
|
+
generateChartSkeletonData
|
|
11
|
+
} from "./generate-chart-skeleton-data";
|
|
12
|
+
import { Grid } from "./grid";
|
|
13
|
+
const LOADING_DATA_KEY = DEFAULT_SKELETON_DATA_KEY;
|
|
14
|
+
const DEFAULT_LOADING_STROKE = "var(--chart-foreground)";
|
|
15
|
+
const DEFAULT_LOADING_GRID_STROKE = "color-mix(in oklch, var(--chart-grid) 50%, transparent)";
|
|
16
|
+
const DEFAULT_LOADING_GRID_SHIMMER_STROKE = "color-mix(in oklch, var(--chart-foreground) 68%, transparent)";
|
|
17
|
+
const DEFAULT_LOADING_STROKE_OPACITY = 0.5;
|
|
18
|
+
function AreaChartLoading({
|
|
19
|
+
margin,
|
|
20
|
+
stroke = DEFAULT_LOADING_STROKE,
|
|
21
|
+
strokeOpacity = DEFAULT_LOADING_STROKE_OPACITY,
|
|
22
|
+
gridStroke = DEFAULT_LOADING_GRID_STROKE,
|
|
23
|
+
gridShimmerStroke = DEFAULT_LOADING_GRID_SHIMMER_STROKE,
|
|
24
|
+
gridShimmer = true,
|
|
25
|
+
gridShimmerLength,
|
|
26
|
+
gridShimmerSpeed,
|
|
27
|
+
gridShimmerSync = false,
|
|
28
|
+
loadingStyle = "pulse",
|
|
29
|
+
label = "Carregando",
|
|
30
|
+
aspectRatio = "2 / 1",
|
|
31
|
+
className = ""
|
|
32
|
+
}) {
|
|
33
|
+
const data = useMemo(
|
|
34
|
+
() => generateChartSkeletonData({
|
|
35
|
+
dataKey: DEFAULT_SKELETON_DATA_KEY,
|
|
36
|
+
pointCount: DEFAULT_SKELETON_POINT_COUNT
|
|
37
|
+
}),
|
|
38
|
+
[]
|
|
39
|
+
);
|
|
40
|
+
return /* @__PURE__ */ jsxs(
|
|
41
|
+
AreaChart,
|
|
42
|
+
{
|
|
43
|
+
animationDuration: 0,
|
|
44
|
+
aspectRatio,
|
|
45
|
+
className,
|
|
46
|
+
data,
|
|
47
|
+
loadingLabel: label,
|
|
48
|
+
margin,
|
|
49
|
+
status: "loading",
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ jsx(
|
|
52
|
+
Grid,
|
|
53
|
+
{
|
|
54
|
+
horizontal: true,
|
|
55
|
+
shimmer: loadingStyle === "sweep" ? false : gridShimmer,
|
|
56
|
+
shimmerLength: gridShimmerLength,
|
|
57
|
+
shimmerSpeed: gridShimmerSpeed,
|
|
58
|
+
shimmerStroke: gridShimmerStroke,
|
|
59
|
+
shimmerSync: gridShimmerSync,
|
|
60
|
+
stroke: gridStroke
|
|
61
|
+
}
|
|
62
|
+
),
|
|
63
|
+
/* @__PURE__ */ jsx(
|
|
64
|
+
Area,
|
|
65
|
+
{
|
|
66
|
+
curve: curveNatural,
|
|
67
|
+
dataKey: LOADING_DATA_KEY,
|
|
68
|
+
fadeEdges: false,
|
|
69
|
+
fill: "transparent",
|
|
70
|
+
fillOpacity: 0,
|
|
71
|
+
loading: true,
|
|
72
|
+
loadingStroke: stroke,
|
|
73
|
+
loadingStrokeOpacity: strokeOpacity,
|
|
74
|
+
loadingStyle,
|
|
75
|
+
showHighlight: false,
|
|
76
|
+
showLine: true,
|
|
77
|
+
stroke: "transparent",
|
|
78
|
+
strokeWidth: 2
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
var area_chart_loading_default = AreaChartLoading;
|
|
86
|
+
export {
|
|
87
|
+
AreaChartLoading,
|
|
88
|
+
area_chart_loading_default as default
|
|
89
|
+
};
|