Skip to content

Commit 4f0f94f

Browse files
committed
let claude manage writer details somewhere
1 parent 2d22744 commit 4f0f94f

2 files changed

Lines changed: 395 additions & 62 deletions

File tree

CLAUDE.md

Lines changed: 9 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,9 @@ The codebase includes connection string parsing and feature flags for additional
569569

570570
**Responsibility**: Convert DataFrame + Plot → output format (JSON, PNG, R code, etc.)
571571

572-
#### Writer Trait (`mod.rs`)
572+
**Internal Architecture**: For Vega-Lite writer implementation details (unified dataset system, layer rendering pipeline, GeomRenderer lifecycle), see [`src/writer/vegalite/CLAUDE.md`](src/writer/vegalite/CLAUDE.md).
573+
574+
#### Writer Trait
573575

574576
```rust
575577
pub trait Writer {
@@ -578,68 +580,13 @@ pub trait Writer {
578580
}
579581
```
580582

581-
#### Vega-Lite Writer (`vegalite.rs`)
582-
583-
**Current Production Writer** - Fully implemented and tested.
584-
585-
**Features**:
586-
587-
- Converts Plot → Vega-Lite JSON specification
588-
- Multi-layer composition support
589-
- Scale type → Vega field type mapping
590-
- Faceting (wrap and grid layouts)
591-
- Axis label customization
592-
- Inline data embedding
593-
594-
**Architecture**:
583+
#### Available Writers
595584

596-
```rust
597-
impl Writer for VegaLiteWriter {
598-
fn write(&self, df: &DataFrame, spec: &Plot) -> Result<String> {
599-
// 1. Convert DataFrame to JSON values
600-
let data_values = self.dataframe_to_json(df)?;
601-
602-
// 2. Build Vega-Lite spec
603-
let mut vl_spec = json!({
604-
"$schema": "https://vega.github.io/schema/vega-lite/v6.json",
605-
"data": {"values": data_values},
606-
"width": 600,
607-
"autosize": {"type": "fit", "contains": "padding"}
608-
});
609-
610-
// 3. Handle single vs multi-layer
611-
if spec.layers.len() == 1 {
612-
// Single layer: flat structure
613-
vl_spec["mark"] = self.geom_to_mark(&spec.layers[0].geom);
614-
vl_spec["encoding"] = self.build_encoding(&spec.layers[0], df, spec)?;
615-
} else {
616-
// Multi-layer: layered structure
617-
let layers: Vec<Value> = spec.layers.iter()
618-
.map(|layer| {
619-
let mut layer_spec = json!({
620-
"mark": self.geom_to_mark(&layer.geom),
621-
"encoding": self.build_encoding(layer, df, spec)?
622-
});
623-
// Apply axis labels to each layer
624-
apply_axis_labels(&mut layer_spec, &spec.labels);
625-
Ok(layer_spec)
626-
})
627-
.collect::<Result<Vec<_>>>()?;
628-
vl_spec["layer"] = json!(layers);
629-
}
630-
631-
// 4. Add faceting, title, etc.
632-
self.add_faceting(&mut vl_spec, spec)?;
633-
if let Some(labels) = &spec.labels {
634-
if let Some(title) = labels.labels.get("title") {
635-
vl_spec["title"] = json!(title);
636-
}
637-
}
638-
639-
Ok(serde_json::to_string_pretty(&vl_spec)?)
640-
}
641-
}
642-
```
585+
**VegaLiteWriter** (Production-ready):
586+
- Generates Vega-Lite v6 JSON specifications
587+
- Multi-layer composition with unified dataset architecture
588+
- Full support for scales, faceting, projections, and labels
589+
- Automatic geom-specific optimizations (segmentation, decomposition)
643590

644591
---
645592

0 commit comments

Comments
 (0)