# Chartexa — High-Performance Charting for Python

[![PyPI](https://img.shields.io/pypi/v/chartexa?label=PyPI&color=blue)](https://pypi.org/project/chartexa)
[![Python](https://img.shields.io/pypi/pyversions/chartexa)](https://pypi.org/project/chartexa)
[![License](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/redrum88/Chartexa/blob/main/LICENSE)

> Render publication-quality charts in Python using the Chartexa .NET engine — 40+ series types, real-time streaming, Jupyter integration, and GPU-accelerated rendering.

---

## Installation

```bash
pip install chartexa
```

### Prerequisites

- **Python 3.9+**
- [**.NET 10 Runtime**](https://dotnet.microsoft.com/download) installed on your system

---

## Quick Start

### One-liner

```python
import chartexa as cx

cx.line([10, 20, 15, 30, 25]).save("chart.png")
```

### Fluent API

```python
import chartexa as cx

(cx.Chart(800, 600)
    .line([1, 2, 3, 4], [10, 20, 15, 30], stroke="#4FC3F7", label="Revenue")
    .scatter([1, 2, 3, 4], [12, 18, 17, 28], fill="red", label="Targets")
    .save("multi_series.png"))
```

### Financial Chart

```python
import chartexa as cx
import pandas as pd

df = pd.read_csv("stock_data.csv")
cx.candlestick(df).save("candlestick.png")
```

### Multi-Panel Dashboard

```python
import chartexa as cx

fig, axes = cx.subplots(2, 2)
axes[0, 0].line([1, 2, 3], [10, 20, 15])
axes[0, 1].scatter([1, 2, 3], [30, 10, 25])
axes[1, 0].bar(["A", "B", "C"], [40, 60, 30])
axes[1, 1].mountain([1, 2, 3], [5, 15, 10])
fig.save("dashboard.png")
```

### Real-Time Streaming

```python
import chartexa as cx

chart = cx.Chart()
with chart.begin_update():
    chart.line(sensor_x, sensor_y, label="Temperature")
    chart.line(sensor_x, humidity_y, label="Humidity")
chart.save("sensors.png")
```

---

## Features

### 40+ Series Types

| Category | Series |
|----------|--------|
| **Basic** | Line, Scatter, Column, Bar, Mountain, Band, Bubble |
| **Financial** | Candlestick, OHLC |
| **Statistical** | BoxPlot, ErrorBar, Fan, Heatmap, Pie, Donut |
| **Stacked** | StackedBar, StackedColumn, StackedMountain |
| **Polar** | Polar, Radar |
| **Scientific** | Oscilloscope, SpectrumAnalyzer, Waterfall, Lissajous, BodePlot, NyquistPlot |
| **Instruments** | Gauges (Angular, Radial, Linear), Thermometer, Compass, VuMeter |
| **Digital** | DigitalLine, DigitalBand, LogicAnalyzer, EyeDiagram, ConstellationDiagram |
| **Geospatial** | GpsTrack, SkyView, RadarSweep |
| **Widgets** | Alarm, Battery, PowerMeter, StatusLamp |
| **3D** | XYZSurface |

### Interactive Modifiers

Zoom/pan, tooltips, crosshair, cursor, rubber-band zoom, data point selection, and series selection.

### Theming & Styling

Built-in themes, custom colors (hex, RGB, CSS names), dash patterns, markers, and gradient palettes.

### Axes

Numeric, DateTime, Logarithmic, and Category axes with full customization.

### Data Sources & Streaming

Connect to MQTT, WebSocket, REST, gRPC, Serial (Arduino/ESP32), GPS, Audio, System Metrics, Docker, Market Data, OBD-II, CAN Bus, SDR, Flight Sims, Racing Sims, and more.

### Data Transforms

Built-in `moving_average`, `exponential_smoothing`, `derivative`, `integral`, `low_pass_filter`, `high_pass_filter`, `bollinger_bands`, and more.

### Performance & Large Data

- **LTTB downsampling** — visually lossless reduction for million-point datasets
- **Min/Max downsampling** — preserves extrema for financial/sensor data
- **FIFO ring buffer** — fixed-capacity streaming with automatic eviction
- **Batch updates** — `chart.begin_update()` suspends rendering for bulk operations
- **NumPy/Pandas integration** — pass arrays directly, zero-copy where possible

### Layout & Dashboards

- `subplots(rows, cols)` — matplotlib-style grid layouts
- `Figure` / `Dashboard` — named panels with row/col spans
- Constraint-based sizing (fixed + proportional)

### Jupyter & Notebook Integration

- Auto-detected in Jupyter, VS Code, Colab, Kaggle, and more
- `display_chart()` renders inline
- `ChartWidget` for interactive ipywidgets
- `%cx` / `%%cx` magic commands
- Colab GPU/CPU/TPU runtime detection

### Export Formats

- **PNG** — `chart.save("chart.png")` or `chart.to_bytes()`
- **HTML** — `chart.to_html()` / `chart.save_html("chart.html")`
- **Inline** — `chart.show()` (opens in browser or displays in notebook)

---

## How It Works

Chartexa for Python uses [pythonnet](https://github.com/pythonnet/pythonnet) to call into the Chartexa .NET charting engine. The Python package bundles the compiled .NET assemblies and provides a Pythonic API with fluent method chaining, NumPy/Pandas interop, and Jupyter integration.

```
Python API → pythonnet bridge → Chartexa .NET Engine → SkiaSharp renderer → PNG/HTML
```

---

## Links

- [GitHub Repository](https://github.com/redrum88/Chartexa)
- [NuGet Packages](https://www.nuget.org/profiles/Kedevo) (C# libraries)
- [Changelog](https://github.com/redrum88/Chartexa/blob/main/CHANGELOG.md)

## License

MIT — see [LICENSE](https://github.com/redrum88/Chartexa/blob/main/LICENSE) for details.
