dashboard
Version:
Create dashboards with gadgets on node.js
21 lines (18 loc) • 6.02 kB
JavaScript
/*
Highcharts JS v2.0.3 (2010-08-07)
Exporting module
(c) 2010 Torstein H�nsi
License: www.highcharts.com/license
*/
(function(){var i=Highcharts,F=i.Chart,z=i.addEvent,u=i.defaultOptions,n=i.createElement,G=i.discardElement,A=i.css,D=i.merge,o=i.each,p=i.extend;u=Math;var J=u.max,q=document,K=window,v="M",w="L",x="div",L="hidden",B="none",M="highcharts-",H="absolute",l="px";u=i.setOptions({lang:{downloadPNG:"Download PNG image",downloadJPEG:"Download JPEG image",downloadPDF:"Download PDF document",downloadSVG:"Download SVG vector image",exportButtonTitle:"Export to raster or vector image",printButtonTitle:"Print the chart"}});
u.navigation={menuStyle:{border:"1px solid #A0A0A0",background:"#FFFFFF"},menuItemStyle:{padding:"0 5px",background:B,color:"#303030"},menuItemHoverStyle:{background:"#4572A5",color:"#FFFFFF"},buttonOptions:{align:"right",backgroundColor:{linearGradient:[0,0,0,20],stops:[[0.4,"#F7F7F7"],[0.6,"#E3E3E3"]]},borderColor:"#B0B0B0",borderRadius:3,borderWidth:1,height:20,hoverBorderColor:"#909090",hoverSymbolFill:"#81A7CF",hoverSymbolStroke:"#4572A5",symbolFill:"#E0E0E0",symbolStroke:"#A0A0A0",symbolX:11.5,
symbolY:10.5,verticalAlign:"top",width:24,y:10}};u.exporting={type:"image/png",url:"http://export.highcharts.com/",width:800,buttons:{exportButton:{symbol:"exportIcon",x:-10,symbolFill:"#A8BF77",hoverSymbolFill:"#768F3E",_titleKey:"exportButtonTitle",menuItems:[{textKey:"downloadPNG",onclick:function(){this.exportChart()}},{textKey:"downloadJPEG",onclick:function(){this.exportChart({type:"image/jpeg"})}},{textKey:"downloadPDF",onclick:function(){this.exportChart({type:"application/pdf"})}},{textKey:"downloadSVG",
onclick:function(){this.exportChart({type:"image/svg+xml"})}}]},printButton:{symbol:"printIcon",x:-36,symbolFill:"#B5C9DF",hoverSymbolFill:"#779ABF",_titleKey:"printButtonTitle",onclick:function(){this.print()}}}};p(F.prototype,{getSVG:function(b){var c=this,a,f,d=D(c.options,b);if(!q.createElementNS)q.createElementNS=function(g,e){var h=q.createElement(e);h.getBBox=function(){return c.renderer.Element.prototype.getBBox.apply({element:h})};return h};a=n(x,null,{position:H,top:"-9999em",width:c.chartWidth+
l,height:c.chartHeight+l},q.body);p(d.chart,{renderTo:a,renderer:"SVG"});d.exporting.enabled=false;d.chart.plotBackgroundImage=null;o(d.series,function(g){g.animation=false;o(g.data,function(e){e&&e.marker&&/^url\(/.test(e.marker.symbol)&&delete e.marker.symbol})});b=new Highcharts.Chart(d);f=a.getElementsByTagName(x)[0].innerHTML;d=null;b.destroy();G(a);return f=f.replace(/zIndex="[^"]+"/g,"").replace(/isShadow="[^"]+"/g,"").replace(/symbolName="[^"]+"/g,"").replace(/jQuery[0-9]+="[^"]+"/g,"").replace(/isTracker="[^"]+"/g,
"").replace(/url\([^#]+#/g,"url(#").replace(/id=([^" >]+)/g,'id="$1"').replace(/class=([^" ]+)/g,'class="$1"').replace(/ transform /g," ").replace(/:path/g,"path").replace(/style="([^"]+)"/g,function(g){return g.toLowerCase()})},exportChart:function(b,c){var a,f=this,d=f.getSVG(c);b=D(f.options.exporting,b);a=n("form",{method:"post",action:b.url},{display:B},q.body);o(["filename","type","width","svg"],function(g){n("input",{type:L,name:g,value:{filename:b.filename||"chart",type:b.type,width:b.width,
svg:d}[g]},null,a)});a.submit();G(a)},print:function(){var b=this,c=b.container,a=[],f=c.parentNode,d=q.body,g=d.childNodes;if(!b.isPrinting){b.isPrinting=true;o(g,function(e,h){if(e.nodeType==1){a[h]=e.style.display;e.style.display=B}});d.appendChild(c);K.print();setTimeout(function(){f.appendChild(c);o(g,function(e,h){if(e.nodeType==1)e.style.display=a[h]});b.isPrinting=false},1E3)}},contextMenu:function(b,c,a,f,d,g){var e=this,h=e.options.navigation,m=h.menuItemStyle,r=e.chartWidth,s=e.chartHeight,
t="cache-"+b,j=e[t],k=J(d,g),y="3px 3px 10px #888",I,E;if(!j){e[t]=j=n(x,{className:M+b},{position:H,zIndex:1E3,padding:k+l},e.container);I=n(x,null,p({MozBoxShadow:y,WebkitBoxShadow:y},h.menuStyle),j);E=function(){A(j,{display:B})};z(j,"mouseleave",E);o(c,function(C){if(C)n(x,{onclick:function(){E();C.onclick.apply(e,arguments)},onmouseover:function(){A(this,h.menuItemHoverStyle)},onmouseout:function(){A(this,m)},innerHTML:C.text||i.getOptions().lang[C.textKey]},p({cursor:"pointer"},m),I)});e.exportMenuWidth=
j.offsetWidth;e.exportMenuHeigh=j.offsetHeight}b={display:"block"};if(a+e.exportMenuWidth>r)b.right=r-a-d-k+l;else b.left=a-k+l;if(f+g+e.exportMenuWidth>s)b.bottom=s-f-k+l;else b.top=f+g-k+l;A(j,b)},addButton:function(b){function c(){j.attr(y);t.attr(k)}var a=this,f=a.renderer,d=D(a.options.navigation.buttonOptions,b),g=d.onclick,e=d.menuItems;b=a.getAlignment(d);var h=b.x,m=b.y,r=d.width,s=d.height,t,j;b=d.borderWidth;var k={stroke:d.borderColor},y={stroke:d.symbolStroke,fill:d.symbolFill};if(d.enabled!==
false){t=f.rect(0,0,r,s,d.borderRadius,b).translate(h,m).attr(p({fill:d.backgroundColor,"stroke-width":b,zIndex:19},k)).add();b=f.rect(h,m,r,s,0).attr({fill:"rgba(255, 255, 255, 0.001)",title:i.getOptions().lang[d._titleKey],zIndex:21}).css({cursor:"pointer"}).on("mouseover",function(){j.attr({stroke:d.hoverSymbolStroke,fill:d.hoverSymbolFill});t.attr({stroke:d.hoverBorderColor})}).on("mouseout",c).add();z(b.element,"click",c);if(e)g=function(){a.contextMenu("export-menu",e,h,m,r,s)};z(b.element,
"click",function(){g.apply(a,arguments)});j=f.symbol(d.symbol,h+d.symbolX,m+d.symbolY,(d.symbolSize||12)/2).attr(p(y,{"stroke-width":d.symbolStrokeWidth||1,zIndex:20})).add()}}});i.Renderer.prototype.symbols.exportIcon=function(b,c,a){return[v,b-a,c+a,w,b+a,c+a,b+a,c+a*0.5,b-a,c+a*0.5,"Z",v,b,c+a*0.5,w,b-a*0.5,c-a/3,b-a/6,c-a/3,b-a/6,c-a,b+a/6,c-a,b+a/6,c-a/3,b+a*0.5,c-a/3,"Z"]};i.Renderer.prototype.symbols.printIcon=function(b,c,a){return[v,b-a,c+a*0.5,w,b+a,c+a*0.5,b+a,c-a/3,b-a,c-a/3,"Z",v,b-a*
0.5,c-a/3,w,b-a*0.5,c-a,b+a*0.5,c-a,b+a*0.5,c-a/3,"Z",v,b-a*0.5,c+a*0.5,w,b-a*0.75,c+a,b+a*0.75,c+a,b+a*0.5,c+a*0.5,"Z"]};z(F.prototype,"load",function(b){b=b.target;var c,a=b.options.exporting,f=a.buttons;if(a.enabled!==false)for(c in f)b.addButton(f[c])})})();