PageSourceSearch

https://embs.eu/wp-content/plugins/graphina-elementor-charts-and-g…na-charts-for-elementor-public.js?ver=1.8.5

js embs.eu collected 2026-10-01 23:57:00 UTC 42,500 bytes, 1,010 lines download raw bytes

1(function($) {
2    'use strict';
3
4    /**
5     * All of the code for your public-facing JavaScript source
6     * should reside in this file.
7     *
8     * Note: It has been assumed you will write jQuery code here, so the
9     * $ function reference has been prepared for usage within the scope
10     * of this function.
11     *
12     * This enables you to define handlers, for when the DOM is ready:
13     *
14     * $(function() {
15     *
16     * });
17     *
18     * When the window is loaded:
19     *
20     * $( window ).load(function() {
21     *
22     * });
23     *
24     * ...and/or other possibilities.
25     *
26     * Ideally, it is not considered best practise to attach more than a
27     * single DOM-ready or window-load handler for a particular page.
28     * Although scripts in the WordPress core, Plugins and Themes may be
29     * practising this, we should strive to set a better example in our own work.
30     */
31
32    $(window).on('load', function () {
33        let ele = $('.chart-card');
34        addRemoveClass(ele.find('h4'), 'graphina-chart-heading');
35        addRemoveClass(ele.find('p'), 'graphina-chart-sub-heading');
36    });
37
38
39    // Graphina Feature Request For Elementor Panel
40    document.addEventListener('DOMContentLoaded', function() {
41        if (parent.document.querySelector('.elementor-editor-active') !== null) {
42            let _graphina_get_help = '';
43            let _graphina_get_help_url = "https://iqonic.design/feature-request/?for_product=graphina";
44            setInterval(function() {
45                if (parent.document.querySelector('[class*=elementor-control-iq]') != null) {
46                    _graphina_get_help = parent.document.querySelector('#elementor-panel__editor__help__link');
47                    if (_graphina_get_help != null) {
48                        if (_graphina_get_help.getAttribute("href") !== _graphina_get_help_url) {
49                            _graphina_get_help.setAttribute("href", _graphina_get_help_url);
50                            _graphina_get_help.innerHTML = "<b> Graphina Feature Request <i class='eicon-editor-external-link'></i> </b>";
51                        }
52                    }
53                }
54            }, 3000)
55        }
56    });
57
58})(jQuery);
59
60
61/***********************
62 * Variables
63 */
64if (typeof fadein == "undefined") {
65    var fadein = {};
66}
67if (typeof fadeout == "undefined") {
68    var fadeout = {};
69}
70if (typeof isInit == "undefined") {
71    var isInit = {};
72}
73
74const googleChartList = ['area_google','bar_google','column_google','line_google','pie_google','donut_google','gauge_google','geo_google','org_google'];
75
76const manualChartList = ['mixed','brush','gantt_google'];
77
78function graphinNumberWithCommas(x, separator, decimal = -1) {
79    if (isNaN(x)) {
80        return x;
81    }
82    var parts = x.toString().split(".");
83    let val = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, separator);
84
85    if (parts[1]) {
86        if (decimal === -1) {
87            val = val + '.' + parts[1]
88        }else if (decimal !== 0) {
89            val = val + '.' + parts[1].substring(0, decimal)
90        }
91    }
92
93    return val;
94}
95
96function resetGraphinaVars() {
97    if (typeof graphina_localize.graphinaAllGraphs == "undefined") {
98        graphina_localize.graphinaAllGraphs = {};
99    }
100    if (typeof graphina_localize.graphinaAllGraphsOptions == "undefined") {
101        graphina_localize.graphinaAllGraphsOptions = {};
102    }
103    if (typeof graphina_localize.graphinaBlockCharts == "undefined") {
104        graphina_localize.graphinaBlockCharts = {};
105    }
106}
107resetGraphinaVars();
108
109/***************
110 * Jquery Base
111 * @param ele
112 * @param add
113 * @param remove
114 */
115
116function addRemoveClass(ele, add = '', remove = '') {
117    if (remove !== '' && ele.hasClass(add)) ele.removeClass(remove);
118    if (add !== '' && !ele.hasClass(add)) ele.addClass(add);
119}
120
121/************
122 *
123 * @param timestamp
124 * @param isTime
125 * @param isDate
126 * @returns {string}
127 */
128
129function dateFormat(timestamp, isTime = false, isDate = false) {
130    let dateSeparator = '-';
131    let date = new Date(timestamp);
132    let hours = date.getHours();
133    let minutes = "0" + date.getMinutes();
134    let day = date.getDate();
135    let month = date.getMonth() + 1;
136    let year = date.getFullYear()
137    return (isDate ? (day + dateSeparator + month + dateSeparator + year) : '') + (isDate && isTime ? ' ' : '') + (isTime ? (hours + ':' + minutes.substr(-2)) : '');
138}
139
140/********************
141 *
142 * @param date1
143 * @param date2
144 * @returns {string}
145 */
146function timeDifference(date1, date2) {
147    let difference = new Date(date2).getTime() - new Date(date1).getTime();
148
149    let daysDifference = Math.floor(difference / 1000 / 60 / 60 / 24);
150    difference -= daysDifference * 1000 * 60 * 60 * 24
151
152    let hoursDifference = Math.floor(difference / 1000 / 60 / 60);
153    difference -= hoursDifference * 1000 * 60 * 60
154
155    let minutesDifference = Math.floor(difference / 1000 / 60);
156
157    return getPostfix(daysDifference, 'day', 'days') +
158        (daysDifference > 0 && hoursDifference > 0 ? ' ' : '') +
159        getPostfix(hoursDifference, 'hour', 'hours') +
160        (hoursDifference > 0 && minutesDifference > 0 ? ' ' : '') +
161        getPostfix(minutesDifference, 'minute', 'minutes');
162}
163
164/*********************
165 *
166 * @param value
167 * @param postfix1
168 * @param postfix2
169 * @returns {string}
170 */
171function getPostfix(value, postfix1, postfix2) {
172    let result = ''
173    switch (true) {
174        case value === 0:
175            break;
176        case value === 1:
177            result += value + ' ' + postfix1;
178            break;
179        case value > 1:
180            result += value + ' ' + postfix2;
181            break;
182    }
183    return result;
184}
185
186function isInViewport(el) {
187    if (graphina_localize.is_view_port_disable != undefined && graphina_localize.is_view_port_disable == 'on') {
188        return true;
189    }
190    const rect = el.getBoundingClientRect();
191    return (
192        (
193            (rect.top - ((window.innerHeight || document.documentElement.clientHeight) / 2.1)) >= 0 &&
194            (rect.bottom - ((window.innerHeight || document.documentElement.clientHeight) / 1.9)) <= (window.innerHeight || document.documentElement.clientHeight)
195        ) ||
196        (
197            rect.top >= 0 &&
198            rect.bottom <= (window.innerHeight || document.documentElement.clientHeight)
199        )
200    );
201}
202
203function initNowGraphina(myElement, chart, id) {
204    resetGraphinaVars();
205    if (id in graphina_localize.graphinaAllGraphs) {
206        graphina_localize.graphinaAllGraphs[id].destroy();
207        delete graphina_localize.graphinaAllGraphs[id];
208        delete graphina_localize.graphinaBlockCharts[id];
209    }
210    graphina_localize.graphinaAllGraphsOptions[id] = chart;
211    isInit[id] = false;
212    getChart(graphina_localize.graphinaAllGraphsOptions[id].ele, id);
213}
214
215function getChart(myElement, id) {
216    if (typeof ApexCharts == 'function' && myElement !== null &&
217        (id in isInit) && isInit[id] === false) {
218        if ((graphina_localize.is_view_port_disable != undefined && graphina_localize.is_view_port_disable == 'on') || (graphina_localize.graphinaAllGraphsOptions[id].type !== undefined && graphina_localize.graphinaAllGraphsOptions[id].type === 'brush')) {
219            initGraphinaCharts(id);
220        } else {
221            const observer = new IntersectionObserver(enteries => {
222                enteries.forEach(entry => {
223                    if (entry.isIntersecting) {
224                        if (isInit[id] === false) {
225                            initGraphinaCharts(id);
226                        }
227                    }
228                })
229            })
230            observer.observe(myElement);
231        }
232    }
233}
234
235function initGraphinaCharts(id, type = 'area') {
236    if (Object.keys(graphina_localize.graphinaBlockCharts).includes(id)) {
237        if(!googleChartList.includes(type)){
238            if (isInit[id] === true) {
239                graphina_localize.graphinaAllGraphs[id].destroy();
240            }
241        }
242        graphina_localize.graphinaAllGraphsOptions[id].ele.innerHTML = '';
243        graphina_localize.graphinaAllGraphsOptions[id].ele.innerHTML = graphina_localize.graphinaBlockCharts[id];
244    } else {
245        if (isInit[id] === true || graphina_localize.graphinaAllGraphs[id]) {
246            if(googleChartList.includes(type)){
247                graphina_localize.graphinaAllGraphs[id].draw(graphina_localize.graphinaAllGraphsOptions[id].series,graphina_localize.graphinaAllGraphsOptions[id].options);
248            }else{
249                let option = graphina_localize.graphinaAllGraphsOptions[id].options;
250                let series = option.series;
251                // delete option.series;
252                if (type === 'mixed') {
253                    graphina_localize.graphinaAllGraphs[id].updateOptions({
254                        series: option.series,
255                        labels: graphina_localize.graphinaAllGraphsOptions[id].options.category
256                    });
257                } else {
258                    graphina_localize.graphinaAllGraphs[id].updateOptions(option, true, graphina_localize.graphinaAllGraphsOptions[id].animation);
259                    graphina_localize.graphinaAllGraphs[id].updateSeries(series, graphina_localize.graphinaAllGraphsOptions[id].animation);
260                }
261            }
262        } else {
263            if(googleChartList.includes(type)){
264                graphinaGoogleChartRender(id,type)
265            }else{
266                instantInitGraphinaCharts(id,type);
267            }
268        }
269    }
270}
271
272function updateGoogleChartType(defaultType, select, id) {
273    if (graphina_localize.graphinaAllGraphsOptions[id]) {
274        let selectType = select.value;
275        graphina_localize.graphinaAllGraphsOptions[id].renderType = selectType;
276        graphinaGoogleChartRender(id, selectType)
277    }
278}
279
280function updateChartType(defaultvalue, select, id) {
281    var x = select.value;
282    if (defaultvalue == x) {
283        graphina_localize.graphinaAllGraphs[id].updateOptions(graphina_localize.graphinaAllGraphsOptions[id].options);
284        return;
285    }
286    if (x == 'area') {
287        graphina_localize.graphinaAllGraphs[id].updateOptions({
288            chart: {
289                type: x
290            },
291            fill: {
292                opacity: 0.4,
293                pattern: {
294                    width: 6,
295                    height: 6,
296                    strokeWidth: 2
297                }
298            },
299            dataLabels: {
300                offsetY: 0,
301                offsetX: 0
302            },
303            stroke: {
304                show: true,
305                colors: graphina_localize.graphinaAllGraphsOptions[id].options.colors,
306                width: 2
307            }
308        })
309    } else if (x == 'line') {
310        graphina_localize.graphinaAllGraphs[id].updateOptions({
311            chart: {
312                type: x
313            },
314            dataLabels: {
315                offsetY: 0,
316                offsetX: 0
317            },
318            stroke: {
319                show: true,
320                colors: graphina_localize.graphinaAllGraphsOptions[id].options.colors,
321                width: 5
322            }
323        })
324    } else if (x == 'bar') {
325        graphina_localize.graphinaAllGraphs[id].updateOptions({
326            chart: {
327                type: x
328            },
329            fill: {
330                opacity: 0.9,
331            },
332            stroke: {
333                show: true,
334                width: 2,
335                // colors: ['transparent']
336            }
337        })
338    } else if (x == 'pie' || x == 'donut') {
339        graphina_localize.graphinaAllGraphs[id].updateOptions({
340            chart: {
341                type: x
342            },
343            fill: {
344                opacity: 1,
345            },
346        })
347    } else if (x == 'polarArea') {
348        graphina_localize.graphinaAllGraphs[id].updateOptions({
349            chart: {
350                type: x
351            },
352            fill: {
353                opacity: 0.4,
354            },
355            stroke: {
356                show: true,
357                width: 2,
358                colors: graphina_localize.graphinaAllGraphsOptions[id].options.colors,
359            },
360        })
361    } else if (x == 'scatter') {
362        graphina_localize.graphinaAllGraphs[id].updateOptions({
363            chart: {
364                type: x
365            },
366            stroke: {
367                show: true,
368                width: 2,
369                colors: ['transparent']
370            },
371            fill: {
372                opacity: 1
373            },
374            markers: {
375                size: 10,
376            }
377        })
378
379    }
380}
381
382function chartDatalabelsFormat(option, showlabel, showValue, numberformat, prefix, postfix, valueInStringShow, valueInString,forminatorPercentage=false,forminatorDecimal=0) {
383
384    if (showlabel == 'yes' && showValue == 'yes') {
385        return option.dataLabels.formatter = function(val, opt) {
386            let seriesValue = opt.w.config.series[opt.seriesIndex];
387            if (numberformat == "yes") {
388                seriesValue = graphinNumberWithCommas(seriesValue,graphina_localize.thous
388and_seperator)
389            } else {
390                seriesValue = valueInStringShow == 'no' ? seriesValue : graphinaAbbrNum(seriesValue, valueInString);
391            }
392            if(forminatorPercentage){
393                let totals = opt.w.globals.seriesTotals.reduce((a, b) => {
394                    return  a + b;
395                }, 0)
396                if(postfix.trim() === ''){
397                    postfix = '%';
398                }
399                seriesValue =  parseFloat(seriesValue/totals * 100).toFixed(parseInt(forminatorDecimal)) +postfix
400                postfix = '';
401            }
402            return prefix + opt.w.config.labels[opt.seriesIndex] + '-' + seriesValue + postfix
403        }
404    } else if (showlabel == 'yes') {
405        return option.dataLabels.formatter = function(val, opt) {
406            if(forminatorPercentage){
407                let totals = opt.w.globals.seriesTotals.reduce((a, b) => {
408                    return  a + b;
409                }, 0)
410                if(postfix.trim() === ''){
411                    postfix = '%';
412                }
413                val =  parseFloat(val/totals * 100).toFixed(parseInt(forminatorDecimal)) +postfix
414                postfix = '';
415            }
416            return prefix + opt.w.config.labels[opt.seriesIndex] + '-' + parseFloat(val).toFixed(1) + postfix
417        }
418    } else if (showValue == 'yes') {
419        return option.dataLabels.formatter = function(val, opt) {
420            let seriesValue = opt.w.config.series[opt.seriesIndex];
421            if (numberformat == "yes") {
422                seriesValue = graphinNumberWithCommas(seriesValue,graphina_localize.thousand_seperator)
423            } else {
424                seriesValue = valueInStringShow == 'no' ? seriesValue : graphinaAbbrNum(seriesValue, valueInString);
425            }
426            if(forminatorPercentage){
427                let totals = opt.w.globals.seriesTotals.reduce((a, b) => {
428                    return  a + b;
429                }, 0)
430                if(postfix.trim() === ''){
431                    postfix = '%';
432                }
433                seriesValue =  parseFloat(seriesValue/totals * 100).toFixed(parseInt(forminatorDecimal)) +postfix
434                postfix = '';
435            }
436            return prefix + seriesValue + postfix
437        }
438    } else {
439        return option.dataLabels.formatter = function(val, opt) {
440            if(forminatorPercentage){
441                let totals = opt.w.globals.seriesTotals.reduce((a, b) => {
442                    return  a + b;
443                }, 0)
444                if(postfix.trim() === ''){
445                    postfix = '%';
446                }
447                val =  parseFloat(val/totals * 100).toFixed(parseInt(forminatorDecimal)) +postfix
448                postfix = '';
449            }
450            return prefix + parseFloat(val).toFixed(1) + postfix;
451        }
452    }
453
454}
455
456function axisTitle(option, type, title, style, xaxisYoffset = 0) {
457    return option[type]['title'] = {
458        text: title,
459        offsetX: 0,
460        offsetY: type === 'xaxis' ? xaxisYoffset : 0,
461        style,
462    }
463}
464
465
466function instantInitGraphinaCharts(id,type) {
467    graphina_localize.graphinaAllGraphs[id] = new ApexCharts(graphina_localize.graphinaAllGraphsOptions[id].ele, graphina_localize.graphinaAllGraphsOptions[id].options);
468    graphina_localize.graphinaAllGraphs[id].render();
469    isInit[id] = true;
470    // window.wp.hooks.doAction('graphina_apex_chart_render', type,id);
471}
472
473/**
474 * Simple object check.
475 * @param item
476 * @returns {boolean}
477 */
478function isObject(item) {
479    return (item && typeof item === 'object' && !Array.isArray(item));
480}
481
482/**
483 * Deep merge two objects.
484 * @param target
485 * @param sources
486 */
487function mergeDeep(target, ...sources) {
488    if (!sources.length) return target;
489    const source = sources.shift();
490
491    if (isObject(target) && isObject(source)) {
492        for (const key in source) {
493            if (source.hasOwnProperty(key)) {
494                if (isObject(source[key])) {
495                    if (!target[key]) Object.assign(target, {
496                        [key]: {}
497                    });
498                    mergeDeep(target[key], source[key]);
499                } else {
500                    Object.assign(target, {
501                        [key]: source[key]
502                    });
503                }
504            }
505        }
506    }
507
508    return mergeDeep(target, ...sources);
509}
510
511function chunk(array, size) {
512    if (!array) return [];
513    const firstChunk = array.slice(0, size);
514    if (!firstChunk.length) {
515        return array;
516    }
517    return [firstChunk].concat(chunk(array.slice(size, array.length), size));
518}
519
520function graphinaAbbrNum(number, decPlaces) {
521    if (number === undefined || number == null) {
522        return number;
523    }
524    var negativesign = '';
525    if (number < 0) {
526        negativesign = '-';
527        number = Math.abs(number)
528    }
529    if(number < 1000){
530        return negativesign + parseFloat(number).toFixed(decPlaces)
531    }
532    // 2 decimal places => 100, 3 => 1000, etc
533    decPlaces = Math.pow(10, decPlaces);
534
535    // Enumerate number abbreviations
536    var abbrev = ["k", "m", "b", "t"];
537
538    // Go through the array backwards, so we do the largest first
539    for (var i = abbrev.length - 1; i >= 0; i--) {
540
541        // Convert array index to "1000", "1000000", etc
542        var size = Math.pow(10, (i + 1) * 3);
543
544        // If the number is bigger or equal do the abbreviation
545        if (size <= number) {
546            // Here, we multiply by decPlaces, round, and then divide by decPlaces.
547            // This gives us nice rounding to a particular decimal place.
548            number = Math.round(number * decPlaces / size) / decPlaces;
549
550            // Handle special case where we round up to the next abbreviation
551            if ((number == 1000) && (i < abbrev.length - 1)) {
552                number = 1;
553                i++;
554            }
555
556            // Add the letter for the abbreviation
557            number += abbrev[i];
558
559            // We are done... stop
560            break;
561        }
562    }
563
564    return negativesign + number;
565}
566
567function getDataForChartsAjax(request_fields, type, id, selected_field = '',button_filter_value='') {
568
569    if (jQuery('body').hasClass("elementor-editor-active")) {
570        let element_x = parent.document.querySelector('[data-setting="iq_' + type + '_chart_sql_builder_x_columns"]');
571        let element_y = parent.document.querySelector('[data-setting="iq_' + type + '_chart_sql_builder_y_columns"]');
572        if (element_x !== null && element_y !== null) {
573            element_x.innerHTML = '';
574            element_y.innerHTML = '';
575        }
576
577        let element_a = parent.document.querySelector('[data-setting="iq_' + type + '_chart_csv_x_columns"]');
578        let element_b = parent.document.querySelector('[data-setting="iq_' + type + '_chart_csv_y_columns"]');
579        if (element_a !== null && element_b !== null) {
580            element_a.innerHTML = '';
581            element_b.innerHTML = '';
582        }
583    };
584
585    if (request_fields['iq_' + type + '_chart_filter_enable'] != undefined && request_fields['iq_' + type + '_chart_filter_enable'] == 'yes') {
586        selected_field = graphinaGetSelectOptionValue(id);
587    }
588
589    jQuery.ajax({
590        url: graphina_localize.ajaxurl,
591        type: "post",
592        dataType: "json",
593        data: {
594            action: "get_graphina_chart_settings",
595            selected_field: selected_field,
596            button_filter_value:button_filter_value,
597            chart_type: type,
598            chart_id: id,
599            fields: request_fields
600        },
601        success: function(response) {
602            if (document.getElementsByClassName(type + '-chart-' + id).length === 0) {
603                return 0;
604            }
605            if (response.status === true && response.category_count > 0) {
606                jQuery(document).find('.' + type + '-chart-' + id + '-loader').addClass('d-none');
607                jQuery(document).find('.' + type + '-chart-' + id).removeClass('d-none');
608                jQuery(document).find('.' + type + '-chart-' + id).parents('.chart
608-box').removeClass('d-none')
609            } else {
610                if(!(['heatmap', 'candle', 'bubble', 'timeline'].includes(type))){
611                    jQuery(document).find('.' + type + '-chart-' + id).parents('.chart-box').addClass('d-none')
612                    jQuery(document).find('.' + type + '-chart-' + id).addClass('d-none')
613                    jQuery(document).find('.' + type + '-chart-' + id + '-loader').find('img').addClass('d-none');
614                    jQuery(document).find('.' + type + '-chart-' + id + '-loader').removeClass('d-none');
615                    jQuery(document).find('.' + type + '-chart-' + id + '-loader').find('p').removeClass('d-none');
616                    if(!jQuery('body').hasClass("elementor-editor-active")){
617                        return;
618                    }
619                }
620            }
621            if (response.status === true) {
622                if (response.fail === true) {
623                    graphina_localize.graphinaBlockCharts[response.chart_id] = response.fail_message;
624                    initGraphinaCharts(response.chart_id);
625                } else {
626                    if(googleChartList.includes(type)){
627                        if(!['pie_google','donut_google','gauge_google','geo_google','org_google'].includes(type)){
628                            let column = graphina_localize.graphinaAllGraphsOptions[id].series.getNumberOfColumns()
629                            if(column > 0 ){
630                                graphina_localize.graphinaAllGraphsOptions[id].series.removeColumns(0,column)
631                            }
632                            graphina_localize.graphinaAllGraphsOptions[id].series.addColumn('string',response.googlechartData.title);
633                            response.googlechartData.title_array.map((value,key)=>{
634                                graphina_localize.graphinaAllGraphsOptions[id].series.addColumn('number',value);
635                                if(response.googlechartData.annotation_show === 'yes'){
636                                    graphina_localize.graphinaAllGraphsOptions[id].series.addColumn( { role: 'annotation' });
637                                }
638                            })
639                        }
640                        let row = graphina_localize.graphinaAllGraphsOptions[id].series.getNumberOfRows();
641                        if(row > 0){
642                            graphina_localize.graphinaAllGraphsOptions[id].series.removeRows(0,row)
643                        }
644                        graphina_localize.graphinaAllGraphsOptions[id].series.addRows(response.googlechartData.data)
645                        if(['pie_google','donut_google','gauge_google'].includes(type)){
646                            let formatJson = type === 'gauge_google' ?  {
647                                prefix: request_fields['iq_' + type + '_google_chart_value_prefix'] ,
648                                suffix: request_fields['iq_' + type + '_google_chart_value_postfix'],
649                                fractionDigits:  request_fields['iq_' + type + '_google_chart_value_decimal']
650                            } : {
651                                prefix: request_fields['iq_' + type + '_chart_label_prefix'] ,
652                                suffix: request_fields['iq_' + type + '_chart_label_postfix'],
653                                fractionDigits: 0
654                            }
655                            if(graphina_localize.graphinaAllGraphsOptions[id].series.getNumberOfRows() > 0){
656                                var formatter = new google.visualization.NumberFormat(formatJson);
657                                formatter.format( graphina_localize.graphinaAllGraphsOptions[id].series, 1);
658                            }
659                        }
660                        initGraphinaCharts(response.chart_id, type);
661                    }else{
662                        if (response.instant_init === true) {
663                            graphina_localize.graphinaAllGraphsOptions[response.chart_id].animation = false;
664                            instantInitGraphinaCharts(response.chart_id,type);
665                        }
666                        graphina_localize.graphinaAllGraphsOptions[response.chart_id].options = mergeDeep(graphina_localize.graphinaAllGraphsOptions[response.chart_id].options, response.chart_option);
667                        if (isInit[response.chart_id] === true) {
668                            initGraphinaCharts(response.chart_id, type);
669                        }
670                    }
671                }
672
673                if (request_fields['iq_' + type + '_chart_dynamic_data_option'] !== undefined) {
674                    if (request_fields['iq_' + type + '_chart_dynamic_data_option'] === "sql-builder") {
675                        if (jQuery('body').hasClass("elementor-editor-active")) {
676                            setFieldsFromSQLStateMent(request_fields, response, type);
677                        };
678                    }
679                }
680
681                if (request_fields['iq_' + type + '_chart_dynamic_data_option'] !== undefined) {
682                    if (request_fields['iq_' + type + '_chart_dynamic_data_option'] === "csv" || request_fields['iq_' + type + '_chart_dynamic_data_option'] === "remote-csv" || request_fields['iq_' + type + '_chart_dynamic_data_option'] === "google-sheet") {
683                        if (jQuery('body').hasClass("elementor-editor-active")) {
684                            setFieldsForCSV(request_fields, response, type);
685                        };
686                    }
687                }
688
689                if(request_fields['iq_' + type + '_chart_data_option'] !== undefined
690                    && request_fields['iq_' + type + '_chart_data_option'] === 'forminator'){
691                    if(jQuery('body').hasClass("elementor-editor-active")) {
692                        setFieldsFromForminator(request_fields, response, type);
693                    };
694                }
695            }
696        },
697        error: function() {
698            console.log('fail');
699        }
700    });
701
702}
703
704function setFieldsFromSQLStateMent(request_fields, response, type) {
705
706
707    let manualSql = manualChartList;
708    if (manualSql.includes(type)) {
709        if (response.sql_fail !== undefined && response.sql_fail !== '') {
710            let char_element = document.querySelector('[id="' + type + '-chart"]');
711            if (char_element !== null) {
712                char_element.innerHTML = '';
713                char_element.innerHTML = "<div class='text-center' style='color:red'> No data found, Please check your sql statement. </div>";
714            }
715            return;
716        }
717    } else {
718        if (response.extra !== undefined && response.extra.sql_fail !== undefined && response.extra.sql_fail !== '') {
719            let char_element = document.querySelector('[id="' + type + '-chart"]');
720            if (char_element !== null) {
721                char_element.innerHTML = '';
722                char_element.innerHTML = "<div class='text-center' style='color:red'> No data found, Please check your sql statement. </div>";
723            }
724            return;
725        }
726    }
727
728    // graphina pro sql-builder select sql result column
729    let db_columns = manualSql.includes(type) ? response.db_column : response.extra.db_column;
730
731
732    let element_x = parent.document.querySelector('[data-setting="iq_' + type + '_chart_sql_builder_x_columns"]');
733    let element_y = parent.document.querySelector('[data-setting="iq_' + type + '_chart_sql_builder_y_columns"]');
734
735    if (element_x == null || element_y == null) {
736        return;
737    }
738
739    x_option_tag = '';
740    y_option_tag = '';
741
742    if (db_columns !== undefined && db_columns.length !== undefined && db_columns.length > 0) {
743        db_columns.forEach(function(currentValue, index, arr) {
744            x_axis_selected_field = '';
745            y_axis_selected_field = '';
746            if (request_fields['iq_' + type + '_chart_sql_builder_x_columns'].includes(currentValue)) {
747                x_axis_selected_field = 'selected';
748            }
749            if (request_fields['iq_' + type + '_chart_sql_builder_y_columns'].includes(currentValue)) {
750                y_axis_selected_field = 'selected';
751            }
752            x_option_tag += '<option value="' + currentValue.toLowerCase() + '" ' + x_axis_selected_field + ' > ' + currentValue + '</option>';
753            y_option_tag += '<option value="' + currentValue.toLowerCase() + '" ' + y_axis_selected_field + ' > ' + currentValue + '</option>';
754        });
755    }
756
757    element_x.innerHTML = x_option_tag;
758
759    element_y.innerHTML = y_option_tag;
760
761}
762
763function setFieldsForCSV(request_fields, response, type) {
764
765    
766
767    let manualCsv = manualChartList;
768
769    let csv_columns = manualCsv.includes(type) ? response.column : response.extra.column;
770    
771    if (csv_columns !== undefined && csv_columns.length !== undefined && csv_columns.length > 0) {
772
773        let element_x = parent.document.querySelector('[data-setting="iq_' + type + '_chart_csv_x_columns"]');
774
775        let element_y = parent.document.querySelector('[data-setting="iq_' + type + '_chart_csv_y_columns"]');
776
777        if (element_x == null || element_y == null) {
778
779            return;
780        }
781
782        x_option_tag = '';
783        y_option_tag = '';
784
785        csv_columns.forEach(function(currentValue, index, arr) {
786
787
788            x_axis_selected_field = '';
789            y_axis_selected_field = '';
790
791            if (request_fields['iq_' + type + '_chart_csv_x_columns'].includes(currentValue)) {
792                x_axis_selected_field = 'selected';
793            }
794            if (request_fields['iq_' + type + '_chart_csv_y_columns'].includes(currentValue)) {
795                y_axis_selected_field = 'selected';
796            }
797
798            x_option_tag += '<option value="' + currentValue.toLowerCase() + '" ' + x_axis_selected_field + ' > ' + currentValue + '</option>';
799
800            y_option_tag += '<option value="' + currentValue.toLowerCase() + '" ' + y_axis_selected_field + ' > ' + currentValue + '</option>';
801
802
803        });
804        element_x.innerHTML = x_option_tag;
805        element_y.innerHTML = y_option_tag;
806    }
807
808}
809
810function graphinasetCookie(cname, cvalue, exdays) {
811    var d = new Date();
812    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
813    var expires = "expires=" + d.toUTCString();
814    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
815}
816
817function graphinaRestrictedPasswordAjax(form, e) {
818    e.preventDefault()
819    jQuery.ajax({
820        url: graphina_localize.ajaxurl,
821        type: "post",
822        data: jQuery(form).serialize(),
823        success: function(response) {
824            if (response.status === true) {
825                graphinasetCookie(response.chart, true, 1);
826                location.reload();
827            } else {
828                jQuery(form).find('.graphina-error').css('display', 'flex');
829            }
830        }
831    });
832
833
834
835}
836
837function graphinaChartFilter(type, selectedValue, id) {
838    jQuery(document).find('.' + type + '-chart-' + id + '-loader').removeClass('d-none');
839    jQuery(document).find('.' + type + '-chart-' + id + '-loader').find('img').removeClass('d-none');
840    jQuery(document).find('.' + type + '-chart-' + id + '-loader').find('p').addClass('d-none');
841    jQuery(document).find('.' + type + '-chart-' + id).addClass('d-none');
842    jQuery(document).find('.' + type + '-chart-' + id).parents('.chart-box').addClass('d-none')
843    getDataForChartsAjax(graphina_localize.graphinaAllGraphsOptions[id].setting_date, type, id, graphinaGetSelectOptionValue(id));
844
845}
846
847function graphinaGetSelectOptionValue(id) {
848    let option = []
849    let allSelect = document.querySelectorAll('.graphina_filter_select' + id);
850    for (let i = 0; i < allSelect.length; i++) {
851        if(allSelect[i].type !== undefined && ['datetime-local','date'].includes(allSelect[i].type)){
852            if (allSelect[i].value !== undefined) {
853                let formatsign = "-";
854                let date = new Date(allSelect[i].value)
855                if (date !== undefined) {
856                    let formatDate = '';
857                    if (allSelect[i].type === 'date') {
858                        formatDate = date.getFullYear() + formatsign + ("00" + (date.getMonth() + 1)).slice(-2) + formatsign +
859                            ("00" + date.getDate()).slice(-2);
860                    } else {
861                        formatDate = date.getFullYear() + formatsign + ("00" + (date.getMonth() + 1)).slice(-2) + formatsign +
862                            ("00" + date.getDate()).slice(-2) + " " +
863                            ("00" + date.getHours()).slice(-2) + ":" +
864                            ("00" + date.getMinutes()).slice(-2) + ":" +
865                            ("00" + date.getSeconds()).slice(-2);
866                    }
867                    option.push(formatDate)
868                }
869            }
870        }else{
871            if (allSelect[i].value !== undefined || allSelect[i].value !== null) {
872                if (allSelect[i].value !== 'default') {
873                    option.push(allSelect[i].value)
874                } else {
875                    option.push('')
876                }
877            }
878        }
879    }
880    return option;
881}
882
883function graphinaGoogleChartInit(ele, options, id, type) {
884    resetGraphinaVars();
885    if (id in graphina_localize.graphinaAllGraphs) {
886        graphina_localize.graphinaAllGraphs[id].clearChart();
887        delete graphina_localize.graphinaAllGraphs[id];
888        delete graphina_localize.graphinaBlockCharts[id];
889    }
890    isInit[id] = false;
891    graphina_localize.graphinaAllGraphsOptions[id] = options;
892    if (ele !== null) {
893        if (graphina_localize.is_view_port_disable != undefined && graphina_localize.is_view_port_disable == 'on') {
894            graphinaGoogleChartRender(id, type);
895        } else {
896            const observer = new IntersectionObserver(enteries => {
897                enteries.forEach(entry => {
898                    if (entry.isIntersecting) {
899                        if (isInit[id] === false) {
900                            graphinaGoogleChartRender(id, type);
901                        }
902                    }
903                })
904            })
905            observer.observe(ele);
906        }
907    }
908}
909
910function graphinaGoogleChartRender(id, type) {
911    if (isInit[id] === true || graphina_localize.graphinaAllGraphs[id]) {
912        graphina_localize.graphinaAllGraphs[id] = new google.visualization[graphina_localize.graphinaAllGraphsOptions[id].renderType](graphina_localize.graphinaAllGraphsOptions[id].ele);
913        graphina_localize.graphinaAllGraphs[id].draw(graphina_localize.graphinaAllGraphsOptions[id].series, graphina_localize.graphinaAllGraphsOptions[id].options);
914    } else {
915        graphina_localize.graphinaAllGraphs[id] = new google.visualization[graphina_localize.graphinaAllGraphsOptions[id].renderType](graphina_localize.graphinaAllGraphsOptions[id].ele);
916        graphina_localize.graphinaAllGraphs[id].draw(graphina_localize.graphinaAllGraphsOptions[id].series, graphina_localize.graphinaAllGraphsOptions[id].options);
917    }
918    isInit[id] = true;
919    // window.wp.hooks.doAction('graphina_google_chart_render', type,id);
920    
921    if (type === 'gauge_google' && typeof graphina_localize.graphinaAllGraphs[id] != "undefined") {
922        Array.prototype.forEach.call(graphina_localize.graphinaAllGraphsOptions[id].ele.getElementsByTagName('circle'), function(circle) {
923            if (circle.getAttribute('fill') === '#4684ee') {
924                circle.setAttribute('fill', typeof graphina_localize.graphinaAllGraphsOptions[id].ballColor !== "undefined" ? graphina_localize.graphinaAllGraphsOptions[id].ballColor : '#4684ee');
925            }
926            if (circle.getAttribute('fill') === '#f7f7f7') {
927                circle.setAttribute('fill', typeof graphina_localize.graphinaAllGraphsOptions[id].innerCircleColor !== "undefined" ? graphina_localize.graphinaAllGraphsOptions[id].innerCircleColor : '#f7f7f7');
928            }
929            if (circle.getAttribute('fill') === '#cccccc') {
930                circle.setAttribute('fill', typeof graphina_localize.graphinaAllGraphsOptions[id].outerCircleColor !== "undefined" ? graphina_localize.graphinaAllGraphsOptions[id].outerCircleColor : '#cccccc');
931            }
932        });
933        Array.prototype.forEach.call(graphina_localize.graphinaAllGraphsOptions[id].ele.getElementsByTagName('path'), function(path) {
934            if (path.getAttribute('stroke') === '#c63310') {
935                path.setAttribute('stroke', typeof graphina_localize.graphinaAllGraphsOptions[id].needleColor !== "undefined" ? graphina_localize.graphinaAllGraphsOptions[id].needleColor : '#c63310');
936                path.setAttribute('fill', typeof graphina_localize.graphinaAllGraphsOptions[id].needleColor !== "undefined" ? graphina_localize.graphinaAllGraphsOptions[id].needleColor : '#c63310');
937            }
938        });
939    }
940}
941
942function setFieldsFromForminator(request_fields, response, type) {
943    if(request_fields['iq_' + type + '_section_chart_forminator_aggregate'] !== undefined && request_fields['iq_' + type + '_section_chart_forminator_aggregate'] === 'yes'){
944        let element_aggregate = parent.document.querySelector('[data-setting="iq_' + type + '_section_chart_forminator_aggregate_column"]');
945        if (element_aggregate == null) {
946            return;
947        }
948        let manualForminator = manualChartList;
949        let forminator_columns = manualForminator.includes(type) ? response.forminator_columns: response.extra.forminator_columns ;
950        let forminator_columns_labels = manualForminator.includes(type) ? response.forminator_columns_labels: response.extra.forminator_columns_labels ;
951        aggregate_column_option_tag = '' ;
952        if(forminator_columns !== undefined &&  forminator_columns.length !== undefined && forminator_columns.length > 0) {
953            let labels = '';
954            forminator_columns.forEach(function(currentValue, index, arr) {
955                labels = '';
956                labels = forminator_columns_labels !== undefined &&  forminator_columns_labels.length > 0 && forminator_columns_labels[index] !== undefined ? forminator_columns_labels[index] : currentValue;
957                aggregate_column_selected_field = '' ;
958                if(request_fields['iq_' + type + '_section_chart_forminator_aggregate_column'].includes(currentValue)) {
959                    aggregate_column_selected_field = 'selected' ;
960                }
961                aggregate_column_option_tag += '<option value="' + currentValue + '" ' + aggregate_column_selected_field + ' > ' + labels + '</option>' ;
962
963            });
964        }
965        element_aggregate.innerHTML = aggregate_column_option_tag ;
966    }else{
967        let element_x = parent.document.querySelector('[data-setting="iq_' + type + '_section_chart_forminator_x_axis_columns"]');
968        let element_y = parent.document.querySelector('[data-setting="iq_' + type + '_section_chart_forminator_y_axis_columns"]');
969        if (element_x == null || element_y == null) {
970            return;
971        }
972        let manualForminator = manualChartList;
973        // graphina pro sql-builder select sql result column
974        let forminator_columns = manualForminator.includes(type) ? response.forminator_columns: response.extra.forminator_columns ;
975        let forminator_columns_labels = manualForminator.includes(type) ? response.forminator_columns_labels: response.extra.forminator_columns_labels ;
976        x_option_tag = '' ;
977        y_option_tag = '' ;
978        if(forminator_columns !== undefined &&  forminator_columns.length !== undefined && forminator_columns.length > 0) {
979            let labels = '';
980            forminator_columns.forEach(function(currentValue, index, arr) {
981                labels = '';
982                labels = forminator_columns_labels !== undefined &&  forminator_columns_labels.length > 0 && forminator_columns_labels[index] !== undefined ? forminator_columns_labels[index] : currentValue;
983                x_axis_selected_field = '' ;
984                y_axis_selected_field = '' ;
985                if(request_fields['iq_' + type + '_section_chart_forminator_x_axis_columns'].includes(currentValue)) {
986                    x_axis_selected_field = 'selected' ;
987                }
988                if(request_fields['iq_' + type + '_section_chart_forminator_y_axis_columns'].includes(currentValue)) {
989                    y_axis_selected_field = 'selected' ;
990                }
991                x_option_tag += '<option value="' + currentValue + '" ' + x_axis_selected_field + ' > ' + labels + '</option>' ;
992                y_option_tag += '<option value="' + currentValue + '" ' + y_axis_selected_field + ' > ' + labels + '</option>' ;
993            });
994        }
995        element_x.innerHTML = x_option_tag ;
996        element_y.innerHTML = y_option_tag ;
997    }
998}
999
1000function graphina_google_chart_ajax_reload(callAjax,type,chart_id,ajaxReload,ajaxIntervalTime){
1001    let setting = graphina_localize.graphinaAllGraphsOptions[chart_id].setting_date;
1002    if(typeof getDataForChartsAjax !== "undefined" && callAjax === "1") {
1003        getDataForChartsAjax(setting, type, chart_id);
1004        if(ajaxReload === 'true'){
1005            window['ajaxIntervalGraphina_' + chart_id] = setInterval(function () {
1006                getDataForChartsAjax(setting, type, chart_id);
1007            }, parseInt(ajaxIntervalTime * 1000));
1008        }
1009    }
1010}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.