feat(matrixify): implement matrix of any charts as core Superset feature - #34526
Conversation
|
Based on your review schedule, I'll hold off on reviewing this PR until it's marked as ready for review. If you'd like me to take a look now, comment
|
| color: theme.colorText, | ||
| borderColor: theme.colorBorder, | ||
| }, | ||
| textStyle: { |
There was a problem hiding this comment.
bycatch ... fixing Bubble Chart's legend stylin'
| const resourceTypeReports = reportsState[resourceType] || {}; | ||
| const reportData = resourceTypeReports[resourceId]; | ||
|
|
||
| // Debug logging to understand what's happening |
There was a problem hiding this comment.
bycatch, was polluting the logs
|
I love this, great if we can make this work on all charts! I'll take a look at the code tomorrow if it's still open for review then! |
|
The feature is super neat, very dynamic, charts show up instantly as you pick metrics and/or dimension members (most new controls are At first I though it was going to be super messy architecturally (that there would be lots of special cases between Explore, Dashboard and embedded), but by building the feature in |
|
@mistercrunch Processing your ephemeral environment request here. Action: up. More information on how to use or configure ephemeral environments |
|
@mistercrunch Ephemeral environment spinning up at http://18.236.155.237:8080. Credentials are 'admin'/'admin'. Please allow several minutes for bootstrapping and startup. |
…ata fetches - Add shouldRefetchData helper to check if formData changes require new data - Import ChartControlPanelRegistry to access control metadata - Only refetch data when non-renderTrigger controls change - Re-render without fetching for renderTrigger-only changes - Improves performance by avoiding unnecessary API calls for UI-only updates Falls back to refetching if control panel config unavailable for safety.
## Summary Added comprehensive unit test coverage for the Matrixify feature including: 1. **StatefulChart renderTrigger optimization** - Tests for `shouldRefetchData` function that prevents unnecessary data fetches when only UI-only controls change 2. **MatrixifyGridRenderer column wrapping** - Tests for the complex column grouping and wrapping logic in the grid layout 3. **shouldMapStateToProps logic** - Tests for the dynamic state mapping in Matrixify dimension controls 4. **ChartRenderer matrixify change detection** - Tests for the component update logic when matrixify properties change ## Test Coverage Added ### StatefulChart.test.tsx - Tests renderTrigger-only changes (should NOT refetch data) - Tests non-renderTrigger changes (should refetch data) - Tests mixed control changes (should refetch if any non-renderTrigger) - Tests viz_type changes (always refetch) - Tests fallback behavior when no control panel config available - Tests error handling for registry access failures - Tests force prop and chartId changes ### MatrixifyGridRenderer.test.tsx - Tests column grouping logic for dynamic vs fixed column layouts - Tests header visibility with wrapping vs non-wrapping scenarios - Tests grid cell placement in wrapped layouts - Tests edge cases (null grid, empty grid, missing config) - Tests exact division and overflow scenarios for column wrapping ### shouldMapStateToProps.test.tsx - Tests shouldMapStateToProps change detection for both X and Y dimensions - Tests mapStateToProps value mapping from form_data and controls - Tests performance optimization (only checks relevant fields) - Tests fallback behavior and default values - Tests priority of form_data over control values ### ChartRenderer.test.jsx - Tests matrixify property change detection - Tests component update logic for matrixify-enabled charts - Tests nested property changes in matrixify configurations - Tests addition and removal of matrixify properties ## Technical Improvements - **Intelligent data fetching**: StatefulChart now avoids unnecessary API calls when only UI controls change - **Robust column wrapping**: MatrixifyGridRenderer handles complex grid layouts with proper header management - **Dynamic state mapping**: Matrixify controls efficiently detect when recalculation is needed - **Performance optimization**: Change detection focuses only on relevant properties All tests use proper mocking strategies and follow React Testing Library best practices. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add tests for StatefulChart renderTrigger optimization - Add tests for MatrixifyGridRenderer column wrapping logic - Add tests for shouldMapStateToProps in dimension controls - Add tests for ChartRenderer matrixify change detection - Refactor ChartRenderer tests to avoid require() statements 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Flatten nested describe blocks to individual test functions - Improve test organization and readability - Maintain all test functionality while using consistent test() pattern - All 77 tests continue to pass 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Add guideline to CLAUDE.md about using test() instead of describe(): - References Kent C. Dodds' 'avoid nesting when testing' principles - Documents the hard rule of no describe() blocks in new test code - Provides clear guidance for future test file development This captures the requirement and ongoing migration to flat test structure that we've implemented across all new Matrixify test files. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Improve test file organization by co-locating tests with source files: Moved files: - StatefulChart.test.tsx → src/chart/components/ (alongside StatefulChart.tsx) - MatrixifyGridRenderer.test.tsx → src/chart/components/Matrixify/ (alongside MatrixifyGridRenderer.tsx) - matrixify.test.ts → src/chart/types/ (alongside matrixify.ts) - __mocks__/matrixify.ts → src/chart/types/matrixify.mocks.ts (renamed and co-located) Updated import paths in moved test files to reflect new locations. Removed empty __mocks__ directory. Benefits: - Better test discoverability - tests next to source files - Easier maintenance - related files grouped together - Cleaner test directory structure - Follows common testing patterns All tests continue to pass with updated paths. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
ddffffc to
756fe62
Compare
|
@michael-s-molina all comments addressed, checked "download as image" in master and got the same results as on my branch (in my case looked the same, and was imperfect (big number shown but now the canvas/viz)). So very likely unrelated. |
There was a problem hiding this comment.
Thanks for the great feature and for addressing my comments @mistercrunch!
|
Do we know what version this is slated to be included in? |
|
I don't think it made 6.0, so should be 7.0. Hoping we can back-to-back these two! |
…ure (apache#34526) Co-authored-by: Claude <noreply@anthropic.com> (cherry picked from commit e6c8343)
…ure (apache#34526) Co-authored-by: Claude <noreply@anthropic.com> (cherry picked from commit e6c8343)
…ure (apache#34526) Co-authored-by: Claude <noreply@anthropic.com>


Summary
This PR introduces Matrixify - a powerful feature that enables any Superset chart to be displayed as a matrix/grid of charts (similar to Tableau's Trellis charts). This allows users to create small multiples visualizations, comparing the same metric across different dimensions or multiple metrics side-by-side.
What it enables
Gallery
Example use cases
Latest Updates (Aug 14, 2025)
Features Added
Fixes & Improvements
Implementation approach
Instead of implementing Matrixify as a separate visualization or explore-only feature, we integrated it directly into
SuperChartas a core capability. This architectural decision provides several benefits:Key components
Type definitions (
@superset-ui/core):SuperChart integration:
SuperChart.renderChart()MatrixifyGridRendererinstead of the regular chartrawFormData(snake_case) to maintain compatibility with existing APIsGrid generation:
MatrixifyGridGeneratorcreates the grid structure and generates formData for each cellStatefulChart component:
Control panel integration:
MatrixifyDimensionControlfor dimension selection with TopN supportTechnical notes
Future improvements
Testing
Next Steps
Core Features
Polish & UX
Axis Synchronization
Smart Layout Optimization
Enhanced Functionality