jquery.peity.min.js000064400000007203151162503740010342 0ustar00// Peity jQuery plugin version 3.3.0 // (c) 2018 Ben Pickles // // http://benpickles.github.io/peity // // Released under MIT license. !function(t,i,e,n){var a=t.fn.peity=function(i,e){return l&&this.each(function(){var n=t(this),h=n.data("_peity");h?(i&&(h.type=i),t.extend(h.opts,e)):(h=new r(n,i,t.extend({},a.defaults[i],n.data("peity"),e)),n.change(function(){h.draw()}).data("_peity",h)),h.draw()}),this},r=function(t,i,e){this.$el=t,this.type=i,this.opts=e},h=r.prototype,s=h.svgElement=function(e,n){return t(i.createElementNS("http://www.w3.org/2000/svg",e)).attr(n)},l="createElementNS"in i&&s("svg",{})[0].createSVGRect;h.draw=function(){var t=this.opts;a.graphers[this.type].call(this,t),t.after&&t.after.call(this,t)},h.fill=function(){var i=this.opts.fill;return t.isFunction(i)?i:function(t,e){return i[e%i.length]}},h.prepare=function(t,i){return this.$svg||this.$el.hide().after(this.$svg=s("svg",{class:"peity"})),this.$svg.empty().data("_peity",this).attr({height:i,width:t})},h.values=function(){return t.map(this.$el.text().split(this.opts.delimiter),function(t){return parseFloat(t)})},a.defaults={},a.graphers={},a.register=function(t,i,e){this.defaults[t]=i,this.graphers[t]=e},a.register("pie",{fill:["#ff9900","#fff4dd","#ffc66e"],radius:8},function(i){if(!i.delimiter){var n=this.$el.text().match(/[^0-9\.]/);i.delimiter=n?n[0]:","}var a=t.map(this.values(),function(t){return t>0?t:0});if("/"==i.delimiter){var r=a[0],h=a[1];a=[r,e.max(0,h-r)]}for(var l=0,p=a.length,o=0;l.5?1:0,1,w(M,g),"L");v?S=S.concat(w(M,v),"A",v,v,0,j>.5?1:0,0,w(x,v)):S.push(u,d),x+=$,k=s("path",{d:S.join(" "),"data-value":$})}k.attr("fill",y.call(this,$,l,a)),c.append(k)}}}),a.register("donut",t.extend(!0,{},a.defaults.pie),function(t){a.graphers.pie.call(this,t)}),a.register("line",{delimiter:",",fill:"#c6d9fd",height:16,min:0,stroke:"#4d89f9",strokeWidth:1,width:32},function(t){var i=this.values();1==i.length&&i.push(i[0]);for(var a=e.max.apply(e,t.max==n?i:i.concat(t.max)),r=e.min.apply(e,t.min==n?i:i.concat(t.min)),h=this.prepare(t.width,t.height),l=t.strokeWidth,p=h.width(),o=h.height()-l,f=a-r,c=this.x=function(t){return t*(p/(i.length-1))},u=this.y=function(t){var i=o;return f&&(i-=(t-r)/f*o),i+l/2},d=u(e.max(r,0)),g=[0,d],v=0;v0&&o&&k--),h.append(s("rect",{"data-value":w,fill:c.call(this,w,g,i),x:m,y:k,width:y,height:v}))}})}(jQuery,document,Math); chart-data.js000064400000004232151162503740007117 0ustar00(function($){ "use strict"; // Start of use strict $(function() { "use strict"; // Just the defaults. $("span.pie").peity("pie",{ width: '80', height: '80' }) $('span.donut').peity('donut',{ width: '50', height: '50' }) $(".peity-line").peity("line",{ width: '100%', height: '65', fill:['#705ec8'] }) $(".bar").peity("bar",{ width: '100%', height: '50' }) $(".bar-colours-1").peity("bar", { fill: ["#664dc9", "#e3dff5"], width: '100', height: '100' }) $(".bar-colours-2").peity("bar", { fill: function(value) { return value > 0 ? "#38cb89" : "#aeeacf" }, width: '100', height: '100' }) $(".bar-colours-3").peity("bar", { fill: ["#ffab00", "#ffdd99"], width: '100', height: '100' }) $(".bar-colours-4").peity("bar", { fill: function(value) { return value > 0 ? "#ef4b4b" : "#f7a1a1" }, width: '100', height: '100' }) $(".pie-colours-1").peity("pie", { fill: ["#705ec8", "#fa057a", "#2dce89", "#ff5b51"], width: '100', height: '100' }) $(".pie-colours-2").peity("pie", { fill: ["#705ec8", "#fa057a", "#2dce89", "#ff5b51", "#fcbf09"], width: '100', height: '100' }) // Using data attributes $(".data-attributes span").peity("donut") // Evented example. $("select").change(function() { var text = $(this).val() + "/" + 5 $(this) .siblings("span.graph") .text(text) .change() $("#notice").text("Chart updated: " + text) }).change() $("span.graph").peity("pie") // Updating charts. var updatingChart = $(".updating-chart").peity("line", { width: "100%",height:65 }) setInterval(function() { var random = Math.round(Math.random() * 20) var values = updatingChart.text().split(",") values.shift() values.push(random) updatingChart .text(values.join(",")) .change() }, 2500) }) })(jQuery);