mistercrunch opened a new pull request, #34526: URL: https://github.com/apache/superset/pull/34526
## Summary <img width="1720" height="915" alt="Screenshot 2025-08-03 at 3 23 33 AM" src="https://github.com/user-attachments/assets/0c796783-3eb6-4667-be47-b035b3c970d8" /> 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 - **Matrix visualization of any chart type**: Transform any Superset chart into a grid of charts - **Flexible matrix configuration**: - Rows and columns can be configured independently - Use metrics or dimension values for either axis - **Universal availability**: Works in both Explore view and Dashboards - **Recursive composition**: Since Matrixify is implemented at the SuperChart level, it theoretically supports matrices of matrices - **Smart layout**: Automatic grid sizing with configurable row heights and column arrangements ## Example use cases - A simple array of say 6 "Big Number with Trendline" showing 6 different metrics at the top of your dashboard (instead of creating/saving 6 charts) - Compare sales metrics across different regions (rows) and time periods (columns) - Show the same visualization for top 10 products by revenue - Deck .gl, plot detailed maps of different markets side by side (autozoom/autocenter) - stuff your face with as many pie charts as you could dream of - possibilities are endless ## Implementation approach Instead of implementing Matrixify as a separate visualization or explore-only feature, we integrated it directly into `SuperChart` as a core capability. This architectural decision provides several benefits: 1. **Universal availability**: Any place that uses SuperChart (Explore, Dashboard, embedded views) automatically supports Matrixify 2. **Clean architecture**: Matrixify is just another way SuperChart can render charts 3. **Recursive composition**: SuperChart can render grids of SuperCharts, enabling powerful nested visualizations 4. **Minimal code changes**: By working at the SuperChart level, we avoid duplicating logic across different parts of the application ### Key components 1. **Type definitions** (`@superset-ui/core`): - Moved all Matrixify types to the core package for better reusability - Defines the configuration structure for matrix axes 2. **SuperChart integration**: - Added Matrixify detection in `SuperChart.renderChart()` - When enabled, renders `MatrixifyGridRenderer` instead of the regular chart - Passes `rawFormData` (snake_case) to maintain compatibility with existing APIs 3. **Grid generation**: - `MatrixifyGridGenerator` creates the grid structure and generates formData for each cell - Preserves all necessary fields while removing Matrixify-specific configuration - Handles both metric-based and dimension-based axes 4. **StatefulChart component**: - New component that handles data fetching for individual grid cells - Supports dynamic sizing and loading states - Reuses existing chart data fetching logic 5. **Control panel integration**: - Added Matrixify sections to chart control panels - Custom `MatrixifyDimensionControl` for dimension selection - Integrated into existing control panel system ## Technical notes - **FormData handling**: Discovered and resolved snake_case vs camelCase conversion issues between different parts of the system - **CSS/Layout**: Implemented proper flexbox and grid layouts to handle overflow and scrolling - **Performance**: Grid cells are memoized to prevent unnecessary re-renders - **Backwards compatibility**: All changes are additive; existing charts continue to work unchanged ## Future improvements - Add tests for SuperChart Matrixify detection and rendering - Add tests for MatrixifyGridGenerator - Document StatefulChart component for plugin developers - Add user-facing documentation for the Matrixify feature - Fix remaining overflow issues in certain view contexts - Add support for synchronized axes across grid cells - Add export functionality for the entire grid - Performance optimizations for large grids - Add grid cell highlighting/selection features ## Testing - [x] Matrixify works in Explore view - [x] Matrixify works in Dashboard view - [x] Both metric and dimension modes work correctly - [x] TopN dimension selection works - [x] Grid layout adjusts properly with different configurations - [ ] Recursive matrices (matrix of matrices) - theoretical support exists - [ ] All chart types work correctly when matrixified ## Next steps - implement "TopN" dimension values with custom sorting (top 12 countries by population) - allow setting number of chart per rows when you want your TopN to overflow on the next rows, so you can say TOP 50 countries and set 12 per row and you end up with 4 rows and 2 charts on the last row - QA - seems drilling and things like that work ### Polish - [maybe] Figure out the state of the overall matrix and surface it to the user - currently the Matrix appears to Explore or Dashboard as if it runs instantaneously (clock/run-button/...) but the user sees spinners in the individual charts, even if say one chart fails, the matrix always succeed. We could probably gather the state from all the charts, and for the container to be done when all charts are done, any chart fails and container fails, time shows duration to run ALL charts, ... Seems complicated but certainly doable. - `Lock X axis` and `Lock Y axis` controls, allowing forcing/locking yaxis and xaxis across charts. We figure out the min/max of X and/or Y, across all charts, and pass those bounds to the underlying charts. Pretty tricky but doable too. - Smart axis display: only left-most chart shows Yaxis, only Top-most charts show x-axis - not sure if that's worth the trouble ... - SuperChart headers to enable things like CSV export and things like that within the matrix? Refactor code/logic/action from dashboard into SuperChart ... -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org