Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../themes/Divi/includes/builder/scripts/ext
File: jquery.easypiechart.js
/*!
[0] Fix | Delete
* easyPieChart
[1] Fix | Delete
* Lightweight plugin to render simple, animated and retina optimized pie charts
[2] Fix | Delete
*
[3] Fix | Delete
* @author Robert Fleischmann <rendro87@gmail.com> (http://robert-fleischmann.de)
[4] Fix | Delete
* @version 2.1.5
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
(function(root, factory) {
[8] Fix | Delete
if(typeof exports === 'object') {
[9] Fix | Delete
module.exports = factory(require('jquery'));
[10] Fix | Delete
}
[11] Fix | Delete
else if(typeof define === 'function' && define.amd) {
[12] Fix | Delete
define(['jquery'], factory);
[13] Fix | Delete
}
[14] Fix | Delete
else {
[15] Fix | Delete
factory(root.jQuery);
[16] Fix | Delete
}
[17] Fix | Delete
}(this, function($) {
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Renderer to render the chart on a canvas object
[21] Fix | Delete
* @param {DOMElement} el DOM element to host the canvas (root of the plugin)
[22] Fix | Delete
* @param {object} options options object of the plugin
[23] Fix | Delete
*/
[24] Fix | Delete
var CanvasRenderer = function(el, options) {
[25] Fix | Delete
var cachedBackground;
[26] Fix | Delete
var canvas = document.createElement('canvas');
[27] Fix | Delete
[28] Fix | Delete
el.appendChild(canvas);
[29] Fix | Delete
[30] Fix | Delete
if (typeof(G_vmlCanvasManager) !== 'undefined') {
[31] Fix | Delete
G_vmlCanvasManager.initElement(canvas);
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
var ctx = canvas.getContext('2d');
[35] Fix | Delete
[36] Fix | Delete
canvas.width = canvas.height = options.size;
[37] Fix | Delete
[38] Fix | Delete
// canvas on retina devices
[39] Fix | Delete
var scaleBy = 1;
[40] Fix | Delete
if (window.devicePixelRatio > 1) {
[41] Fix | Delete
scaleBy = window.devicePixelRatio;
[42] Fix | Delete
canvas.style.width = canvas.style.height = [options.size, 'px'].join('');
[43] Fix | Delete
canvas.width = canvas.height = options.size * scaleBy;
[44] Fix | Delete
ctx.scale(scaleBy, scaleBy);
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
// move 0,0 coordinates to the center
[48] Fix | Delete
ctx.translate(options.size / 2, options.size / 2);
[49] Fix | Delete
[50] Fix | Delete
// rotate canvas -90deg
[51] Fix | Delete
ctx.rotate((-1 / 2 + options.rotate / 180) * Math.PI);
[52] Fix | Delete
[53] Fix | Delete
var radius = (options.size - options.lineWidth) / 2;
[54] Fix | Delete
if (options.scaleColor && options.scaleLength) {
[55] Fix | Delete
radius -= options.scaleLength + 2; // 2 is the distance between scale and bar
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
// IE polyfill for Date
[59] Fix | Delete
Date.now = Date.now || function() {
[60] Fix | Delete
return +(new Date());
[61] Fix | Delete
};
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* Draw a circle around the center of the canvas
[65] Fix | Delete
* @param {strong} color Valid CSS color string
[66] Fix | Delete
* @param {number} lineWidth Width of the line in px
[67] Fix | Delete
* @param {number} percent Percentage to draw (float between -1 and 1)
[68] Fix | Delete
*/
[69] Fix | Delete
var drawCircle = function(color, lineWidth, percent, alpha ) {
[70] Fix | Delete
percent = Math.min(Math.max(-1, percent || 0), 1);
[71] Fix | Delete
var isNegative = percent <= 0 ? true : false;
[72] Fix | Delete
[73] Fix | Delete
ctx.beginPath();
[74] Fix | Delete
ctx.arc(0, 0, radius, 0, Math.PI * 2 * percent, isNegative);
[75] Fix | Delete
[76] Fix | Delete
ctx.strokeStyle = color;
[77] Fix | Delete
ctx.globalAlpha = alpha;
[78] Fix | Delete
ctx.lineWidth = lineWidth;
[79] Fix | Delete
[80] Fix | Delete
ctx.stroke();
[81] Fix | Delete
};
[82] Fix | Delete
[83] Fix | Delete
/**
[84] Fix | Delete
* Draw the scale of the chart
[85] Fix | Delete
*/
[86] Fix | Delete
var drawScale = function() {
[87] Fix | Delete
var offset;
[88] Fix | Delete
var length;
[89] Fix | Delete
[90] Fix | Delete
ctx.lineWidth = 1;
[91] Fix | Delete
ctx.fillStyle = options.scaleColor;
[92] Fix | Delete
[93] Fix | Delete
ctx.save();
[94] Fix | Delete
for (var i = 24; i > 0; --i) {
[95] Fix | Delete
if (i % 6 === 0) {
[96] Fix | Delete
length = options.scaleLength;
[97] Fix | Delete
offset = 0;
[98] Fix | Delete
} else {
[99] Fix | Delete
length = options.scaleLength * 0.6;
[100] Fix | Delete
offset = options.scaleLength - length;
[101] Fix | Delete
}
[102] Fix | Delete
ctx.fillRect(-options.size/2 + offset, 0, length, 1);
[103] Fix | Delete
ctx.rotate(Math.PI / 12);
[104] Fix | Delete
}
[105] Fix | Delete
ctx.restore();
[106] Fix | Delete
};
[107] Fix | Delete
[108] Fix | Delete
/**
[109] Fix | Delete
* Request animation frame wrapper with polyfill
[110] Fix | Delete
* @return {function} Request animation frame method or timeout fallback
[111] Fix | Delete
*/
[112] Fix | Delete
var reqAnimationFrame = (function() {
[113] Fix | Delete
return window.requestAnimationFrame ||
[114] Fix | Delete
window.webkitRequestAnimationFrame ||
[115] Fix | Delete
window.mozRequestAnimationFrame ||
[116] Fix | Delete
function(callback) {
[117] Fix | Delete
window.setTimeout(callback, 1000 / 60);
[118] Fix | Delete
};
[119] Fix | Delete
}());
[120] Fix | Delete
[121] Fix | Delete
/**
[122] Fix | Delete
* Draw the background of the plugin including the scale and the track
[123] Fix | Delete
*/
[124] Fix | Delete
var drawBackground = function() {
[125] Fix | Delete
if(options.scaleColor) drawScale();
[126] Fix | Delete
if(options.trackColor) drawCircle(options.trackColor, options.lineWidth, 1, options.trackAlpha );
[127] Fix | Delete
};
[128] Fix | Delete
[129] Fix | Delete
/**
[130] Fix | Delete
* Canvas accessor
[131] Fix | Delete
*/
[132] Fix | Delete
this.getCanvas = function() {
[133] Fix | Delete
return canvas;
[134] Fix | Delete
};
[135] Fix | Delete
[136] Fix | Delete
/**
[137] Fix | Delete
* Canvas 2D context 'ctx' accessor
[138] Fix | Delete
*/
[139] Fix | Delete
this.getCtx = function() {
[140] Fix | Delete
return ctx;
[141] Fix | Delete
};
[142] Fix | Delete
[143] Fix | Delete
/**
[144] Fix | Delete
* Clear the complete canvas
[145] Fix | Delete
*/
[146] Fix | Delete
this.clear = function() {
[147] Fix | Delete
ctx.clearRect(options.size / -2, options.size / -2, options.size, options.size);
[148] Fix | Delete
};
[149] Fix | Delete
[150] Fix | Delete
/**
[151] Fix | Delete
* Draw the complete chart
[152] Fix | Delete
* @param {number} percent Percent shown by the chart between -100 and 100
[153] Fix | Delete
*/
[154] Fix | Delete
this.draw = function(percent) {
[155] Fix | Delete
// do we need to render a background
[156] Fix | Delete
if (!!options.scaleColor || !!options.trackColor) {
[157] Fix | Delete
// getImageData and putImageData are supported
[158] Fix | Delete
if (ctx.getImageData && ctx.putImageData) {
[159] Fix | Delete
if (!cachedBackground) {
[160] Fix | Delete
drawBackground();
[161] Fix | Delete
cachedBackground = ctx.getImageData(0, 0, options.size * scaleBy, options.size * scaleBy);
[162] Fix | Delete
} else {
[163] Fix | Delete
ctx.putImageData(cachedBackground, 0, 0);
[164] Fix | Delete
}
[165] Fix | Delete
} else {
[166] Fix | Delete
this.clear();
[167] Fix | Delete
drawBackground();
[168] Fix | Delete
}
[169] Fix | Delete
} else {
[170] Fix | Delete
this.clear();
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
ctx.lineCap = options.lineCap;
[174] Fix | Delete
[175] Fix | Delete
// if barcolor is a function execute it and pass the percent as a value
[176] Fix | Delete
var color;
[177] Fix | Delete
if (typeof(options.barColor) === 'function') {
[178] Fix | Delete
color = options.barColor(percent);
[179] Fix | Delete
} else {
[180] Fix | Delete
color = options.barColor;
[181] Fix | Delete
}
[182] Fix | Delete
[183] Fix | Delete
// draw bar
[184] Fix | Delete
drawCircle(color, options.lineWidth, percent / 100, options.barAlpha );
[185] Fix | Delete
}.bind(this);
[186] Fix | Delete
[187] Fix | Delete
/**
[188] Fix | Delete
* Animate from some percent to some other percentage
[189] Fix | Delete
* @param {number} from Starting percentage
[190] Fix | Delete
* @param {number} to Final percentage
[191] Fix | Delete
*/
[192] Fix | Delete
this.animate = function(from, to) {
[193] Fix | Delete
var startTime = Date.now();
[194] Fix | Delete
options.onStart(from, to);
[195] Fix | Delete
var animation = function() {
[196] Fix | Delete
var process = Math.min(Date.now() - startTime, options.animate.duration);
[197] Fix | Delete
var currentValue = options.easing(this, process, from, to - from, options.animate.duration);
[198] Fix | Delete
this.draw(currentValue);
[199] Fix | Delete
options.onStep(from, to, currentValue);
[200] Fix | Delete
if (process >= options.animate.duration) {
[201] Fix | Delete
options.onStop(from, to);
[202] Fix | Delete
} else {
[203] Fix | Delete
reqAnimationFrame(animation);
[204] Fix | Delete
}
[205] Fix | Delete
}.bind(this);
[206] Fix | Delete
[207] Fix | Delete
reqAnimationFrame(animation);
[208] Fix | Delete
}.bind(this);
[209] Fix | Delete
};
[210] Fix | Delete
[211] Fix | Delete
var EasyPieChart = function(el, opts) {
[212] Fix | Delete
var defaultOptions = {
[213] Fix | Delete
barColor: '#ef1e25',
[214] Fix | Delete
barAlpha: 1.0,
[215] Fix | Delete
trackColor: '#f9f9f9',
[216] Fix | Delete
trackAlpha: 1.0,
[217] Fix | Delete
scaleColor: '#dfe0e0',
[218] Fix | Delete
scaleLength: 5,
[219] Fix | Delete
lineCap: 'round',
[220] Fix | Delete
lineWidth: 3,
[221] Fix | Delete
size: 110,
[222] Fix | Delete
rotate: 0,
[223] Fix | Delete
render: true,
[224] Fix | Delete
animate: {
[225] Fix | Delete
duration: 1000,
[226] Fix | Delete
enabled: true
[227] Fix | Delete
},
[228] Fix | Delete
easing: function (x, t, b, c, d) { // more can be found here: http://gsgd.co.uk/sandbox/jquery/easing/
[229] Fix | Delete
t = t / (d/2);
[230] Fix | Delete
if (t < 1) {
[231] Fix | Delete
return c / 2 * t * t + b;
[232] Fix | Delete
}
[233] Fix | Delete
return -c/2 * ((--t)*(t-2) - 1) + b;
[234] Fix | Delete
},
[235] Fix | Delete
onStart: function(from, to) {
[236] Fix | Delete
return;
[237] Fix | Delete
},
[238] Fix | Delete
onStep: function(from, to, currentValue) {
[239] Fix | Delete
return;
[240] Fix | Delete
},
[241] Fix | Delete
onStop: function(from, to) {
[242] Fix | Delete
return;
[243] Fix | Delete
}
[244] Fix | Delete
};
[245] Fix | Delete
[246] Fix | Delete
// detect present renderer
[247] Fix | Delete
if (typeof(CanvasRenderer) !== 'undefined') {
[248] Fix | Delete
defaultOptions.renderer = CanvasRenderer;
[249] Fix | Delete
} else if (typeof(SVGRenderer) !== 'undefined') {
[250] Fix | Delete
defaultOptions.renderer = SVGRenderer;
[251] Fix | Delete
} else {
[252] Fix | Delete
throw new Error('Please load either the SVG- or the CanvasRenderer');
[253] Fix | Delete
}
[254] Fix | Delete
[255] Fix | Delete
var options = {};
[256] Fix | Delete
var currentValue = 0;
[257] Fix | Delete
[258] Fix | Delete
/**
[259] Fix | Delete
* Initialize the plugin by creating the options object and initialize rendering
[260] Fix | Delete
*/
[261] Fix | Delete
var init = function() {
[262] Fix | Delete
this.el = el;
[263] Fix | Delete
this.options = options;
[264] Fix | Delete
[265] Fix | Delete
// merge user options into default options
[266] Fix | Delete
for (var i in defaultOptions) {
[267] Fix | Delete
if (defaultOptions.hasOwnProperty(i)) {
[268] Fix | Delete
options[i] = opts && typeof(opts[i]) !== 'undefined' ? opts[i] : defaultOptions[i];
[269] Fix | Delete
if (typeof(options[i]) === 'function') {
[270] Fix | Delete
options[i] = options[i].bind(this);
[271] Fix | Delete
}
[272] Fix | Delete
}
[273] Fix | Delete
}
[274] Fix | Delete
[275] Fix | Delete
// check for jQuery easing
[276] Fix | Delete
if (typeof(options.easing) === 'string' && typeof(jQuery) !== 'undefined' && jQuery.isFunction(jQuery.easing[options.easing])) {
[277] Fix | Delete
options.easing = jQuery.easing[options.easing];
[278] Fix | Delete
} else {
[279] Fix | Delete
options.easing = defaultOptions.easing;
[280] Fix | Delete
}
[281] Fix | Delete
[282] Fix | Delete
// process earlier animate option to avoid bc breaks
[283] Fix | Delete
if (typeof(options.animate) === 'number') {
[284] Fix | Delete
options.animate = {
[285] Fix | Delete
duration: options.animate,
[286] Fix | Delete
enabled: true
[287] Fix | Delete
};
[288] Fix | Delete
}
[289] Fix | Delete
[290] Fix | Delete
if (typeof(options.animate) === 'boolean' && !options.animate) {
[291] Fix | Delete
options.animate = {
[292] Fix | Delete
duration: 1000,
[293] Fix | Delete
enabled: options.animate
[294] Fix | Delete
};
[295] Fix | Delete
}
[296] Fix | Delete
[297] Fix | Delete
// create renderer
[298] Fix | Delete
this.renderer = new options.renderer(el, options);
[299] Fix | Delete
[300] Fix | Delete
// initial draw
[301] Fix | Delete
this.renderer.draw(currentValue);
[302] Fix | Delete
[303] Fix | Delete
// initial update
[304] Fix | Delete
if (el.dataset && el.dataset.percent) {
[305] Fix | Delete
this.update(parseFloat(el.dataset.percent));
[306] Fix | Delete
} else if (el.getAttribute && el.getAttribute('data-percent')) {
[307] Fix | Delete
this.update(parseFloat(el.getAttribute('data-percent')));
[308] Fix | Delete
}
[309] Fix | Delete
}.bind(this);
[310] Fix | Delete
[311] Fix | Delete
/**
[312] Fix | Delete
* Update the value of the chart
[313] Fix | Delete
* @param {number} newValue Number between 0 and 100
[314] Fix | Delete
* @return {object} Instance of the plugin for method chaining
[315] Fix | Delete
*/
[316] Fix | Delete
this.update = function(newValue) {
[317] Fix | Delete
newValue = parseFloat(newValue);
[318] Fix | Delete
if (options.animate.enabled) {
[319] Fix | Delete
this.renderer.animate(currentValue, newValue);
[320] Fix | Delete
} else {
[321] Fix | Delete
this.renderer.draw(newValue);
[322] Fix | Delete
}
[323] Fix | Delete
currentValue = newValue;
[324] Fix | Delete
return this;
[325] Fix | Delete
}.bind(this);
[326] Fix | Delete
[327] Fix | Delete
/**
[328] Fix | Delete
* Disable animation
[329] Fix | Delete
* @return {object} Instance of the plugin for method chaining
[330] Fix | Delete
*/
[331] Fix | Delete
this.disableAnimation = function() {
[332] Fix | Delete
options.animate.enabled = false;
[333] Fix | Delete
return this;
[334] Fix | Delete
};
[335] Fix | Delete
[336] Fix | Delete
/**
[337] Fix | Delete
* Enable animation
[338] Fix | Delete
* @return {object} Instance of the plugin for method chaining
[339] Fix | Delete
*/
[340] Fix | Delete
this.enableAnimation = function() {
[341] Fix | Delete
options.animate.enabled = true;
[342] Fix | Delete
return this;
[343] Fix | Delete
};
[344] Fix | Delete
[345] Fix | Delete
init();
[346] Fix | Delete
};
[347] Fix | Delete
[348] Fix | Delete
$.fn.easyPieChart = function(options) {
[349] Fix | Delete
return this.each(function() {
[350] Fix | Delete
var instanceOptions;
[351] Fix | Delete
[352] Fix | Delete
if (!$.data(this, 'easyPieChart')) {
[353] Fix | Delete
instanceOptions = $.extend({}, options, $(this).data());
[354] Fix | Delete
$.data(this, 'easyPieChart', new EasyPieChart(this, instanceOptions));
[355] Fix | Delete
}
[356] Fix | Delete
});
[357] Fix | Delete
};
[358] Fix | Delete
[359] Fix | Delete
[360] Fix | Delete
}));
[361] Fix | Delete
[362] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function