@@ -93,7 +93,7 @@ function endpointParams(endpoint: string, params: unknown[]): Record<string, unk
93
93
return r ;
94
94
}
95
95
96
- function patchDataSet ( title : string , color : string ) {
96
+ function patchDataSet ( title : string , color : string , customTitle : string ) {
97
97
return ( dg : DataGroup | null ) => {
98
98
if ( ! dg ) {
99
99
return null ;
@@ -102,6 +102,7 @@ function patchDataSet(title: string, color: string) {
102
102
const d = datasets . find ( ( di ) => di . title === title ) ;
103
103
if ( d ) {
104
104
d . color = color ;
105
+ d . customTitle = customTitle ;
105
106
}
106
107
return d ;
107
108
} ;
@@ -120,12 +121,34 @@ export function initialLoader(datasets: ILinkConfig['datasets']) {
120
121
}
121
122
const key = `${ endpoint } :${ JSON . stringify ( params ) } ` ;
122
123
const existing = loadingDataSets . get ( key ) ;
124
+
125
+ /* eslint-disable @typescript-eslint/restrict-template-expressions */
126
+ let customTitle = title ;
127
+ if ( params . custom_title ) {
128
+ // Custom title present (e.g. from signal documentation) - apply directly
129
+ customTitle = `${ params . custom_title } ` ;
130
+ } else if ( params . _endpoint ) {
131
+ // Derive custom title from params
132
+ customTitle = `${ params . _endpoint } ` ;
133
+ if ( params . data_source && params . signal ) {
134
+ customTitle += ` > ${ params . data_source } :${ params . signal } ` ;
135
+ }
136
+ if ( params . geo_type && params . geo_value ) {
137
+ customTitle += ` > ${ params . geo_type } :${ params . geo_value } ` ;
138
+ }
139
+ if ( params . regions ) {
140
+ customTitle += ` > ${ params . regions } ` ;
141
+ }
142
+ customTitle += ` > ${ title } ` ;
143
+ }
144
+ /* eslint-enable @typescript-eslint/restrict-template-expressions */
145
+
123
146
if ( existing ) {
124
- resolvedDataSets . push ( existing . then ( patchDataSet ( title , color ) ) ) ;
147
+ resolvedDataSets . push ( existing . then ( patchDataSet ( title , color , customTitle ) ) ) ;
125
148
} else {
126
149
const loadingDataSet = func ( params ) ;
127
150
loadingDataSets . set ( key , loadingDataSet ) ;
128
- resolvedDataSets . push ( loadingDataSet . then ( patchDataSet ( title , color ) ) ) ;
151
+ resolvedDataSets . push ( loadingDataSet . then ( patchDataSet ( title , color , customTitle ) ) ) ;
129
152
}
130
153
}
131
154
@@ -156,21 +179,8 @@ export function initialLoader(datasets: ILinkConfig['datasets']) {
156
179
return Promise . all ( resolvedDataSets ) . then ( ( data ) => {
157
180
const cleaned = data . filter ( ( d ) : d is DataSet => d != null ) ;
158
181
cleaned . forEach ( ( d ) => {
159
- if ( d . params && ! Array . isArray ( d . params ) && d . params . _endpoint ) {
160
- /* eslint-disable @typescript-eslint/restrict-template-expressions */
161
- const col_name = d . title ;
162
- d . title = `${ d . params . _endpoint } ` ;
163
- if ( d . params . data_source && d . params . signal ) {
164
- d . title += ` > ${ d . params . data_source } :${ d . params . signal } ` ;
165
- }
166
- if ( d . params . geo_type && d . params . geo_value ) {
167
- d . title += ` > ${ d . params . geo_type } :${ d . params . geo_value } ` ;
168
- }
169
- if ( d . params . regions ) {
170
- d . title += ` > ${ d . params . regions } ` ;
171
- }
172
- d . title += ` > ${ col_name } ` ;
173
- /* eslint-enable @typescript-eslint/restrict-template-expressions */
182
+ if ( d . customTitle ) {
183
+ d . title = d . customTitle ;
174
184
}
175
185
add ( d ) ;
176
186
} ) ;
0 commit comments