Metadata-Version: 2.4
Name: codechu-spark
Version: 0.2.0
Summary: Stdlib-only text visualizations — sparklines, mini bar charts, heatmaps.
Author: Codechu
License: MIT License
        
        Copyright (c) 2026 Codechu
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/codechu/spark-py
Project-URL: Source, https://github.com/codechu/spark-py
Project-URL: Issues, https://github.com/codechu/spark-py/issues
Keywords: sparkline,bar-chart,heatmap,ascii,terminal,stdlib
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Terminals
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.1; extra == "dev"
Requires-Dist: ruff>=0.4; extra == "dev"
Dynamic: license-file

```text
   c o d e c h u  ·  s p a r k
   ▁▂▃▄▅▆▇█▇▆▅▄▃▂▁▂▄▆█▆▄▂▁▃▅▇█▇▅▃▁▂▅█▅▂▁▄▇▄▁▂▆█▆▂▁▃▇▇▃▁
   ── one line. one glance. one truth about your data. ──
```

> *Unicode sparklines, mini bar charts, and 1-D heatmaps — pure text.*

# codechu-spark

Stdlib-only text visualizations — Unicode sparklines, labeled mini
bar charts, 1D heatmaps — extracted from the [Disk Cleaner](https://github.com/codechu/disk-cleaner)
toolchain. No external dependencies. Python 3.10+.

## Install

```bash
pip install codechu-spark
```

## API

### `sparkline(values, *, width=None, chars="▁▂▃▄▅▆▇█")`

```python
from codechu_spark import sparkline

sparkline([1, 3, 7, 2, 5])                # → '▁▃█▂▅'
sparkline(list(range(100)), width=10)     # downsampled by averaging
sparkline([1, 2, 3], chars=".-=#")        # custom glyphs
```

- `width=None` → one glyph per value
- `width<len(values)` → downsample by averaging consecutive buckets
- `width>len(values)` → render at `len(values)` (no upsampling)
- Empty list → `''`; all-equal → first glyph repeated

### `bar_chart(items, *, width=40, char="█")`

```python
from codechu_spark import bar_chart

print(bar_chart([
    ("python", 42),
    ("rust",   17),
    ("go",     8),
], width=20))
# python  ████████████████████  42
# rust    ████████              17
# go      ███                    8
```

Bars are scaled to the maximum value. Labels are left-aligned to the
longest label. Negative values clip to a zero-width bar.

### `heatmap(values, *, chars=" ░▒▓█")`

```python
from codechu_spark import heatmap

heatmap([0, 1, 2, 3, 4])     # → ' ░▒▓█'
heatmap([0, 5, 10], chars=".oO")
```

A denser-than-sparkline row. Useful for per-bucket load,
hour-of-day utilization, or any single-row intensity readout.

## Design

- **Pure stdlib.** Zero third-party dependencies.
- **Single-row primitives.** Each function returns a string (with
  embedded newlines for `bar_chart`); no terminal control codes, no
  cursor movement — that's a separate concern.
- **Custom glyphs welcome.** Pass any `chars` string ordered low → high.

## Tests

```bash
pip install -e ".[dev]"
pytest -q
```

Coverage gate: ≥90 %.

## License

MIT — see [LICENSE](LICENSE).
