|
8 | 8 |
|
9 | 9 | (function ($) {
|
10 | 10 | $(window).on('load', function(){
|
11 |
| - // scroll to the selected chart type. |
12 |
| - $('#chart-select').scrollIntoView(); |
| 11 | + let chart_select = $('#chart-select'); |
| 12 | + if(chart_select.length > 0){ |
| 13 | + // scroll to the selected chart type. |
| 14 | + $('#chart-select')[0].scrollIntoView(); |
| 15 | + } |
13 | 16 | });
|
14 | 17 |
|
15 | 18 | $(document).ready(function () {
|
|
154 | 157 |
|
155 | 158 | /**
|
156 | 159 | * Initialize/Update the available chart list based on their supported renderer libraries.
|
157 |
| - * |
| 160 | + * |
158 | 161 | * @returns {void}
|
159 | 162 | */
|
160 | 163 | function init_available_chart_list() {
|
|
172 | 175 | const rendererTypesMapping = JSON.parse( rendererTypesMappingData );
|
173 | 176 |
|
174 | 177 | document.querySelectorAll('input.type-radio').forEach( chartTypeRadio => {
|
175 |
| - |
| 178 | + |
176 | 179 | // Init the lib based on the default selected chart type.
|
177 | 180 | if ( chartTypeRadio.checked ) {
|
178 | 181 | const chartType = chartTypeRadio.value;
|
|
201 | 204 | }
|
202 | 205 | });
|
203 | 206 | });
|
204 |
| - |
| 207 | + |
205 | 208 | // Update the chart list on user interaction.
|
206 | 209 | rendererSelect.addEventListener('change', (event) => {
|
207 | 210 | disable_renderer_select_placeholder();
|
208 | 211 | toggle_renderer_type( event.target.value );
|
209 | 212 | toggle_chart_types_by_render( event.target.value );
|
210 | 213 | });
|
211 |
| - |
| 214 | + |
212 | 215 | }
|
213 | 216 |
|
214 | 217 | /**
|
|
223 | 226 |
|
224 | 227 | /**
|
225 | 228 | * Toggle the renderer type class based on the given renderer type.
|
226 |
| - * |
| 229 | + * |
227 | 230 | * The class is used to style the chart type picker based on the given renderer library.
|
228 |
| - * |
| 231 | + * |
229 | 232 | * @param {('GoogleCharts' | 'ChartJS' | 'DataTable')} rendererType The renderer type to toggle the class.
|
230 | 233 | */
|
231 | 234 | function toggle_renderer_type( rendererType ) {
|
232 | 235 | const typePicker = document.querySelector('#type-picker');
|
233 | 236 | if ( ! typePicker ) {
|
234 | 237 | return;
|
235 | 238 | }
|
236 |
| - |
| 239 | + |
237 | 240 | typePicker.classList.remove('lib-GoogleCharts', 'lib-ChartJS', 'lib-DataTable');
|
238 | 241 | typePicker.classList.add(`lib-${rendererType}`);
|
239 | 242 | }
|
240 | 243 |
|
241 | 244 | /**
|
242 | 245 | * Toggle chart types based on the given renderer type.
|
243 |
| - * |
| 246 | + * |
244 | 247 | * @param {('GoogleCharts' | 'ChartJS' | 'DataTable')} rendererType The renderer type to filter the chart types.
|
245 | 248 | */
|
246 | 249 | function toggle_chart_types_by_render( rendererType ) {
|
|
786 | 789 | if( chartTypes ) {
|
787 | 790 | document.querySelector('.push-right[type=submit]')?.addEventListener('click', async function (event) {
|
788 | 791 | if ( typeof window.tiTrk !== 'undefined' ) {
|
789 |
| - event.preventDefault(); |
| 792 | + event.preventDefault(); |
790 | 793 | try {
|
791 | 794 | const formData = new FormData(document.querySelector('#viz-types-form'));
|
792 | 795 | const savedData = Object.fromEntries(formData);
|
793 |
| - |
| 796 | + |
794 | 797 | tiTrk?.with('visualizer')?.add({
|
795 | 798 | feature: 'chart-create',
|
796 | 799 | featureComponent: 'saved-data',
|
|
800 | 803 | },
|
801 | 804 | groupId
|
802 | 805 | });
|
803 |
| - |
| 806 | + |
804 | 807 | // Do not make the user to wait too long for the event to be uploaded.
|
805 | 808 | const timer = new Promise((resolve) => setTimeout(resolve, 500));
|
806 | 809 | await Promise.race([timer, tiTrk?.uploadEvents()]);
|
|
0 commit comments