@@ -106,6 +106,29 @@ function _loadDemoData() {
106106 }
107107}
108108
109+ /** Resolve internal series key to a human-readable name. */
110+ function _resolveSeriesDisplayName ( ) {
111+ if ( ! _currentSeriesName || ! _currentData ) return '' ;
112+ // Try data metadata first
113+ const ctx = _currentData . context || { } ;
114+ if ( ctx . series && ctx . season ) return ctx . series + ' ' + ctx . season ;
115+ if ( ctx . series ) return ctx . series ;
116+ // Example: look up label from bundled examples
117+ if ( _currentSeriesName . startsWith ( _EXAMPLE_PREFIX ) ) {
118+ const examples = _loadExamplesData ( ) ;
119+ const key = _currentSeriesName . slice ( _EXAMPLE_PREFIX . length ) ;
120+ if ( examples [ key ] && examples [ key ] . label ) return examples [ key ] . label ;
121+ }
122+ // Demo: derive from data
123+ if ( _currentSeriesName === '__demo__' ) {
124+ const demo = _loadDemoData ( ) ;
125+ const name = demo ? _seriesName ( demo ) : null ;
126+ return name || 'Demo' ;
127+ }
128+ // User-analyzed: the key IS the name
129+ return _currentSeriesName ;
130+ }
131+
109132/** Returns `{key: {label, data}}` for every bundled example, or {}. */
110133function _loadExamplesData ( ) {
111134 const el = document . getElementById ( 'examples-data' ) ;
@@ -232,12 +255,8 @@ function _renderCurrentView() {
232255 // Dropdown already shows the series name — no need to duplicate it.
233256 if ( gridTitle ) gridTitle . textContent = '' ;
234257
235- // Update analytics toolbar series name from the dropdown's visible text
236258 const analyticsName = document . getElementById ( 'analytics-series-name' ) ;
237- if ( analyticsName ) {
238- const sel = document . getElementById ( 'series-select' ) ;
239- analyticsName . textContent = ( sel && sel . selectedOptions . length ) ? sel . selectedOptions [ 0 ] . textContent : '' ;
240- }
259+ if ( analyticsName ) analyticsName . textContent = _resolveSeriesDisplayName ( ) ;
241260
242261 if ( _activeTab === 'grid' && gridContainer ) {
243262 renderGrid ( _currentData , gridContainer ) ;
0 commit comments