Skip to content

Conversation

@skokenes
Copy link
Contributor

@skokenes skokenes commented Jul 21, 2025

Summary

This PR adds support for nested data structures in line charts, allowing visualization of hierarchical Malloy query results. Users can now specify nested field paths using intuitive dot notation (e.g., x='monthly_sales.dcId').

Key Changes

  • Dot notation support: Users can specify nested fields using field1.field2 syntax in viz tags
  • Automatic field detection: Intelligently detects series, x, and y fields from nested data structures
  • Data flattening: Transforms nested Malloy data into a flat structure suitable for Vega visualization
  • Placeholder Field objects: Creates proper Field interface implementations for nested fields with all required properties including tag

Example Usage

# viz=line { series=department x='monthly_sales.dcId' y='monthly_sales.total_sales' }
view: nested_line_explicit_paths is {
  group_by: department
  nest: monthly_sales is {
    group_by: dcId
    aggregate: total_sales
  }
}
CleanShot 2025-07-21 at 16 33 30@2x

Implementation Details

  • Field paths are converted from dot notation to JSON arrays internally for compatibility with Malloy's path resolution
  • Nested data is flattened in the mapMalloyDataToChartData function before passing to Vega
  • Auto-detection prioritizes nested fields when available, using outer dimensions for series and inner fields for x/y axes
  • Fields tagged with "tooltip" are excluded from automatic detection

Testing

  • Updated existing story examples to use dot notation
  • All builds pass successfully
  • Line charts render correctly with nested data

… notation

- Enable line charts to accept nested Malloy query data as input
- Support dot notation for field paths (e.g., x='monthly_sales.dcId')
- Implement automatic field detection for nested data structures
- Add flattening logic to transform nested data for Vega visualization
- Create placeholder Field objects with required properties including tag
- Update story examples to demonstrate nested line chart usage

The implementation prioritizes nested data detection over flat data when
auto-detecting fields, with series using outer dimensions and x/y using
inner nested fields.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@skokenes skokenes marked this pull request as draft July 21, 2025 20:32
@skokenes skokenes changed the title feat(malloy-render): Add nested data support for line charts with dot notation feat: Add nested data support for line charts Jul 21, 2025
@lloydtabb
Copy link
Collaborator

Love this. Going to be a big deal when it is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants