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).load(() => { 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 $(document).ready(function(){ 39 setTimeout(() => { 40 window.scrollTo(0, window.pageYOffset + 1); 41 window.scrollTo(0, window.pageYOffset - 1); 42 },800); 43 }); 44 45 // Graphina Feature Request For Elementor Panel 46 document.addEventListener('DOMContentLoaded', function() { 47 if(parent.document.querySelector('.elementor-editor-active') !== null) { 48 let _graphina_get_help = '' ; 49 let _graphina_get_help_url = "https://iqonic.design/feature-request/?for_product=graphina" ; 50 setInterval( function() { 51 if(parent.document.querySelector('[class*=elementor-control-iq]') != null) { 52 _graphina_get_help = parent.document.querySelector('#elementor-panel__editor__help__link'); 53 if(_graphina_get_help != null) { 54 if( _graphina_get_help.getAttribute("href") !== _graphina_get_help_url ) { 55 _graphina_get_help.setAttribute("href", _graphina_get_help_url ); 56 _graphina_get_help.innerHTML = "<b> Graphina Feature Request <i class='eicon-editor-external-link'></i> </b>" ; 57 } 58 } 59 } 60 }, 3000) 61 } 62 }); 63 64})(jQuery); 65 66 67/*********************** 68 * Variables 69 */ 70if (typeof fadein == "undefined") { 71 var fadein = {}; 72} 73if (typeof fadeout == "undefined") { 74 var fadeout = {}; 75} 76if (typeof isInit == "undefined") { 77 var isInit = {}; 78} 79 80function resetGraphinaVars(){ 81 if(typeof graphina_localize.graphinaAllGraphs == "undefined"){ 82 graphina_localize.graphinaAllGraphs = {}; 83 } 84 if(typeof graphina_localize.graphinaAllGraphsOptions == "undefined"){ 85 graphina_localize.graphinaAllGraphsOptions = {}; 86 } 87 if(typeof graphina_localize.graphinaBlockCharts == "undefined"){ 88 graphina_localize.graphinaBlockCharts = {}; 89 } 90} 91resetGraphinaVars(); 92 93/*************** 94 * Jquery Base 95 * @param ele 96 * @param add 97 * @param remove 98 */ 99 100function addRemoveClass(ele, add = '', remove = '') { 101 if (remove !== '' && ele.hasClass(add)) ele.removeClass(remove); 102 if (add !== '' && !ele.hasClass(add)) ele.addClass(add); 103} 104 105/************ 106 * 107 * @param timestamp 108 * @param isTime 109 * @param isDate 110 * @returns {string} 111 */ 112 113function dateFormat(timestamp, isTime = false, isDate = false) { 114 let dateSeparator = '-'; 115 let date = new Date(timestamp); 116 let hours = date.getHours(); 117 let minutes = "0" + date.getMinutes(); 118 let day = date.getDate(); 119 let month = date.getMonth() + 1; 120 let year = date.getFullYear() 121 return (isDate ? (day + dateSeparator + month + dateSeparator + year) : '') + (isDate && isTime ? ' ' : '') + (isTime ? (hours + ':' + minutes.substr(-2)) : ''); 122} 123 124/******************** 125 * 126 * @param date1 127 * @param date2 128 * @returns {string} 129 */ 130function timeDifference(date1, date2) { 131 let difference = new Date(date2).getTime() - new Date(date1).getTime(); 132 133 let daysDifference = Math.floor(difference / 1000 / 60 / 60 / 24); 134 difference -= daysDifference * 1000 * 60 * 60 * 24 135 136 let hoursDifference = Math.floor(difference / 1000 / 60 / 60); 137 difference -= hoursDifference * 1000 * 60 * 60 138 139 let minutesDifference = Math.floor(difference / 1000 / 60); 140 141 return getPostfix(daysDifference, 'day', 'days') 142 + (daysDifference > 0 && hoursDifference > 0 ? ' ' : '') 143 + getPostfix(hoursDifference, 'hour', 'hours') 144 + (hoursDifference > 0 && minutesDifference > 0 ? ' ' : '') 145 + getPostfix(minutesDifference, 'minute', 'minutes'); 146} 147 148/********************* 149 * 150 * @param value 151 * @param postfix1 152 * @param postfix2 153 * @returns {string} 154 */ 155function getPostfix(value, postfix1, postfix2) { 156 let result = '' 157 switch (true) { 158 case value === 0: 159 break; 160 case value === 1: 161 result += value + ' ' + postfix1; 162 break; 163 case value > 1: 164 result += value + ' ' + postfix2; 165 break; 166 } 167 return result; 168} 169 170 171/******************* 172 * 173 * @param svg 174 * @param mainId 175 */ 176 177function adjustSize(svg, mainId) { 178 const innerHeight = getInnerHeightWidth(document.querySelector('#animated-radial_' + mainId), 'height'); 179 const innerWidth = getInnerHeightWidth(document.querySelector('#animated-radial_' + mainId), 'width'); 180 svg[mainId].attr("width", innerWidth).attr("height", innerHeight); 181} 182 183/************************ 184 * 185 * @param elm 186 * @param type 187 * @returns {number} 188 */ 189 190function getInnerHeightWidth(elm, type) {
191 let computed = getComputedStyle(elm); 192 let padding = 0; 193 let val = 0; 194 switch (type) { 195 case 'height': 196 padding = parseInt(computed.paddingTop) + parseInt(computed.paddingBottom); 197 val = elm.clientHeight - padding; 198 break; 199 case 'width': 200 padding = parseInt(computed.paddingLeft) + parseInt(computed.paddingRight); 201 val = elm.clientWidth - padding; 202 break; 203 } 204 return val; 205} 206 207/********************************** 208 * 209 * @param main_id 210 * @param n 211 * @param g 212 * @param interval 213 * @param animeSpeed 214 * @param bars 215 * @param animatedRadialChartHeight 216 */ 217 218function update(main_id, n = [], g = [], interval = [], animeSpeed = [], bars = [], animatedRadialChartHeight = []) { 219 if (typeof g[main_id] === "undefined") { 220 clearInterval(interval[main_id]); 221 } 222 223 n[main_id] += parseFloat(animeSpeed[main_id]); 224 g[main_id].selectAll("rect") 225 .data(bars[main_id]) 226 .attr("width", d => (parseFloat(animatedRadialChartHeight[main_id]) + noise.perlin3(d, 1, n[main_id]) * 160)); 227} 228 229/**************************************** 230 * 231 * @param main_id 232 * @param svg 233 * @param g 234 * @param bars 235 * @param radialGradient 236 * @param animatedRadialChartColor 237 * @param animatedRadialChartLineSpace 238 */ 239 240function drawBars(main_id, svg, g, bars, radialGradient, animatedRadialChartColor, animatedRadialChartLineSpace) { 241 if (typeof svg[main_id] !== "undefined") { 242 d3.selectAll("#animated-radial_" + main_id + " svg > *").remove(); 243 } 244 svg[main_id] = d3.select("#animated-radial_" + main_id + " svg"); 245 adjustSize(svg, main_id) 246 247 g[main_id] = svg[main_id].append("g").attr("transform", `translate(${960 / 2},${560 / 2})`); 248 249 bars[main_id] = d3.range(0, 120); 250 251 radialGradient[main_id] = svg[main_id] 252 .append("defs") 253 .append("radialGradient") 254 .attr("id", "radial-gradient-" + main_id) 255 .attr("gradientUnits", "userSpaceOnUse") 256 .attr("cx", 0) 257 .attr("cy", 0) 258 .attr("r", "30%"); 259 260 radialGradient[main_id] 261 .append("stop") 262 .attr("offset", "60%") 263 .attr("stop-color", animatedRadialChartColor[main_id].gradient_1); 264 265 radialGradient[main_id] 266 .append("stop") 267 .attr("offset", "100%") 268 .attr("stop-color", animatedRadialChartColor[main_id].gradient_2); 269 270 g[main_id].append("circle") 271 .attr("cx", 0) 272 .attr("cy", 0) 273 .attr("r", 80) 274 .attr("stroke", animatedRadialChartColor[main_id].stroke_color) 275 .attr("fill", "none") 276 .attr("text", "none"); 277 278 g[main_id].selectAll("rect") 279 .data(bars[main_id]) 280 .enter() 281 .append("rect") 282 .attr("x", 100) 283 .attr("y", 0) 284 .attr("width", 100) 285 .attr("height", 6) 286 .attr("fill", "url(#radial-gradient-" + main_id + ")") 287 .attr("transform", d => `rotate(${d * animatedRadialChartLineSpace[main_id]})`); 288} 289 290/************************************ 291 * 292 * @param mainId 293 * @param svg 294 * @param g 295 * @param bars 296 * @param radialGradient 297 * @param animatedRadialChartColor 298 * @param animatedRadialChartLineSpace 299 * @param n 300 * @param interval 301 * @param animeSpeed 302 * @param animatedRadialChartHeight 303 */ 304 305function initAnimatedRadial(mainId, svg, g, bars, radialGradient, animatedRadialChartColor, animatedRadialChartLineSpace, n, interval, animeSpeed, animatedRadialChartHeight) { 306 window.addEventListener("resize", () => { 307 adjustSize(svg, mainId) 308 }); 309 drawBars(mainId, svg, g, bars, radialGradient, animatedRadialChartColor, animatedRadialChartLineSpace) 310 update(mainId, n, g, interval, animeSpeed, bars, animatedRadialChartHeight); 311 if (typeof interval !== undefined && typeof interval[mainId] !== undefined) { 312 adjustSize(svg, mainId); 313 drawBars(mainId, svg, g, bars, radialGradient, animatedRadialChartColor, animatedRadialChartLineSpace) 314 clearInterval(interval[mainId]); 315 } 316 interval[mainId] = setInterval(function () { 317 update(mainId, n, g, interval, animeSpeed, bars, animatedRadialChartHeight); 318 }, 50); 319} 320 321function isInViewport(el) { 322 if(graphina_localize.is_view_port_disable != undefined && graphina_localize.is_view_port_disable == 'on'){ 323 return true; 324 } 325 const rect = el.getBoundingClientRect(); 326 return ( 327 ( 328 (rect.top - ((window.innerHeight || document.documentElement.clientHeight) / 2.1)) >= 0 && 329 (rect.bottom - ((window.innerHeight || document.documentElement.clientHeight) / 1.9)) <= (window.innerHeight || document.documentElement.clientHeight) 330 ) 331 || 332 ( 333 rect.top >= 0 && 334 rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) 335 ) 336 ); 337} 338 339function initNowGraphina(myElement, chart, id) { 340 resetGraphinaVars(); 341 if (id in graphina_localize.graphinaAllGraphs) { 342 graphina_localize.graphinaAllGraphs[id].destroy(); 343 delete graphina_localize.graphinaAllGraphs[id]; 344 delete graphina_localize.graphinaBlockCharts[id]; 345 } 346 graphina_localize.graphinaAllGraphsOptions[id] = chart; 347 isInit[id] = false;
348 getChart(graphina_localize.graphinaAllGraphsOptions[id].ele, id); 349 document.addEventListener('scroll', function () { 350 getChart(graphina_localize.graphinaAllGraphsOptions[id].ele, id); 351 }); 352} 353 354function getChart(myElement, id) { 355 if (typeof ApexCharts == 'function' && myElement !== null 356 && isInViewport(myElement) && (id in isInit) && isInit[id] === false) { 357 setTimeout(() => { 358 if (isInit[id] === false) { 359 initGraphinaCharts(id); 360 } 361 },1000); 362 } 363} 364 365function initGraphinaCharts(id,type='area') { 366 if(Object.keys(graphina_localize.graphinaBlockCharts).includes(id)){ 367 if (isInit[id] === true){ 368 graphina_localize.graphinaAllGraphs[id].destroy(); 369 } 370 graphina_localize.graphinaAllGraphsOptions[id].ele.innerHTML=''; 371 graphina_localize.graphinaAllGraphsOptions[id].ele.innerHTML = graphina_localize.graphinaBlockCharts[id]; 372 } else { 373 if (isInit[id] === true || graphina_localize.graphinaAllGraphs[id]) { 374 let option = graphina_localize.graphinaAllGraphsOptions[id].options; 375 let series = option.series; 376 // delete option.series; 377 if(type === 'mixed'){ 378 graphina_localize.graphinaAllGraphs[id].updateOptions({ 379 series:option.series, 380 labels:graphina_localize.graphinaAllGraphsOptions[id].options.category 381 }); 382 }else{ 383 graphina_localize.graphinaAllGraphs[id].updateOptions(option, true, graphina_localize.graphinaAllGraphsOptions[id].animation); 384 graphina_localize.graphinaAllGraphs[id].updateSeries(series, graphina_localize.graphinaAllGraphsOptions[id].animation); 385 } 386 } else { 387 graphina_localize.graphinaAllGraphs[id] = new ApexCharts(graphina_localize.graphinaAllGraphsOptions[id].ele, graphina_localize.graphinaAllGraphsOptions[id].options); 388 graphina_localize.graphinaAllGraphs[id].render(); 389 isInit[id] = true; 390 } 391 } 392} 393 394function updateChartType(defaultvalue,select,id){ 395 var x = select.value; 396 if(defaultvalue == x){ 397 graphina_localize.graphinaAllGraphs[id].updateOptions(graphina_localize.graphinaAllGraphsOptions[id].options); 398 return; 399 } 400 if( x == 'area'){ 401 graphina_localize.graphinaAllGraphs[id].updateOptions({ 402 chart: { 403 type: x 404 }, 405 fill:{ 406 opacity:0.4, 407 pattern:{ 408 width: 6, 409 height: 6, 410 strokeWidth: 2 411 } 412 }, 413 dataLabels:{ 414 offsetY:0, 415 offsetX:0 416 }, 417 stroke:{ 418 show:true, 419 colors:graphina_localize.graphinaAllGraphsOptions[id].options.colors, 420 width:2 421 } 422 }) 423 }else if(x == 'line'){ 424 graphina_localize.graphinaAllGraphs[id].updateOptions({ 425 chart: { 426 type: x 427 }, 428 dataLabels:{ 429 offsetY:0, 430 offsetX:0 431 }, 432 stroke: { 433 show:true, 434 colors:graphina_localize.graphinaAllGraphsOptions[id].options.colors, 435 width:5 436 } 437 }) 438 } 439 else if(x == 'bar'){ 440 graphina_localize.graphinaAllGraphs[id].updateOptions({ 441 chart: { 442 type: x 443 }, 444 fill:{ 445 opacity:0.9, 446 }, 447 stroke: { 448 show: true, 449 width: 2, 450 // colors: ['transparent'] 451 } 452 }) 453 }else if(x == 'pie' || x == 'donut'){ 454 graphina_localize.graphinaAllGraphs[id].updateOptions({ 455 chart: { 456 type: x 457 }, 458 fill:{ 459 opacity:1, 460 }, 461 }) 462 }else if(x == 'polarArea'){ 463 graphina_localize.graphinaAllGraphs[id].updateOptions({ 464 chart: { 465 type: x 466 }, 467 fill:{ 468 opacity:0.4, 469 }, 470 stroke: { 471 show: true, 472 width: 2, 473 colors:graphina_localize.graphinaAllGraphsOptions[id].options.colors, 474 }, 475 }) 476 }else if(x == 'scatter'){ 477 graphina_localize.graphinaAllGraphs[id].updateOptions({ 478 chart: { 479 type: x 480 }, 481 stroke:{ 482 show: true, 483 width: 2, 484 colors:['transparent'] 485 }, 486 fill:{ 487 opacity:1 488 }, 489 markers : { 490 size: 10, 491 } 492 }) 493 494 } 495} 496 497function chartDatalabelsFormat( option, showlabel, showValue, numberformat, prefix, postfix, valueInStringShow, valueInString ){ 498 499 if(showlabel =='yes' && showValue == 'yes'){ 500 return option.dataLabels.formatter = function (val, opt) { 501 let seriesValue = opt.w.config.series[opt.seriesIndex]; 502 if(numberformat == "yes"){
503 seriesValue = seriesValue.toLocaleString(graphina_localize.thousand_seperator) 504 }else{ 505 seriesValue = valueInStringShow == 'no' ? seriesValue : graphinaAbbrNum(seriesValue , valueInString); 506 } 507 return prefix + opt.w.config.labels[opt.seriesIndex] + '-'+ seriesValue + postfix 508 } 509 } 510 else if(showlabel =='yes'){ 511 return option.dataLabels.formatter = function (val, opt) { 512 return prefix + opt.w.config.labels[opt.seriesIndex] + '-' + parseFloat(val).toFixed(1)+'%' + postfix 513 } 514 } 515 else if(showValue == 'yes'){ 516 return option.dataLabels.formatter = function (val, opt) { 517 let seriesValue = opt.w.config.series[opt.seriesIndex]; 518 if(numberformat == "yes"){ 519 seriesValue = seriesValue.toLocaleString(graphina_localize.thousand_seperator) 520 }else{ 521 seriesValue = valueInStringShow == 'no' ? seriesValue : graphinaAbbrNum(seriesValue , valueInString); 522 } 523 return prefix + seriesValue + postfix 524 } 525 } 526 else { 527 return option.dataLabels.formatter = function (val, opt) { 528 return prefix + parseFloat(val).toFixed(1)+'%' +postfix; 529 } 530 } 531 532} 533 534function axisTitle(option, type ,title, style,xaxisYoffset){ 535 return option[type]['title']= { 536 text: title, 537 offsetX: 0, 538 offsetY: xaxisYoffset, 539 style, 540 } 541} 542 543 544function instantInitGraphinaCharts(id) { 545 graphina_localize.graphinaAllGraphs[id] = new ApexCharts(graphina_localize.graphinaAllGraphsOptions[id].ele, graphina_localize.graphinaAllGraphsOptions[id].options); 546 graphina_localize.graphinaAllGraphs[id].render(); 547 isInit[id] = true; 548} 549 550/** 551 * Simple object check. 552 * @param item 553 * @returns {boolean} 554 */ 555function isObject(item) { 556 return (item && typeof item === 'object' && !Array.isArray(item)); 557} 558 559/** 560 * Deep merge two objects. 561 * @param target 562 * @param sources 563 */ 564function mergeDeep(target, ...sources) { 565 if (!sources.length) return target; 566 const source = sources.shift(); 567 568 if (isObject(target) && isObject(source)) { 569 for (const key in source) { 570 if (source.hasOwnProperty(key)) { 571 if (isObject(source[key])) { 572 if (!target[key]) Object.assign(target, {[key]: {}}); 573 mergeDeep(target[key], source[key]); 574 } else { 575 Object.assign(target, {[key]: source[key]}); 576 } 577 } 578 } 579 } 580 581 return mergeDeep(target, ...sources); 582} 583 584function chunk(array, size) { 585 if (!array) return []; 586 const firstChunk = array.slice(0, size); 587 if (!firstChunk.length) { 588 return array; 589 } 590 return [firstChunk].concat(chunk(array.slice(size, array.length), size)); 591} 592 593function graphinaAbbrNum(number, decPlaces) { 594 if( number === undefined || number == null){ 595 return number; 596 } 597 var negativesign = ''; 598 if(number < 0){ 599 negativesign = '-'; 600 number = Math.abs(number) 601 } 602 // 2 decimal places => 100, 3 => 1000, etc 603 decPlaces = Math.pow(10,decPlaces); 604 605 // Enumerate number abbreviations 606 var abbrev = [ "k", "m", "b", "t" ]; 607 608 // Go through the array backwards, so we do the largest first 609 for (var i=abbrev.length-1; i>=0; i--) { 610 611 // Convert array index to "1000", "1000000", etc 612 var size = Math.pow(10,(i+1)*3); 613 614 // If the number is bigger or equal do the abbreviation 615 if(size <= number) { 616 // Here, we multiply by decPlaces, round, and then divide by decPlaces. 617 // This gives us nice rounding to a particular decimal place. 618 number = Math.round(number*decPlaces/size)/decPlaces; 619 620 // Handle special case where we round up to the next abbreviation 621 if((number == 1000) && (i < abbrev.length - 1)) { 622 number = 1; 623 i++; 624 } 625 626 // Add the letter for the abbreviation 627 number += abbrev[i]; 628 629 // We are done... stop 630 break; 631 } 632 } 633 634 return negativesign + number; 635} 636 637function getDataForChartsAjax(request_fields, type, id, selected_field='') { 638 639 if(jQuery('body').hasClass("elementor-editor-active")) { 640 let element_x = parent.document.querySelector('[data-setting="iq_' + type + '_chart_sql_builder_x_columns"]'); 641 let element_y = parent.document.querySelector('[data-setting="iq_' + type + '_chart_sql_builder_y_columns"]'); 642 if(element_x !== null && element_y !== null) { 643 element_x.innerHTML = '' ; 644 element_y.innerHTML = '' ; 645 } 646 }; 647 648 if(request_fields['iq_'+type+'_chart_filter_enable'] != undefined && request_fields['iq_'+type+'_chart_filter_enable'] == 'yes' ){ 649 selected_field = graphinaGetSelectOptionValue(id); 650 } 651 652 jQuery.ajax({ 653 url: graphina_localize.ajaxurl, 654 type: "post", 655 dataType: "json", 656 data: { 657 action: "get_graphina_chart_settings", 658 selected_field:selected_field, 659 chart_type: type, 660 chart_id: id, 661 fields: request_fields 662 }, 663 success: function (response) { 664 if(document.getElementsByClassName(type+'-chart-'+id).length === 0) { 665 return 0; 666 } 667 if (request_fields['iq_' + type + '_chart_filter_enable'] !== undefined && request_fields['iq_' + type + '_chart_filter_enable'] === 'yes') { 668 if (response.status === true) { 669 jQuery(document).find('.' + type + '-chart-' + id + '-loader').hide(); 670 jQuery(document).find('.' + type + '-chart-' + id).show(); 671 }else{ 672 jQuery(document).find('.' + type + '-chart-' + id + '-loader').find('img').hide(); 673 jQuery(document).find('.' + type + '-chart-' + id + '-loader').find('p').show(); 674 } 675 } 676 if (response.status === true) { 677 if(response.fail === true) { 678 graphina_localize.graphinaBlockCharts[response.chart_id] = response.fail_message; 679 initGraphinaCharts(response.chart_id); 680 }else { 681 if (response.instant_init === true) { 682 instantInitGraphinaCharts(response.chart_id); 683 graphina_localize.graphinaAllGraphsOptions[response.chart_id].animation = false;
684 } 685 graphina_localize.graphinaAllGraphsOptions[response.chart_id].options = mergeDeep(graphina_localize.graphinaAllGraphsOptions[response.chart_id].options, response.chart_option); 686 if (isInit[response.chart_id] === true) { 687 initGraphinaCharts(response.chart_id,type); 688 } 689 } 690 691 if(request_fields['iq_' + type + '_chart_dynamic_data_option'] !== undefined ) { 692 if ( request_fields['iq_' + type + '_chart_dynamic_data_option'] === "sql-builder") { 693 if(jQuery('body').hasClass("elementor-editor-active")) { 694 setFieldsFromSQLStateMent(request_fields, response, type); 695 }; 696 } 697 } 698 699 } 700 }, 701 error: function () { 702 console.log('fail'); 703 } 704 }); 705 706} 707 708function setFieldsFromSQLStateMent (request_fields, response, type) { 709 710 // console.log('setFieldsFromSQLStateMent'); 711 // console.log('Responce =>',response); 712 713 let element_x = parent.document.querySelector('[data-setting="iq_' + type + '_chart_sql_builder_x_columns"]'); 714 let element_y = parent.document.querySelector('[data-setting="iq_' + type + '_chart_sql_builder_y_columns"]'); 715 716 if(element_x == null || element_y == null) { 717 return ; 718 } 719 720 // console.log('element_x', element_x, 'element_y', element_y); 721 722 let manualSql = ['mixed','brush','pie_google','donut_google','line_google','area_google','bar_google','column_google','gauge_google','geo_google']; 723 724 if(manualSql.includes(type)){ 725 if(response.sql_fail !== undefined && response.sql_fail !== '' ) { 726 let char_element = document.querySelector('[id="' + type + '-chart"]') ; 727 if(char_element !== null) { 728 char_element.innerHTML = '' ; 729 char_element.innerHTML = "<div class='text-center' style='color:red'> No data found, Please check your sql statement. </div>" ; 730 } 731 return ; 732 } 733 }else{ 734 if(response.extra !== undefined && response.extra.sql_fail !== undefined && response.extra.sql_fail !== '' ) { 735 let char_element = document.querySelector('[id="' + type + '-chart"]') ; 736 if(char_element !== null) { 737 char_element.innerHTML = '' ; 738 char_element.innerHTML = "<div class='text-center' style='color:red'> No data found, Please check your sql statement. </div>" ; 739 } 740 return ; 741 } 742 } 743 744 // graphina pro sql-builder select sql result column 745 let db_columns = manualSql.includes(type) ? response.db_column: response.extra.db_column ; 746 747 x_option_tag = '' ; 748 y_option_tag = '' ; 749 750 if(db_columns !== undefined && db_columns.length !== undefined && db_columns.length > 0) { 751 db_columns.forEach(function(currentValue, index, arr) { 752 x_axis_selected_field = '' ; 753 y_axis_selected_field = '' ; 754 if(request_fields['iq_' + type + '_chart_sql_builder_x_columns'].includes(currentValue)) { 755 x_axis_selected_field = 'selected' ; 756 } 757 if(request_fields['iq_' + type + '_chart_sql_builder_y_columns'].includes(currentValue)) { 758 y_axis_selected_field = 'selected' ; 759 } 760 x_option_tag += '<option value="' + currentValue.toLowerCase() + '" ' + x_axis_selected_field + ' > ' + currentValue + '</option>' ; 761 y_option_tag += '<option value="' + currentValue.toLowerCase() + '" ' + y_axis_selected_field + ' > ' + currentValue + '</option>' ; 762 }); 763 } 764 765 element_x.innerHTML = x_option_tag ; 766 element_y.innerHTML = y_option_tag ; 767 768} 769 770function graphinasetCookie(cname, cvalue, exdays) { 771 var d = new Date(); 772 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); 773 var expires = "expires="+d.toUTCString(); 774 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; 775} 776 777function graphinaRestrictedPasswordAjax(form,e){ 778 e.preventDefault() 779 jQuery.ajax({ 780 url: graphina_localize.ajaxurl, 781 type: "post", 782 data: jQuery(form).serialize(), 783 success: function (response) { 784 if(response.status === true){ 785 graphinasetCookie(response.chart, true,1); 786 location.reload(); 787 } 788 else{ 789 jQuery(form).find('.graphina-error').css('display', 'flex'); 790 } 791 } 792 }); 793 794 795 796} 797 798function graphinaChartFilter(request_fields,type,selectedValue,id){ 799 jQuery(document).find('.'+type+'-chart-'+id+'-loader').show(); 800 jQuery(document).find('.'+type+'-chart-'+id+'-loader').find('img').show(); 801 jQuery(document).find('.'+type+'-chart-'+id+'-loader').find('p').hide(); 802 jQuery(document).find('.'+type+'-chart-'+id).hide(); 803 // setTimeout(() =>{ 804 getDataForChartsAjax(request_fields, type, id,graphinaGetSelectOptionValue(id)); 805 // },1000) 806 807} 808 809function graphinaGetSelectOptionValue(id){ 810 let option = [] 811 let allSelect = document.querySelectorAll('.graphina_filter_select'+id); 812 for(let i=0;i < allSelect.length;i++){ 813 if(allSelect[i].value !== undefined || allSelect[i].value !== null){ 814 if(allSelect[i].value !== 'default'){ 815 option.push(allSelect[i].value) 816 }else{ 817 option.push('') 818 } 819 } 820 } 821 822 document.querySelectorAll('.graphina_datepicker_'+id).forEac
822h(elem => { 823 if (elem.value !== undefined && (elem.value !== undefined || true)) { 824 let formatsign = "-"; 825 let date = new Date(elem.value) 826 if(date != undefined){ 827 let formatDate = ''; 828 if(elem.type === 'date'){ 829 formatDate = date.getFullYear() + formatsign + ("00" + (date.getMonth() + 1)).slice(-2) + formatsign + 830 ("00" + date.getDate()).slice(-2); 831 }else{ 832 formatDate = date.getFullYear() + formatsign + ("00" + (date.getMonth() + 1)).slice(-2) + formatsign + 833 ("00" + date.getDate()).slice(-2) + " " + 834 ("00" + date.getHours()).slice(-2) + ":" + 835 ("00" + date.getMinutes()).slice(-2) + ":" + 836 ("00" + date.getSeconds()).slice(-2); 837 } 838 option.push(formatDate) 839 } 840 } 841 } 842 ); 843 844 return option; 845} 846 847 848 849
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.