mistercrunch opened a new pull request, #34639:
URL: https://github.com/apache/superset/pull/34639

   ## Summary
   Introduces dataset-level chart defaults that automatically populate when 
users create new charts, significantly improving the user experience by 
reducing repetitive configuration steps and guiding users toward optimal 
visualizations.
   
   ## Motivation
   When creating charts from datasets in Apache Superset, users previously had 
to manually configure all settings from scratch every time. This led to:
   - Repetitive work for common configurations
   - Confusion for new users about which metrics/dimensions to use
   - Inconsistent chart configurations across teams
   - Slower time-to-insight when exploring data
   
   ## Changes
   
   ### Backend (`superset/connectors/sqla/models.py`)
   - Added properties to `SqlaTable` model for managing chart defaults:
     - `default_chart_metadata`: Retrieves chart defaults from the `extra` JSON 
field
     - `default_metric`, `default_dimension`, `default_time_grain`, 
`default_time_range`, `default_row_limit`: Individual default accessors
   - Added `set_default_chart_metadata()` method for updating defaults
   - Stores configuration in existing `extra` field to avoid schema changes
   
   ### Frontend - Dataset Editor 
(`superset-frontend/src/components/Datasource/DatasourceEditor.jsx`)
   - Added "Chart Defaults" configuration section with controls for:
     - Default metric selection
     - Default dimension/groupby column
     - Time grain and time range settings
     - Row limit configuration
     - Adhoc filter defaults
   - Implemented `onChartDefaultChange()` handler for updates
   - Added `cleanupChartDefaults()` to handle column deletions during metadata 
sync
   - Created `parseExtra()` helper for robust JSON parsing
   
   ### Frontend - Chart Creation 
(`superset-frontend/src/explore/actions/hydrateExplore.ts`)
   - Implemented `applyDatasetChartDefaults()` function that:
     - Applies defaults only to new charts (preserves existing charts)
     - Validates that referenced columns/metrics still exist
     - Gracefully handles JSON parsing errors
     - Respects user overrides and existing settings
   - Integrated into explore hydration flow for automatic application
   
   ## User Experience
   
   ### For Dataset Administrators
   1. Navigate to Dataset Editor
   2. Configure desired defaults in the new "Chart Defaults" section
   3. Save dataset with configured defaults
   
   ### For Chart Creators
   1. Click "Create Chart" from a dataset with defaults
   2. Chart opens with pre-populated settings
   3. Can immediately visualize data or adjust as needed
   
   ## Benefits
   - ✨ **Improved onboarding**: New users get sensible starting configurations
   - ⚡ **Faster chart creation**: Common settings are pre-populated
   - 🎯 **Better consistency**: Encourages standard configurations across teams
   - 🔄 **Flexible**: Defaults can be overridden, not enforced
   - 📊 **Discoverability**: Helps users understand recommended 
metrics/dimensions
   
   ## Technical Decisions
   - **Used existing `extra` field**: Avoids database migration, maintains 
backward compatibility
   - **New charts only**: Preserves existing chart configurations
   - **Silent failure handling**: Doesn't block users if defaults are invalid
   - **Native Explore components**: Ensures UI consistency with chart builder
   
   ## Testing Considerations
   - Verify defaults apply correctly to new charts
   - Ensure existing charts remain unaffected
   - Test cleanup when referenced columns are deleted
   - Validate graceful handling of malformed JSON
   - Confirm defaults can be overridden by users
   
   ## Screenshots
   [Dataset Editor - Chart Defaults Section]
   ![Chart Defaults Configuration UI]
   
   [Explore View - Pre-populated Settings]
   ![New Chart with Applied Defaults]
   
   ## Future Enhancements
   - Viz-type specific defaults
   - Multiple named configurations
   - API endpoints for programmatic access
   - Validation for incompatible default combinations
   
   ## Breaking Changes
   None - Feature is backward compatible and opt-in.
   
   ## Related Issues
   Closes #[ISSUE_NUMBER]


-- 
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

Reply via email to