PageSourceSearch

https://jeffbuckley.com/wp-content/plugins/js_composer_salient.new…/lib/vc_chart/jquery.vc_chart.js?ver=7.1.2

js jeffbuckley.com collected 2026-10-02 07:29:41 UTC 5,956 bytes, 158 lines download raw bytes

1/* =========================================================
2 * jquery.vc_chart.js v1.0
3 * =========================================================
4 * Copyright 2013 Wpbakery
5 *
6 * Jquery chart plugin for the Visual Composer.
7 * ========================================================= */
8(function($){
9    /**
10     * Pie chart animated.
11     * @param element - DOM element
12     * @param options - settings object.
13     * @constructor
14     */
15    var VcChart = function(element, options) {
16        this.el = element;
17        this.$el = $(this.el);
18        this.options = $.extend({
19            color: 'rgba(39,207,195,1)',
20            units: '',
21            label_selector: '.vc_pie_chart_value',
22            back_selector: '.vc_pie_chart_back',
23            responsive: true
24        }, options);
25        this.init();
26    };
27    VcChart.prototype = {
28        constructor: VcChart,
29        _progress_v: 0,
30        animated: false,
31        colors: {
32            'wpb_button': 'rgba(247, 247, 247, 1)',
33            'btn-primary': 'rgba(0, 136, 204, 1)',
34            'btn-info': 'rgba(88, 185, 218, 1)',
35            'btn-success': 'rgba(106, 177, 101, 1)',
36            'btn-warning': 'rgba(255, 153, 0, 1)',
37            'btn-danger': 'rgba(255, 103, 91, 1)',
38            'btn-inverse': 'rgba(85, 85, 85, 1)'
39        },
40        init: function() {
41            this.setupColor();
42            this.value = this.$el.data('pie-value')/100;
43            this.label_value = this.$el.data('pie-label-value') || this.$el.data('pie-value');
44            this.$wrapper = $('.vc_pie_wrapper', this.$el);
45            this.$label = $(this.options.label_selector, this.$el);
46            this.$back = $(this.options.back_selector, this.$el);
47            this.$canvas = this.$el.find('canvas');
48            this.draw();
49            this.setWayPoint();
50            if(this.options.responsive === true) this.setResponsive();
51
52        },
53        setupColor: function() {
54            if(this.$el.data('pie-color').length > 0) {
55                this.color = this.$el.data('pie-color');
56            } else if(typeof this.options.color === 'string' && this.options.color.match(/^rgb(a?)\([^\)]\)/)) {
57                this.color = this.options.color;
58            } else {
59                this.color = 'rgba(247, 247, 247, 0.2)';
60            }
61        },
62        setResponsive: function() {
63            var that = this;
64            $(window).resize(function(){
65                if(that.animated === true) that.circle.stop();
66                that.draw(true);
67            });
68        },
69        draw: function(redraw) {
70            var w = this.$el.width()/100*80,
71                border_w = 5,
72                radius = w/2 - border_w - 1;
73            this.$wrapper.css({"width" : w + "px"});
74            this.$label.css({"width" : w, "height" : w, "line-height" : w+"px"});
75            this.$back.css({"width" : w, "height" : w, "opacity" : 0.3});
76            this.$canvas.attr({"width" : w + "px", "height" : w + "px"});
77            this.circle = new ProgressCircle({
78                canvas: this.$canvas.get(0),
79                minRadius: radius,
80                arcWidth: border_w
81            });
82            if(redraw === true && this.animated === true) {
83                this._progress_v = this.value;
84                this.circle.addEntry({
85                    fillColor: this.color,
86                    progressListener: $.proxy(this.setProgress, this)
87                }).start();
88            }
89        },
90        setProgress: function() {
91            if (this._progress_v >= this.value) {
92                this.circle.stop();
93                this.$label.html(this.label_value + '<span class="units">' + this.options.units + '</span>');
94                return this._progress_v;
95            }
96            this._progress_v += 0.005;
97            
98            if(parseInt(this.label_value)){
99            	 var label_value = this._progress_v/this.value*this.label_value;
100            	 var val = Math.round(label_value) + '<span class="units">' + this.options.units + '</span>';
101            } else {
102            	 var val = this.label_value + '<span class="units">' + this.options.units + '</span>'
103            }
104         
105            this.$label.html(val);
106            return this._progress_v;
107        },
108        animate: function() {
109            if(this.animated !== true) {
110                this.animated = true;
111                this.circle.addEntry({
112                    fillColor: this.color,
113                    progressListener: $.proxy(this.setProgress, this)
114                }).start(5);
115            }
116        },
117        setWayPoint: function() {
118            if (typeof $.fn.waypoint !== 'undefined') {
119                this.$el.waypoint($.proxy(this.animate, this), { offset: '85%',  triggerOnce: true });
120            } else {
121                var $that = this;
122                $(this.$el).appear(function() {
123                  $that.animate();
124                },{accX: 0, accY: 120});
125                
126            }
127        }
128    };
129    /**
130     * jQuery plugin
131     * @param option - object with settings
132     * @return {*}
133     */
134    $.fn.vcChat = function(option) {
135        return this.each(function () {
136            var $this = $(this),
137                data = $this.data('vc_chart'),
138                options = typeof option === 'object' ? option : {
139                    color: $this.data('pie-color'),
140                    units: $this.data('pie-units')
141                };
142            if (!data) $this.data('vc_chart', (data = new VcChart(this, options)));
143            if (typeof option == 'string') data[option]();
144        });
145    };
146    /**
147     * Allows users to rewrite function inside theme.
148     */
149    if ( typeof window['vc_pieChart'] !== 'function' ) {
150        window.vc_pieChart = function() {
151            $('.vc_pie_chart').vcChat();
152        }
153    }
154    $(document).ready(function(){
155        if($('.vc_pie_chart').length > 0) vc_pieChart();
156    });
157
158})(window.jQuery);

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.