Skip to content

Commit 26a825b

Browse files
committed
2026-03-05 Strengthen viz module: dark/light theme, new params, tutorial
1 parent fa6ccf0 commit 26a825b

10 files changed

Lines changed: 665 additions & 99 deletions

File tree

API_SPEC.md

Lines changed: 97 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -637,42 +637,124 @@ result = cv.evaluate(y, modelFactory, period=7) # -> dict
637637

638638
## Visualization API (from vectrix.viz import ...)
639639

640-
> **Optional dependency.** Install with: `pip install vectrix[viz]`
640+
> **Optional dependency.** Install with: `pip install vectrix[viz]` (requires Plotly >= 5.0)
641641
642642
### Individual Charts
643643

644644
```python
645645
from vectrix.viz import forecastChart, dnaRadar, modelHeatmap, scenarioChart, backtestChart, metricsCard
646+
```
647+
648+
#### forecastChart()
649+
650+
```python
651+
forecastChart(
652+
forecastResult, # EasyForecastResult
653+
historical=None, # pd.DataFrame | None — auto-detects date/value columns
654+
title=None, # str | None — auto: "Forecast — {model} (MAPE {mape}%)"
655+
theme="dark" # str — 'dark' or 'light'
656+
) -> go.Figure
657+
```
658+
659+
#### dnaRadar()
660+
661+
```python
662+
dnaRadar(
663+
analysisResult, # EasyAnalysisResult
664+
title=None, # str | None — auto: "DNA — {category} ({difficulty}, {score}/100)"
665+
theme="dark" # str
666+
) -> go.Figure # Polar chart with 6 features: Trend, Seasonality, Memory, Vol.Clustering, Nonlinear, Forecastability
667+
```
668+
669+
#### modelHeatmap()
670+
671+
```python
672+
modelHeatmap(
673+
comparisonDf, # pd.DataFrame — from compare()
674+
top=10, # int — number of top models
675+
title=None, # str | None
676+
theme="dark" # str
677+
) -> go.Figure # Heatmap with min-max normalized errors (green=best, red=worst)
678+
```
679+
680+
#### scenarioChart()
646681

647-
forecastChart(forecastResult, historical=None, title=None) # -> go.Figure
648-
dnaRadar(analysisResult, title=None) # -> go.Figure
649-
modelHeatmap(comparisonDf, top=10, title=None) # -> go.Figure
650-
scenarioChart(scenarios, title=None) # -> go.Figure
651-
backtestChart(backtestResult, title=None) # -> go.Figure
652-
metricsCard(metricsDict, title=None) # -> go.Figure
682+
```python
683+
scenarioChart(
684+
scenarios, # list[ScenarioResult] — from WhatIfAnalyzer.analyze()
685+
dates=None, # list | pd.DatetimeIndex | None — if None, uses numeric steps
686+
title=None, # str | None
687+
theme="dark" # str
688+
) -> go.Figure # Baseline=solid, scenarios=dashed
689+
```
690+
691+
#### backtestChart()
692+
693+
```python
694+
backtestChart(
695+
backtestResult, # BacktestResult — from Backtester.run()
696+
metric="mape", # str — 'mape' or 'rmse'
697+
title=None, # str | None
698+
theme="dark" # str
699+
) -> go.Figure # Bar per fold + average hline, best=green, worst=red
700+
```
701+
702+
#### metricsCard()
703+
704+
```python
705+
metricsCard(
706+
metricsDict, # dict — from BusinessMetrics.calculate()
707+
title=None, # str | None
708+
thresholds=None, # dict | None — custom thresholds
709+
theme="dark" # str
710+
) -> go.Figure # 4 indicator cards: Accuracy, Bias, WAPE, MASE
653711
```
654712

713+
**Default thresholds:** `{'accuracy': 95, 'bias': 3, 'wape': 5, 'mase': 1.0}`. Values beyond threshold turn red.
714+
655715
### Composite Reports
656716

657717
```python
658718
from vectrix.viz import forecastReport, analysisReport
659719

660-
forecastReport(forecastResult, historical=None, title=None) # -> go.Figure (2-row: forecast + metrics)
661-
analysisReport(analysisResult, title=None) # -> go.Figure (2x2: radar + bars + summary)
720+
forecastReport(
721+
forecastResult, # EasyForecastResult
722+
historical=None, # pd.DataFrame | None
723+
title=None, # str | None
724+
theme="dark" # str
725+
) -> go.Figure # 2-row: forecast line chart (75%) + 4 metric bars MAPE/RMSE/MAE/sMAPE (25%)
726+
727+
analysisReport(
728+
analysisResult, # EasyAnalysisResult
729+
title=None, # str | None
730+
theme="dark" # str
731+
) -> go.Figure # 2x2: DNA radar (top-left) + feature bars (top-right) + difficulty indicator (bottom)
662732
```
663733

664734
### Theme Utilities
665735

666736
```python
667-
from vectrix.viz import COLORS, PALETTE, LAYOUT, applyTheme
737+
from vectrix.viz import COLORS, LIGHT_COLORS, PALETTE, LAYOUT, HEIGHT, applyTheme
738+
```
739+
740+
| Export | Type | Description |
741+
|--------|------|-------------|
742+
| `COLORS` | dict | 10 dark theme colors: primary `#6366f1`, accent `#a855f7`, positive `#22c55e`, negative `#ef4444`, warning `#f59e0b`, muted `#94a3b8`, bg `#0f172a`, card `#1e293b`, text `#f1f5f9`, grid `rgba(255,255,255,0.06)` |
743+
| `LIGHT_COLORS` | dict | 10 light theme colors: same keys, adjusted values (bg `#ffffff`, text `#0f172a`) |
744+
| `PALETTE` | list | 10 cycling colors for multi-series charts |
745+
| `LAYOUT` | dict | Plotly layout defaults (dark theme, Inter font, margins) |
746+
| `HEIGHT` | dict | Standard heights: `chart` 450, `card` 220, `report` 600, `analysis` 650, `small` 350 |
668747

669-
COLORS # dict — 10 brand colors (primary, accent, positive, negative, warning, muted, bg, card, text, grid)
670-
PALETTE # list — 10 cycling colors for multi-series charts
671-
LAYOUT # dict — Plotly layout defaults (dark theme, Inter font)
672-
applyTheme(fig, title=None, height=450) # -> go.Figure — apply brand theme to any figure
748+
```python
749+
applyTheme(
750+
fig, # go.Figure
751+
title=None, # str | None
752+
height=450, # int
753+
theme="dark" # str — 'dark' or 'light'
754+
) -> go.Figure # Applies brand theme, legend, grid styling
673755
```
674756

675757
---
676758

677-
*Last updated: 2026-03-04*
759+
*Last updated: 2026-03-05*
678760
*When modifying ANY public API, update this file FIRST.*

0 commit comments

Comments
 (0)