diff --git a/dist/justgage.js b/dist/justgage.js index ccc7da8..dd31e0a 100644 --- a/dist/justgage.js +++ b/dist/justgage.js @@ -139,6 +139,10 @@ // color of label showing label under value labelFontColor: kvLookup('labelFontColor', config, dataset, "#b3b3b3"), + // valueFontFamily : string + // font-family for label as well as min/max value + labelFontFamily: kvLookup('labelFontFamily', config, dataset, "Arial"), + // shadowOpacity : int // 0 ~ 1 shadowOpacity: kvLookup('shadowOpacity', config, dataset, 0.2), @@ -649,7 +653,7 @@ obj.txtLabel.attr({ "font-size": obj.params.labelFontSize, "font-weight": "normal", - "font-family": "Arial", + "font-family": obj.config.labelFontFamily, "fill": obj.config.labelFontColor, "fill-opacity": "0" }); @@ -673,7 +677,7 @@ obj.txtMin.attr({ "font-size": obj.params.minFontSize, "font-weight": "normal", - "font-family": "Arial", + "font-family": obj.config.labelFontFamily, "fill": obj.config.labelFontColor, "fill-opacity": (obj.config.hideMinMax || obj.config.donut) ? "0" : "1" }); @@ -696,7 +700,7 @@ obj.txtMax.attr({ "font-size": obj.params.maxFontSize, "font-weight": "normal", - "font-family": "Arial", + "font-family": obj.config.labelFontFamily, "fill": obj.config.labelFontColor, "fill-opacity": (obj.config.hideMinMax || obj.config.donut) ? "0" : "1" }); @@ -761,7 +765,7 @@ setDy(obj.txtValue, obj.params.valueFontSize, obj.params.valueY); }; - + this.bindEvent("raphael.anim.finish", onFinish) this.bindEvent("raphael.anim.frame", onFrame) @@ -812,12 +816,12 @@ eventName += '.' + this.level.id //check for existing bind events - if(this.events[eventName]) + if(this.events[eventName]) Raphael.eve.off(eventName, this.events[eventName]) - + Raphael.eve.on(eventName, func); - this.events[eventName] = func + this.events[eventName] = func } diff --git a/dist/justgage.min.js b/dist/justgage.min.js index 5142cbd..a6dba1f 100644 --- a/dist/justgage.min.js +++ b/dist/justgage.min.js @@ -1,2 +1,2 @@ -!function(n,e){"function"==typeof define&&define.amd?define(["raphael"],function(t){return n.JustGage=e(t)}):"object"==typeof module&&module.exports?module.exports=n.JustGage=e(require("raphael")):n.JustGage=e(Raphael)}("undefined"!=typeof window?window:this,function(T){function t(t){var A=this;if(A.events={},N(t))return!1;if(N(t.id)){if(N(t.parentNode))return!1;A.node=t.parentNode}else if(A.node=document.getElementById(t.id),!A.node)return!1;var n,e,i,o,a,r,l,c,f,m,s,g,u,d,p,h,x,v,b,M=A.node.dataset?A.node.dataset:{},y=!N(t.defaults)&&t.defaults;!1!==y&&delete(t=function(t){t=t||{};for(var n=1;n"),refreshAnimationTime:C("refreshAnimationTime",t,M,700),refreshAnimationType:C("refreshAnimationType",t,M,">"),donutStartAngle:C("donutStartAngle",t,M,90),valueMinFontSize:C("valueMinFontSize",t,M,16),labelMinFontSize:C("labelMinFontSize",t,M,10),minLabelMinFontSize:C("minLabelMinFontSize",t,M,10),maxLabelMinFontSize:C("maxLabelMinFontSize",t,M,10),hideValue:C("hideValue",t,M,!1),hideMinMax:C("hideMinMax",t,M,!1),showInnerShadow:C("showInnerShadow",t,M,!1),humanFriendly:C("humanFriendly",t,M,!1),noGradient:C("noGradient",t,M,!1),donut:C("donut",t,M,!1),relativeGaugeSize:C("relativeGaugeSize",t,M,!1),counter:C("counter",t,M,!1),decimals:C("decimals",t,M,0),customSectors:C("customSectors",t,M,{}),formatNumber:C("formatNumber",t,M,!1),pointer:C("pointer",t,M,!1),pointerOptions:C("pointerOptions",t,M,{}),displayRemaining:C("displayRemaining",t,M,!1)},A.config.value>A.config.max&&(A.config.value=A.config.max),A.config.valueA.config.valueMinFontSize?o/6.5:A.config.valueMinFontSize,f=r+i/2,m=l+o/1.275,s=o/16>A.config.labelMinFontSize?o/16:A.config.labelMinFontSize,g=r+i/2,u=m+c/2+5,d=o/16>A.config.minLabelMinFontSize?o/16:A.config.minLabelMinFontSize,p=r+i/10+i/6.666666666666667*A.config.gaugeWidthScale/2,h=u,o/16>A.config.maxLabelMinFontSize?o/16:A.config.maxLabelMinFontSize),r+i-i/10-i/6.666666666666667*A.config.gaugeWidthScale/2),u),A.params={canvasW:n,canvasH:e,widgetW:i,widgetH:o,dx:r,dy:l,valueFontSize:c,valueX:f,valueY:m,labelFontSize:s,labelX:g,labelY:u,minFontSize:d,minX:p,minY:h,maxFontSize:x,maxX:v,maxY:b},b=null,A.canvas.customAttributes.pki=function(t){var n,e,i,o,a,r,l=A.config.min,c=A.config.max,f=A.params.widgetW,m=A.params.widgetH,s=A.params.dx,g=A.params.dy,u=A.config.gaugeWidthScale,d=A.config.donut;A.config.reverse;return l<0&&(c-=l,t-=l,l=0),d?(n=(1-2*(t-l)/(c-l))*Math.PI,r="M"+((o=f/2+s)-(i=(e=f/2-f/30)-f/6.666666666666667*u))+","+(a=m/2+g)+" ",r+="L"+(o-e)+","+a+" ",(c-l)/2=o.ranges[M].lo&&t<=o.ranges[M].hi)return o.ranges[M].color}if(1===(a=e.length))return e[0];for(r=i?1/a:1/(a-1),l=[],M=0;M1*r.config.max&&(t=1*r.config.max),1*t<1*r.config.min&&(t=1*r.config.min),a=O(t,(t-r.config.min)/(r.config.max-r.config.min),r.config.levelColors,r.config.noGradient,r.config.customSectors),o=r.config.textRenderer?r.config.textRenderer(o):r.config.humanFriendly?k(o,r.config.humanFriendlyDecimal)+r.config.symbol:r.config.formatNumber?L((1*o).toFixed(r.config.decimals))+r.config.symbol:r.config.displayRemaining?(1*(r.config.max-o)).toFixed(r.config.decimals)+r.config.symbol:(1*o).toFixed(r.config.decimals)+r.config.symbol,r.originalValue=o,r.config.value=1*t,r.config.counter||(r.txtValue.attr({text:o}),E(r.txtValue,r.params.valueFontSize,r.params.valueY));var l=r.config.value;r.config.reverse&&(l=1*r.config.max+1*r.config.min-1*r.config.value),r.level.animate({pki:[l],fill:a},r.config.refreshAnimationTime,r.config.refreshAnimationType,r.config.onAnimationEnd),r.config.pointer&&r.needle.animate({ndl:[l]},r.config.refreshAnimationTime,r.config.refreshAnimationType),e=null},t.prototype.update=function(t,n){if(t instanceof Object)for(var e in t)i(this,e,n=t[e]);else i(this,t,n)},t.prototype.destroy=function(){for(var t in this.node&&this.node.parentNode&&(this.node.innerHTML=""),this.events)T.eve.off(t,this.events[t]);this.events={}},t.prototype.generateShadow=function(t,n){var e,i,o,a,r,l,c,f=this,m="inner-shadow-"+f.config.id;(e=document.createElementNS(t,"filter")).setAttribute("id",m),n.appendChild(e),(i=document.createElementNS(t,"feOffset")).setAttribute("dx",0),i.setAttribute("dy",f.config.shadowVerticalOffset),e.appendChild(i),(o=document.createElementNS(t,"feGaussianBlur")).setAttribute("result","offset-blur"),o.setAttribute("stdDeviation",f.config.shadowSize),e.appendChild(o),(a=document.createElementNS(t,"feComposite")).setAttribute("operator","out"),a.setAttribute("in","SourceGraphic"),a.setAttribute("in2","offset-blur"),a.setAttribute("result","inverse"),e.appendChild(a),(r=document.createElementNS(t,"feFlood")).setAttribute("flood-color","black"),r.setAttribute("flood-opacity",f.config.shadowOpacity),r.setAttribute("result","color"),e.appendChild(r),(l=document.createElementNS(t,"feComposite")).setAttribute("operator","in"),l.setAttribute("in","color"),l.setAttribute("in2","inverse"),l.setAttribute("result","shadow"),e.appendChild(l),(c=document.createElementNS(t,"feComposite")).setAttribute("operator","over"),c.setAttribute("in","shadow"),c.setAttribute("in2","SourceGraphic"),e.appendChild(c),f.config.showInnerShadow&&(f.canvas.canvas.childNodes[2].setAttribute("filter","url("+window.location.pathname+"#"+m+")"),f.canvas.canvas.childNodes[3].setAttribute("filter","url("+window.location.pathname+"#"+m+")")),c=null};var I=function(){for(var t=3,n=document.createElement("div"),e=n.getElementsByTagName("i");n.innerHTML="\x3c!--[if gt IE "+ ++t+"]>"),refreshAnimationTime:C("refreshAnimationTime",t,y,700),refreshAnimationType:C("refreshAnimationType",t,y,">"),donutStartAngle:C("donutStartAngle",t,y,90),valueMinFontSize:C("valueMinFontSize",t,y,16),labelMinFontSize:C("labelMinFontSize",t,y,10),minLabelMinFontSize:C("minLabelMinFontSize",t,y,10),maxLabelMinFontSize:C("maxLabelMinFontSize",t,y,10),hideValue:C("hideValue",t,y,!1),hideMinMax:C("hideMinMax",t,y,!1),showInnerShadow:C("showInnerShadow",t,y,!1),humanFriendly:C("humanFriendly",t,y,!1),noGradient:C("noGradient",t,y,!1),donut:C("donut",t,y,!1),relativeGaugeSize:C("relativeGaugeSize",t,y,!1),counter:C("counter",t,y,!1),decimals:C("decimals",t,y,0),customSectors:C("customSectors",t,y,{}),formatNumber:C("formatNumber",t,y,!1),pointer:C("pointer",t,y,!1),pointerOptions:C("pointerOptions",t,y,{}),displayRemaining:C("displayRemaining",t,y,!1)},A.config.value>A.config.max&&(A.config.value=A.config.max),A.config.valueA.config.valueMinFontSize?o/6.5:A.config.valueMinFontSize,f=r+i/2,m=l+o/1.275,s=o/16>A.config.labelMinFontSize?o/16:A.config.labelMinFontSize,g=r+i/2,u=m+c/2+5,d=o/16>A.config.minLabelMinFontSize?o/16:A.config.minLabelMinFontSize,p=r+i/10+i/6.666666666666667*A.config.gaugeWidthScale/2,h=u,o/16>A.config.maxLabelMinFontSize?o/16:A.config.maxLabelMinFontSize),r+i-i/10-i/6.666666666666667*A.config.gaugeWidthScale/2),u),A.params={canvasW:n,canvasH:e,widgetW:i,widgetH:o,dx:r,dy:l,valueFontSize:c,valueX:f,valueY:m,labelFontSize:s,labelX:g,labelY:u,minFontSize:d,minX:p,minY:h,maxFontSize:x,maxX:b,maxY:v},v=null,A.canvas.customAttributes.pki=function(t){var n,e,i,o,a,r,l=A.config.min,c=A.config.max,f=A.params.widgetW,m=A.params.widgetH,s=A.params.dx,g=A.params.dy,u=A.config.gaugeWidthScale,d=A.config.donut;A.config.reverse;return l<0&&(c-=l,t-=l,l=0),d?(n=(1-2*(t-l)/(c-l))*Math.PI,r="M"+((o=f/2+s)-(i=(e=f/2-f/30)-f/6.666666666666667*u))+","+(a=m/2+g)+" ",r+="L"+(o-e)+","+a+" ",(c-l)/2=o.ranges[y].lo&&t<=o.ranges[y].hi)return o.ranges[y].color}if(1===(a=e.length))return e[0];for(r=i?1/a:1/(a-1),l=[],y=0;y1*r.config.max&&(t=1*r.config.max),1*t<1*r.config.min&&(t=1*r.config.min),a=O(t,(t-r.config.min)/(r.config.max-r.config.min),r.config.levelColors,r.config.noGradient,r.config.customSectors),o=r.config.textRenderer?r.config.textRenderer(o):r.config.humanFriendly?k(o,r.config.humanFriendlyDecimal)+r.config.symbol:r.config.formatNumber?L((1*o).toFixed(r.config.decimals))+r.config.symbol:r.config.displayRemaining?(1*(r.config.max-o)).toFixed(r.config.decimals)+r.config.symbol:(1*o).toFixed(r.config.decimals)+r.config.symbol,r.originalValue=o,r.config.value=1*t,r.config.counter||(r.txtValue.attr({text:o}),E(r.txtValue,r.params.valueFontSize,r.params.valueY));var l=r.config.value;r.config.reverse&&(l=1*r.config.max+1*r.config.min-1*r.config.value),r.level.animate({pki:[l],fill:a},r.config.refreshAnimationTime,r.config.refreshAnimationType,r.config.onAnimationEnd),r.config.pointer&&r.needle.animate({ndl:[l]},r.config.refreshAnimationTime,r.config.refreshAnimationType),e=null},t.prototype.update=function(t,n){if(t instanceof Object)for(var e in t)i(this,e,n=t[e]);else i(this,t,n)},t.prototype.destroy=function(){for(var t in this.node&&this.node.parentNode&&(this.node.innerHTML=""),this.events)T.eve.off(t,this.events[t]);this.events={}},t.prototype.generateShadow=function(t,n){var e,i,o,a,r,l,c,f=this,m="inner-shadow-"+f.config.id;(e=document.createElementNS(t,"filter")).setAttribute("id",m),n.appendChild(e),(i=document.createElementNS(t,"feOffset")).setAttribute("dx",0),i.setAttribute("dy",f.config.shadowVerticalOffset),e.appendChild(i),(o=document.createElementNS(t,"feGaussianBlur")).setAttribute("result","offset-blur"),o.setAttribute("stdDeviation",f.config.shadowSize),e.appendChild(o),(a=document.createElementNS(t,"feComposite")).setAttribute("operator","out"),a.setAttribute("in","SourceGraphic"),a.setAttribute("in2","offset-blur"),a.setAttribute("result","inverse"),e.appendChild(a),(r=document.createElementNS(t,"feFlood")).setAttribute("flood-color","black"),r.setAttribute("flood-opacity",f.config.shadowOpacity),r.setAttribute("result","color"),e.appendChild(r),(l=document.createElementNS(t,"feComposite")).setAttribute("operator","in"),l.setAttribute("in","color"),l.setAttribute("in2","inverse"),l.setAttribute("result","shadow"),e.appendChild(l),(c=document.createElementNS(t,"feComposite")).setAttribute("operator","over"),c.setAttribute("in","shadow"),c.setAttribute("in2","SourceGraphic"),e.appendChild(c),f.config.showInnerShadow&&(f.canvas.canvas.childNodes[2].setAttribute("filter","url("+window.location.pathname+"#"+m+")"),f.canvas.canvas.childNodes[3].setAttribute("filter","url("+window.location.pathname+"#"+m+")")),c=null};var I=function(){for(var t=3,n=document.createElement("div"),e=n.getElementsByTagName("i");n.innerHTML="\x3c!--[if gt IE "+ ++t+"]>