src/pyams_skin/resources/js/ext/flot/jquery.flot.legend.min.js
changeset 557 bca7a7e058a3
equal deleted inserted replaced
-1:000000000000 557:bca7a7e058a3
       
     1 !function(e){function t(t,l,n,i){if(null!=l.legend.container?e(l.legend.container).html(""):n.find(".legend").remove(),l.legend.show){var r,a,h,d,c=l.legend.legendEntries=i,g=l.legend.plotOffset=t.getPlotOffset(),p=[],f=0,m="",u=l.legend.position,b=l.legend.margin,y={name:"",label:"",xPos:"",yPos:""};p[f++]='<svg class="legendLayer" style="width:inherit;height:inherit;">',p[f++]='<rect class="background" width="100%" height="100%"/>',p[f++]=s;var x=0,w=[],k=window.getComputedStyle(document.querySelector("body"));for(d=0;d<c.length;++d){L=d%l.legend.noColumns;r=c[d],y.label=r.label;var v=t.getSurface().getTextInfo("",y.label,{style:k.fontStyle,variant:k.fontVariant,weight:k.fontWeight,size:parseInt(k.fontSize),lineHeight:parseInt(k.lineHeight),family:k.fontFamily}).width;w[L]?v>w[L]&&(w[L]=v+48):w[L]=v+48}for(d=0;d<c.length;++d){var L=d%l.legend.noColumns;r=c[d],h="",y.label=r.label,y.xPos=x+3+"px",x+=w[L],(d+1)%l.legend.noColumns==0&&(x=0),y.yPos=1.5*Math.floor(d/l.legend.noColumns)+"em",r.options.lines.show&&r.options.lines.fill&&(y.name="area",y.fillColor=r.color,h+=o(y)),r.options.bars.show&&(y.name="bar",y.fillColor=r.color,h+=o(y)),r.options.lines.show&&!r.options.lines.fill&&(y.name="line",y.strokeColor=r.color,y.strokeWidth=r.options.lines.lineWidth,h+=o(y)),r.options.points.show&&(y.name=r.options.points.symbol,y.strokeColor=r.color,y.fillColor=r.options.points.fillColor,y.strokeWidth=r.options.points.lineWidth,h+=o(y)),a='<text x="'+y.xPos+'" y="'+y.yPos+'" text-anchor="start"><tspan dx="2em" dy="1.2em">'+y.label+"</tspan></text>",p[f++]="<g>"+h+a+"</g>"}p[f++]="</svg>",null==b[0]&&(b=[b,b]),"n"===u.charAt(0)?m+="top:"+(b[1]+g.top)+"px;":"s"===u.charAt(0)&&(m+="bottom:"+(b[1]+g.bottom)+"px;"),"e"===u.charAt(1)?m+="right:"+(b[0]+g.right)+"px;":"w"===u.charAt(1)&&(m+="left:"+(b[0]+g.left)+"px;");var M=6;for(d=0;d<w.length;++d)M+=w[d];var C,P=1.6*Math.ceil(c.length/l.legend.noColumns);l.legend.container?(C=e(p.join("")).appendTo(l.legend.container)[0],l.legend.container.style.width=M+"px",l.legend.container.style.height=P+"em"):((C=e('<div class="legend" style="position:absolute;'+m+'">'+p.join("")+"</div>").appendTo(n)).css("width",M+"px"),C.css("height",P+"em"),C.css("pointerEvents","none"))}}function o(e){var t="",o=e.name,l=e.xPos,n=e.yPos,i=e.fillColor,s=e.strokeColor,r=e.strokeWidth;switch(o){case"circle":t='<use xlink:href="#circle" class="legendIcon" x="'+l+'" y="'+n+'" fill="'+i+'" stroke="'+s+'" stroke-width="'+r+'" width="1.5em" height="1.5em"/>';break;case"diamond":t='<use xlink:href="#diamond" class="legendIcon" x="'+l+'" y="'+n+'" fill="'+i+'" stroke="'+s+'" stroke-width="'+r+'" width="1.5em" height="1.5em"/>';break;case"cross":t='<use xlink:href="#cross" class="legendIcon" x="'+l+'" y="'+n+'" stroke="'+s+'" stroke-width="'+r+'" width="1.5em" height="1.5em"/>';break;case"rectangle":t='<use xlink:href="#rectangle" class="legendIcon" x="'+l+'" y="'+n+'" fill="'+i+'" stroke="'+s+'" stroke-width="'+r+'" width="1.5em" height="1.5em"/>';break;case"plus":t='<use xlink:href="#plus" class="legendIcon" x="'+l+'" y="'+n+'" stroke="'+s+'" stroke-width="'+r+'" width="1.5em" height="1.5em"/>';break;case"bar":t='<use xlink:href="#bars" class="legendIcon" x="'+l+'" y="'+n+'" fill="'+i+'" width="1.5em" height="1.5em"/>';break;case"area":t='<use xlink:href="#area" class="legendIcon" x="'+l+'" y="'+n+'" fill="'+i+'" width="1.5em" height="1.5em"/>';break;case"line":t='<use xlink:href="#line" class="legendIcon" x="'+l+'" y="'+n+'" stroke="'+s+'" stroke-width="'+r+'" width="1.5em" height="1.5em"/>';break;default:t='<use xlink:href="#circle" class="legendIcon" x="'+l+'" y="'+n+'" fill="'+i+'" stroke="'+s+'" stroke-width="'+r+'" width="1.5em" height="1.5em"/>'}return t}function l(t,o,l){var n=o,i=t.reduce(function(e,t,o){var l=n?n(t.label,t):t.label;if(!t.hasOwnProperty("label")||l){var i={label:l||"Plot "+(o+1),color:t.color,options:{lines:t.lines,points:t.points,bars:t.bars}};e.push(i)}return e},[]);if(l)if(e.isFunction(l))i.sort(l);else if("reverse"===l)i.reverse();else{var s="descending"!==l;i.sort(function(e,t){return e.label===t.label?0:e.label<t.label!==s?1:-1})}return i}function n(e,t){for(var o in e)if(e.hasOwnProperty(o)&&e[o]!==t[o])return!0;return!1}function i(e,t){if(!e||!t)return!0;if(e.length!==t.length)return!0;var o,l,i,s,r;for(o=0;o<t.length;o++){if(l=t[o],i=e[o],l.label!==i.label)return!0;if(l.color!==i.color)return!0;if(s=l.options.lines,r=i.options.lines,n(s,r))return!0;if(s=l.options.points,r=i.options.points,n(s,r))return!0;if(s=l.options.bars,r=i.options.bars,n(s,r))return!0}return!1}var s='<defs><symbol id="line" fill="none" viewBox="-5 -5 25 25"><polyline points="0,15 5,5 10,10 15,0"/></symbol><symbol id="area" stroke-width="1" viewBox="-5 -5 25 25"><polyline points="0,15 5,5 10,10 15,0, 15,15, 0,15"/></symbol><symbol id="bars" stroke-width="1" viewBox="-5 -5 25 25"><polyline points="1.5,15.5 1.5,12.5, 4.5,12.5 4.5,15.5 6.5,15.5 6.5,3.5, 9.5,3.5 9.5,15.5 11.5,15.5 11.5,7.5 14.5,7.5 14.5,15.5 1.5,15.5"/></symbol><symbol id="circle" viewBox="-5 -5 25 25"><circle cx="0" cy="15" r="2.5"/><circle cx="5" cy="5" r="2.5"/><circle cx="10" cy="10" r="2.5"/><circle cx="15" cy="0" r="2.5"/></symbol><symbol id="rectangle" viewBox="-5 -5 25 25"><rect x="-2.1" y="12.9" width="4.2" height="4.2"/><rect x="2.9" y="2.9" width="4.2" height="4.2"/><rect x="7.9" y="7.9" width="4.2" height="4.2"/><rect x="12.9" y="-2.1" width="4.2" height="4.2"/></symbol><symbol id="diamond" viewBox="-5 -5 25 25"><path d="M-3,15 L0,12 L3,15, L0,18 Z"/><path d="M2,5 L5,2 L8,5, L5,8 Z"/><path d="M7,10 L10,7 L13,10, L10,13 Z"/><path d="M12,0 L15,-3 L18,0, L15,3 Z"/></symbol><symbol id="cross" fill="none" viewBox="-5 -5 25 25"><path d="M-2.1,12.9 L2.1,17.1, M2.1,12.9 L-2.1,17.1 Z"/><path d="M2.9,2.9 L7.1,7.1 M7.1,2.9 L2.9,7.1 Z"/><path d="M7.9,7.9 L12.1,12.1 M12.1,7.9 L7.9,12.1 Z"/><path d="M12.9,-2.1 L17.1,2.1 M17.1,-2.1 L12.9,2.1 Z"/></symbol><symbol id="plus" fill="none" viewBox="-5 -5 25 25"><path d="M0,12 L0,18, M-3,15 L3,15 Z"/><path d="M5,2 L5,8 M2,5 L8,5 Z"/><path d="M10,7 L10,13 M7,10 L13,10 Z"/><path d="M15,-3 L15,3 M12,0 L18,0 Z"/></symbol></defs>';e.plot.plugins.push({init:function(e){e.hooks.setupGrid.push(function(e){var o=e.getOptions(),s=e.getData(),r=o.legend.labelFormatter,a=o.legend.legendEntries,h=o.legend.plotOffset,d=l(s,r,o.legend.sorted),c=e.getPlotOffset();(i(a,d)||n(h,c))&&t(e,o,e.getPlaceholder(),d)})},options:{legend:{show:!1,noColumns:1,labelFormatter:null,container:null,position:"ne",margin:5,sorted:null}},name:"legend",version:"1.0"})}(jQuery);