mpld3 0.5.2 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mpld3.v0.5.6.min.js +19298 -0
- package/mpld3.v0.5.6.js +2079 -0
- package/mpld3.v0.5.6.min.js +2 -0
- package/package.json +3 -3
- package/dist/mpld3.v0.5.2.min.js +0 -6
- package/mpld3.v0.5.2.js +0 -1820
- package/mpld3.v0.5.2.min.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function mpld3_cloneObj(t){var e={};for(var i in t)e[i]=t[i];return e}function mpld3_generateId(t,e){t="undefined"!=typeof t?t:10,e="undefined"!=typeof e?e:"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";for(var i=e.charAt(Math.round(Math.random()*(e.length-11))),s=1;t>s;s++)i+=e.charAt(Math.round(Math.random()*(e.length-1)));return i}function mpld3_interpolateDates(t,e){var i=d3.interpolate([t[0].valueOf(),t[1].valueOf()],[e[0].valueOf(),e[1].valueOf()]);return function(t){var e=i(t);return[new Date(e[0]),new Date(e[1])]}}function isUndefined(t){return"undefined"==typeof t}function isUndefinedOrNull(t){return null==t||isUndefined(t)}function getMod(t,e){return t.length>0?t[e%t.length]:null}function mpld3_path(t){function e(t,e){var n=function(t){return"function"==typeof t?t:function(){return t}},p=n(i),a=n(s),l=[],h=[],d=0,c=-1,u=0,m=!1;if(!e){e=["M"];for(var f=1;f<t.length;f++)e.push("L")}for(;++c<e.length;){for(u=d+r[e[c]],l=[];u>d;)o.call(this,t[d],d)?(l.push(p.call(this,t[d],d),a.call(this,t[d],d)),d++):(l=null,d=u);l?m&&l.length>0?(h.push("M",l[0],l[1]),m=!1):(h.push(e[c]),h=h.concat(l)):m=!0}return d!=t.length&&console.warn("Warning: not all vertices used in Path"),h.join(" ")}var i=function(t,e){return t[0]},s=function(t,e){return t[1]},o=function(t,e){return!0},r={M:1,m:1,L:1,l:1,Q:2,q:2,T:1,t:1,S:2,s:2,C:3,c:3,Z:0,z:0};return e.x=function(t){return arguments.length?(i=t,e):i},e.y=function(t){return arguments.length?(s=t,e):s},e.defined=function(t){return arguments.length?(o=t,e):o},e.call=e,e}function mpld3_multiscale(t){function e(t){return i.forEach(function(e){t=e(t)}),t}var i=Array.prototype.slice.call(arguments,0),s=i.length;return e.domain=function(t){return arguments.length?(i[0].domain(t),e):i[0].domain()},e.range=function(t){return arguments.length?(i[s-1].range(t),e):i[s-1].range()},e.step=function(t){return i[t]},e}function mpld3_Grid(t,e){if(mpld3_PlotElement.call(this,t,e),this.cssclass="mpld3-"+this.props.xy+"grid","x"==this.props.xy)this.transform="translate(0,"+this.ax.height+")",this.position="bottom",this.scale=this.ax.xdom,this.tickSize=-this.ax.height;else{if("y"!=this.props.xy)throw"unrecognized grid xy specifier: should be 'x' or 'y'";this.transform="translate(0,0)",this.position="left",this.scale=this.ax.ydom,this.tickSize=-this.ax.width}}function mpld3_Axis(t,e){mpld3_PlotElement.call(this,t,e);var i={bottom:[0,this.ax.height],top:[0,0],left:[0,0],right:[this.ax.width,0]},s={bottom:"x",top:"x",left:"y",right:"y"};this.ax=t,this.transform="translate("+i[this.props.position]+")",this.props.xy=s[this.props.position],this.cssclass="mpld3-"+this.props.xy+"axis",this.scale=this.ax[this.props.xy+"dom"],this.tickNr=null,this.tickFormat=null}function mpld3_Coordinates(t,e){if(this.trans=t,"undefined"==typeof e){if(this.ax=null,this.fig=null,"display"!==this.trans)throw"ax must be defined if transform != 'display'"}else this.ax=e,this.fig=e.fig;if(this.zoomable="data"===this.trans,this.x=this["x_"+this.trans],this.y=this["y_"+this.trans],"undefined"==typeof this.x||"undefined"==typeof this.y)throw"unrecognized coordinate code: "+this.trans}function mpld3_Path(t,e){mpld3_PlotElement.call(this,t,e),this.data=t.fig.get_data(this.props.data),this.pathcodes=this.props.pathcodes,this.pathcoords=new mpld3_Coordinates(this.props.coordinates,this.ax),this.offsetcoords=new mpld3_Coordinates(this.props.offsetcoordinates,this.ax),this.datafunc=mpld3_path()}function mpld3_PathCollection(t,e){mpld3_PlotElement.call(this,t,e),(null==this.props.facecolors||0==this.props.facecolors.length)&&(this.props.facecolors=["none"]),(null==this.props.edgecolors||0==this.props.edgecolors.length)&&(this.props.edgecolors=["none"]);var i=this.ax.fig.get_data(this.props.offsets);(null===i||0===i.length)&&(i=[null]);var s=Math.max(this.props.paths.length,i.length);if(i.length===s)this.offsets=i;else{this.offsets=[];for(var o=0;s>o;o++)this.offsets.push(getMod(i,o))}this.pathcoords=new mpld3_Coordinates(this.props.pathcoordinates,this.ax),this.offsetcoords=new mpld3_Coordinates(this.props.offsetcoordinates,this.ax)}function mpld3_Line(t,e){mpld3_PlotElement.call(this,t,e);var i=this.props;i.facecolor="none",i.edgecolor=i.color,delete i.color,i.edgewidth=i.linewidth,delete i.linewidth;const s=i.drawstyle;switch(delete i.drawstyle,this.defaultProps=mpld3_Path.prototype.defaultProps,mpld3_Path.call(this,t,i),s){case"steps":case"steps-pre":this.datafunc=d3.line().curve(d3.curveStepBefore);break;case"steps-post":this.datafunc=d3.line().curve(d3.curveStepAfter);break;case"steps-mid":this.datafunc=d3.line().curve(d3.curveStep);break;default:this.datafunc=d3.line().curve(d3.curveLinear)}}function mpld3_Markers(t,e){mpld3_PlotElement.call(this,t,e),null!==this.props.markerpath?this.marker=0==this.props.markerpath[0].length?null:mpld3.path().call(this.props.markerpath[0],this.props.markerpath[1]):this.marker=null===this.props.markername?null:d3.symbol(this.props.markername).size(Math.pow(this.props.markersize,2))();var i={paths:[this.props.markerpath],offsets:t.fig.parse_offsets(t.fig.get_data(this.props.data,!0)),xindex:this.props.xindex,yindex:this.props.yindex,offsetcoordinates:this.props.coordinates,edgecolors:[this.props.edgecolor],edgewidths:[this.props.edgewidth],facecolors:[this.props.facecolor],alphas:[this.props.alpha],zorder:this.props.zorder,id:this.props.id};this.requiredProps=mpld3_PathCollection.prototype.requiredProps,this.defaultProps=mpld3_PathCollection.prototype.defaultProps,mpld3_PathCollection.call(this,t,i)}function mpld3_Image(t,e){mpld3_PlotElement.call(this,t,e),this.coords=new mpld3_Coordinates(this.props.coordinates,this.ax)}function mpld3_Text(t,e){mpld3_PlotElement.call(this,t,e),this.text=this.props.text,this.position=this.props.position,this.coords=new mpld3_Coordinates(this.props.coordinates,this.ax)}function mpld3_Axes(t,e){function i(t){return new Date(t[0],t[1],t[2],t[3],t[4],t[5])}function s(t,e){return"date"!==t?e:[i(e[0]),i(e[1])]}function o(t,e,i){var s="date"===t?d3.scaleTime():"log"===t?d3.scaleLog():d3.scaleLinear();return s.domain(e).range(i)}mpld3_PlotElement.call(this,t,e),this.axnum=this.fig.axes.length,this.axid=this.fig.figid+"_ax"+(this.axnum+1),this.clipid=this.axid+"_clip",this.props.xdomain=this.props.xdomain||this.props.xlim,this.props.ydomain=this.props.ydomain||this.props.ylim,this.sharex=[],this.sharey=[],this.elements=[],this.axisList=[];var r=this.props.bbox;this.position=[r[0]*this.fig.width,(1-r[1]-r[3])*this.fig.height],this.width=r[2]*this.fig.width,this.height=r[3]*this.fig.height,this.isZoomEnabled=null,this.zoom=null,this.lastTransform=d3.zoomIdentity,this.isBoxzoomEnabled=null,this.isLinkedBrushEnabled=null,this.isCurrentLinkedBrushTarget=!1,this.brushG=null,this.props.xdomain=s(this.props.xscale,this.props.xdomain),this.props.ydomain=s(this.props.yscale,this.props.ydomain),this.x=this.xdom=o(this.props.xscale,this.props.xdomain,[0,this.width]),this.y=this.ydom=o(this.props.yscale,this.props.ydomain,[this.height,0]),"date"===this.props.xscale&&(this.x=mpld3.multiscale(d3.scaleLinear().domain(this.props.xlim).range(this.props.xdomain.map(Number)),this.xdom)),"date"===this.props.yscale&&(this.y=mpld3.multiscale(d3.scaleLinear().domain(this.props.ylim).range(this.props.ydomain.map(Number)),this.ydom));for(var n=this.props.axes,p=0;p<n.length;p++){var a=new mpld3.Axis(this,n[p]);this.axisList.push(a),this.elements.push(a),(this.props.gridOn||a.props.grid.gridOn)&&this.elements.push(a.getGrid())}for(var l=this.props.paths,p=0;p<l.length;p++)this.elements.push(new mpld3.Path(this,l[p]));for(var h=this.props.lines,p=0;p<h.length;p++)this.elements.push(new mpld3.Line(this,h[p]));for(var d=this.props.markers,p=0;p<d.length;p++)this.elements.push(new mpld3.Markers(this,d[p]));for(var c=this.props.texts,p=0;p<c.length;p++)this.elements.push(new mpld3.Text(this,c[p]));for(var u=this.props.collections,p=0;p<u.length;p++)this.elements.push(new mpld3.PathCollection(this,u[p]));for(var m=this.props.images,p=0;p<m.length;p++)this.elements.push(new mpld3.Image(this,m[p]));this.elements.sort(function(t,e){return t.props.zorder-e.props.zorder})}function mpld3_Toolbar(t,e){mpld3_PlotElement.call(this,t,e),this.buttons=[],this.props.buttons.forEach(this.addButton.bind(this))}function mpld3_Button(t,e){mpld3_PlotElement.call(this,t),this.toolbar=t,this.fig=this.toolbar.fig,this.cssclass="mpld3-"+e+"button",this.active=!1}function mpld3_Plugin(t,e){mpld3_PlotElement.call(this,t,e)}function mpld3_ResetPlugin(t,e){mpld3_Plugin.call(this,t,e);var i=mpld3.ButtonFactory({buttonID:"reset",sticky:!1,onActivate:function(){this.toolbar.fig.reset()},icon:function(){return mpld3.icons.reset}});this.fig.buttons.push(i)}function mpld3_ZoomPlugin(t,e){mpld3_Plugin.call(this,t,e),null===this.props.enabled&&(this.props.enabled=!this.props.button);var i=this.props.enabled;if(this.props.button){var s=mpld3.ButtonFactory({buttonID:"zoom",sticky:!0,actions:["scroll","drag"],onActivate:this.activate.bind(this),onDeactivate:this.deactivate.bind(this),onDraw:function(){this.setState(i)},icon:function(){return mpld3.icons.move}});this.fig.buttons.push(s)}}function mpld3_BoxZoomPlugin(t,e){mpld3_Plugin.call(this,t,e),null===this.props.enabled&&(this.props.enabled=!this.props.button);var i=this.props.enabled;if(this.props.button){var s=mpld3.ButtonFactory({buttonID:"boxzoom",sticky:!0,actions:["drag"],onActivate:this.activate.bind(this),onDeactivate:this.deactivate.bind(this),onDraw:function(){this.setState(i)},icon:function(){return mpld3.icons.zoom}});this.fig.buttons.push(s)}this.extentClass="boxzoombrush"}function mpld3_TooltipPlugin(t,e){mpld3_Plugin.call(this,t,e)}function mpld3_LinkedBrushPlugin(t,e){mpld3.Plugin.call(this,t,e),null===this.props.enabled&&(this.props.enabled=!this.props.button);var i=this.props.enabled;if(this.props.button){var s=mpld3.ButtonFactory({buttonID:"linkedbrush",sticky:!0,actions:["drag"],onActivate:this.activate.bind(this),onDeactivate:this.deactivate.bind(this),onDraw:function(){this.setState(i)},icon:function(){return mpld3.icons.brush}});this.fig.buttons.push(s)}this.pathCollectionsByAxes=[],this.objectsByAxes=[],this.allObjects=[],this.extentClass="linkedbrush",this.dataKey="offsets",this.objectClass=null}function MousePositionPlugin(t,e){mpld3.Plugin.call(this,t,e)}function mpld3_Figure(t,e){mpld3_PlotElement.call(this,null,e),this.figid=t,this.width=this.props.width,this.height=this.props.height,this.data=this.props.data,this.buttons=[],this.root=d3.select("#"+t).append("div").style("position","relative"),this.axes=[];for(var i=0;i<this.props.axes.length;i++)this.axes.push(new mpld3_Axes(this,this.props.axes[i]));this.plugins=[],this.pluginsByType={},this.props.plugins.forEach(function(t){this.addPlugin(t)}.bind(this)),this.toolbar=new mpld3.Toolbar(this,{buttons:this.buttons})}function mpld3_PlotElement(t,e){this.parent=isUndefinedOrNull(t)?null:t,this.props=isUndefinedOrNull(e)?{}:this.processProps(e),this.fig=t instanceof mpld3_Figure?t:t&&"fig"in t?t.fig:null,this.ax=t instanceof mpld3_Axes?t:t&&"ax"in t?t.ax:null}if(!d3)var d3=require("d3");var mpld3={_mpld3IsLoaded:!0,figures:[],plugin_map:{}};mpld3.version="0.5.6",mpld3.register_plugin=function(t,e){mpld3.plugin_map[t]=e},mpld3.remove_figure=function(t){var e=document.getElementById(t);null!==e&&(e.innerHTML="");for(var i=0;i<mpld3.figures.length;i++){var s=mpld3.figures[i];s.figid===t&&mpld3.figures.splice(i,1)}return!0},mpld3.draw_figure=function(t,e,i,s){var o=document.getElementById(t);if(s="undefined"!=typeof s?s:!1,s&&mpld3.remove_figure(t),null===o)throw t+" is not a valid id";var r=new mpld3.Figure(t,e);return i&&i(r,o),mpld3.figures.push(r),r.draw(),r},mpld3.cloneObj=mpld3_cloneObj,mpld3.boundsToTransform=function(t,e){var i=t.width,s=t.height,o=e[1][0]-e[0][0],r=e[1][1]-e[0][1],n=(e[0][0]+e[1][0])/2,p=(e[0][1]+e[1][1])/2,a=Math.max(1,Math.min(8,.9/Math.max(o/i,r/s))),l=[i/2-a*n,s/2-a*p];return{translate:l,scale:a}},mpld3.getTransformation=function(t){var e=document.createElementNS("http://www.w3.org/2000/svg","g");e.setAttributeNS(null,"transform",t);var i,s,o,r=e.transform.baseVal.consolidate().matrix,n=r.a,p=r.b,a=r.c,l=r.d,h=r.e,d=r.f;(i=Math.sqrt(n*n+p*p))&&(n/=i,p/=i),(o=n*a+p*l)&&(a-=n*o,l-=p*o),(s=Math.sqrt(a*a+l*l))&&(a/=s,l/=s,o/=s),p*a>n*l&&(n=-n,p=-p,o=-o,i=-i);var c={translateX:h,translateY:d,rotate:180*Math.atan2(p,n)/Math.PI,skewX:180*Math.atan(o)/Math.PI,scaleX:i,scaleY:s},u="translate("+c.translateX+","+c.translateY+")rotate("+c.rotate+")skewX("+c.skewX+")scale("+c.scaleX+","+c.scaleY+")";return u},mpld3.merge_objects=function(t){for(var e,i={},s=0;s<arguments.length;s++){e=arguments[s];for(var o in e)i[o]=e[o]}return i},mpld3.generate_id=function(t,e){return console.warn("mpld3.generate_id is deprecated. Use mpld3.generateId instead."),mpld3_generateId(t,e)},mpld3.generateId=mpld3_generateId,mpld3.get_element=function(t,e){var i,s,o;i="undefined"==typeof e?mpld3.figures:"undefined"==typeof e.length?[e]:e;for(var r=0;r<i.length;r++){if(e=i[r],e.props.id===t)return e;for(var n=0;n<e.axes.length;n++){if(s=e.axes[n],s.props.id===t)return s;for(var p=0;p<s.elements.length;p++)if(o=s.elements[p],o.props.id===t)return o}}return null},mpld3.insert_css=function(t,e){var i=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style"),o=t+" {";for(var r in e)o+=r+":"+e[r]+"; ";o+="}",s.type="text/css",s.styleSheet?s.styleSheet.cssText=o:s.appendChild(document.createTextNode(o)),i.appendChild(s)},mpld3.process_props=function(t,e,i,s){function o(t){mpld3_PlotElement.call(this,null,t)}console.warn("mpld3.process_props is deprecated. Plot elements should derive from mpld3.PlotElement"),o.prototype=Object.create(mpld3_PlotElement.prototype),o.prototype.constructor=o,o.prototype.requiredProps=s,o.prototype.defaultProps=i;var r=new o(e);return r.props},mpld3.interpolateDates=mpld3_interpolateDates,mpld3.path=function(){return mpld3_path()},mpld3.multiscale=mpld3_multiscale,mpld3.icons={reset:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI\nWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gIcACMoD/OzIwAAAJhJREFUOMtjYKAx4KDUgNsMDAx7\nyNV8i4GB4T8U76VEM8mGYNNMtCH4NBM0hBjNMIwSsMzQ0MamcDkDA8NmQi6xggpUoikwQbIkHk2u\nE0rLI7vCBknBSyxeRDZAE6qHgQkq+ZeBgYERSfFPAoHNDNUDN4BswIRmKgxwEasP2dlsDAwMYlA/\n/mVgYHiBpkkGKscIDaPfVMmuAGnOTaGsXF0MAAAAAElFTkSuQmCC\n",move:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI\nWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gIcACQMfLHBNQAAANZJREFUOMud07FKA0EQBuAviaKB\nlFr7COJrpAyYRlKn8hECEkFEn8ROCCm0sBMRYgh5EgVFtEhsRjiO27vkBoZd/vn5d3b+XcrjFI9q\nxgXWkc8pUjOB93GMd3zgB9d1unjDSxmhWSHQqOJki+MtOuv/b3ZifUqctIrMxwhHuG1gim4Ma5kR\nWuEkXFgU4B0MW1Ho4TeyjX3s4TDq3zn8ALvZ7q5wX9DqLOHCDA95cFBAnOO1AL/ZdNopgY3fQcqF\nyriMe37hM9w521ZkkvlMo7o/8g7nZYQ/QDctp1nTCf0AAAAASUVORK5CYII=\n",zoom:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI\nWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gMPDiIRPL/2oQAAANBJREFUOMvF0b9KgzEcheHHVnCT\nKoI4uXbtLXgB3oJDJxevw1VwkoJ/NjepQ2/BrZRCx0ILFURQKV2kyOeSQpAmn7WDB0Lg955zEhLy\n2scdXlBggits+4WOQqjAJ3qYR7NGLrwXGU9+sGbEtlIF18FwmuBngZ+nCt6CIacC3Rx8LSl4xzgF\nn0tusBn4UyVhuA/7ZYIv5g+pE3ail25hN/qdmzCfpsJVjKKCZesDBwtzrAqGOMQj6vhCDRsY4ALH\nmOVObltR/xeG/jph6OD2r+Fv5lZBWEhMx58AAAAASUVORK5CYII=\n",brush:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI\nWXMAAEQkAABEJAFAZ8RUAAAAB3RJTUUH3gMCEiQKB9YaAgAAAWtJREFUOMuN0r1qVVEQhuFn700k\nnfEvBq0iNiIiOKXgH4KCaBeIhWARK/EibLwFCwVLjyAWaQzRGG9grC3URkHUBKKgRuWohWvL5pjj\nyTSLxcz7rZlZHyMiItqzFxGTEVF18/UoODNFxDIO4x12dkXqTcBPsCUzD+AK3ndFqhHwEsYz82gn\nN4dbmMRK9R/4KY7jAvbiWmYeHBT5Z4QCP8J1rGAeN3GvU3Mbl/Gq3qCDcxjLzOV+v78fq/iFIxFx\nPyJ2lNJpfBy2g59YzMyzEbEVLzGBJjOriLiBq5gaJrCIU3hcRCbwAtuwjm/Yg/V6I9NgDA1OR8RC\nZq6Vcd7iUwtn5h8fdMBdETGPE+Xe4ExELDRNs4bX2NfCUHe+7UExyfkCP8MhzOA7PuAkvrbwXyNF\nxF3MDqxiqlhXC7SPdaOKiN14g0u4g3H0MvOiTUSNY3iemb0ywmfMdfYyUmAJ2yPiBx6Wr/oy2Oqw\n+A1SupBzAOuE/AAAAABJRU5ErkJggg==\n"},mpld3.Grid=mpld3_Grid,mpld3_Grid.prototype=Object.create(mpld3_PlotElement.prototype),mpld3_Grid.prototype.constructor=mpld3_Grid,mpld3_Grid.prototype.requiredProps=["xy"],mpld3_Grid.prototype.defaultProps={color:"gray",dasharray:"2,2",alpha:"0.5",nticks:10,gridOn:!0,tickvalues:null,zorder:0},mpld3_Grid.prototype.draw=function(){var t={left:"axisLeft",right:"axisRight",top:"axisTop",bottom:"axisBottom"}[this.position];this.grid=d3[t](this.scale).ticks(this.props.nticks).tickValues(this.props.tickvalues).tickSize(this.tickSize,0,0).tickFormat(""),this.elem=this.ax.axes.append("g").attr("class",this.cssclass).attr("transform",this.transform).call(this.grid),mpld3.insert_css("div#"+this.ax.fig.figid+" ."+this.cssclass+" .tick",{stroke:this.props.color,"stroke-dasharray":this.props.dasharray,"stroke-opacity":this.props.alpha}),mpld3.insert_css("div#"+this.ax.fig.figid+" ."+this.cssclass+" path",{"stroke-width":0}),mpld3.insert_css("div#"+this.ax.fig.figid+" ."+this.cssclass+" .domain",{"pointer-events":"none"})},mpld3_Grid.prototype.zoomed=function(t){t?"x"==this.props.xy?this.elem.call(this.grid.scale(t.rescaleX(this.scale))):this.elem.call(this.grid.scale(t.rescaleY(this.scale))):this.elem.call(this.grid)},mpld3.Axis=mpld3_Axis,mpld3_Axis.prototype=Object.create(mpld3_PlotElement.prototype),mpld3_Axis.prototype.constructor=mpld3_Axis,mpld3_Axis.prototype.requiredProps=["position"],mpld3_Axis.prototype.defaultProps={nticks:10,tickvalues:null,tickformat:null,filtered_tickvalues:null,filtered_tickformat:null,tickformat_formatter:null,fontsize:"11px",fontcolor:"black",axiscolor:"black",scale:"linear",grid:{},zorder:0,visible:!0},mpld3_Axis.prototype.getGrid=function(){var t={nticks:this.props.nticks,zorder:this.props.zorder,tickvalues:null,xy:this.props.xy};if(this.props.grid)for(var e in this.props.grid)t[e]=this.props.grid[e];return new mpld3_Grid(this.ax,t)},mpld3_Axis.prototype.wrapTicks=function(){function t(t,e,i){i=i||1.2,t.each(function(){for(var t,s=d3.select(this),o=s.node().getBBox(),r=o.height,n=s.text().split(/\s+/).reverse(),p=[],a=0,l=s.attr("y"),h=r,d=s.text(null).append("tspan").attr("x",0).attr("y",l).attr("dy",h);t=n.pop();)p.push(t),d.text(p.join(" ")),d.node().getComputedTextLength()>e&&(p.pop(),d.text(p.join(" ")),p=[t],d=s.append("tspan").attr("x",0).attr("y",l).attr("dy",++a*(r*i)+h).text(t))})}var e=80;"x"==this.props.xy&&this.elem.selectAll("text").call(t,e)},mpld3_Axis.prototype.draw=function(){var t="x"===this.props.xy?this.parent.props.xscale:this.parent.props.yscale;if("date"===t&&this.props.tickvalues){var e="x"===this.props.xy?this.parent.x.domain():this.parent.y.domain(),i="x"===this.props.xy?this.parent.xdom.domain():this.parent.ydom.domain(),s=d3.scaleLinear().domain(e).range(i);this.props.tickvalues=this.props.tickvalues.map(function(t){return new Date(s(t))})}var o={left:"axisLeft",right:"axisRight",top:"axisTop",bottom:"axisBottom"}[this.props.position];this.axis=d3[o](this.scale);var r=this;this.filter_ticks(this.axis.scale().domain()),"index"==this.props.tickformat_formatter?this.axis=this.axis.tickFormat(function(t,e){return r.props.filtered_tickformat[t]}):"percent"==this.props.tickformat_formatter?this.axis=this.axis.tickFormat(function(t,e){var i=t/r.props.tickformat.xmax*100,s=r.props.tickformat.decimals||0,o=d3.format("."+s+"f")(i);return o+r.props.tickformat.symbol}):"str_method"==this.props.tickformat_formatter?this.axis=this.axis.tickFormat(function(t,e){var i=d3.format(r.props.tickformat.format_string)(t);return r.props.tickformat.prefix+i+r.props.tickformat.suffix}):"fixed"==this.props.tickformat_formatter?this.axis=this.axis.tickFormat(function(t,e){return r.props.filtered_tickformat[e]}):this.tickFormat&&(this.axis=this.axis.tickFormat(this.tickFormat)),this.tickNr&&(this.axis=this.axis.ticks(this.tickNr)),this.axis=this.axis.tickValues(this.props.filtered_tickvalues),this.elem=this.ax.baseaxes.append("g").attr("transform",this.transform).attr("class",this.cssclass).call(this.axis),this.wrapTicks(),mpld3.insert_css("div#"+this.ax.fig.figid+" ."+this.cssclass+" line, ."+this.cssclass+" path",{"shape-rendering":"crispEdges",stroke:this.props.axiscolor,fill:"none"}),mpld3.insert_css("div#"+this.ax.fig.figid+" ."+this.cssclass+" text",{"font-family":"sans-serif","font-size":this.props.fontsize+"px",fill:this.props.fontcolor,stroke:"none"})},mpld3_Axis.prototype.zoomed=function(t){this.filter_ticks(this.axis.scale().domain()),this.axis=this.axis.tickValues(this.props.filtered_tickvalues),t?("x"==this.props.xy?this.elem.call(this.axis.scale(t.rescaleX(this.scale))):this.elem.call(this.axis.scale(t.rescaleY(this.scale))),this.wrapTicks()):this.elem.call(this.axis)},mpld3_Axis.prototype.setTicks=function(t,e){this.tickNr=t,this.tickFormat=e},mpld3_Axis.prototype.filter_ticks=function(t){if(this.props.tickvalues){const e=this,i=this.props.tickvalues.map(function(t,e){return e}).filter(function(i,s){const o=e.props.tickvalues[i];return o>=t[0]&&o<=t[1]});this.props.filtered_tickvalues=this.props.tickvalues.filter(function(t,e){return i.includes(e)}),this.props.tickformat?this.props.filtered_tickformat=this.props.tickformat.filter(function(t,e){return i.includes(e)}):this.props.filtered_tickformat=this.props.tickformat}else this.props.filtered_tickvalues=this.props.tickvalues,this.props.filtered_tickformat=this.props.tickformat},mpld3.Coordinates=mpld3_Coordinates,mpld3_Coordinates.prototype.xy=function(t,e,i){return e="undefined"==typeof e?0:e,i="undefined"==typeof i?1:i,[this.x(t[e]),this.y(t[i])]},mpld3_Coordinates.prototype.x_data=function(t){return this.ax.x(t)},mpld3_Coordinates.prototype.y_data=function(t){return this.ax.y(t)},mpld3_Coordinates.prototype.x_display=function(t){return t},mpld3_Coordinates.prototype.y_display=function(t){return t},mpld3_Coordinates.prototype.x_axes=function(t){return t*this.ax.width},mpld3_Coordinates.prototype.y_axes=function(t){return this.ax.height*(1-t)},mpld3_Coordinates.prototype.x_figure=function(t){return t*this.fig.width-this.ax.position[0]},mpld3_Coordinates.prototype.y_figure=function(t){return(1-t)*this.fig.height-this.ax.position[1]},mpld3.Path=mpld3_Path,mpld3_Path.prototype=Object.create(mpld3_PlotElement.prototype),mpld3_Path.prototype.constructor=mpld3_Path,mpld3_Path.prototype.requiredProps=["data"],mpld3_Path.prototype.defaultProps={xindex:0,yindex:1,coordinates:"data",facecolor:"green",edgecolor:"black",edgewidth:1,dasharray:"none",pathcodes:null,offset:null,offsetcoordinates:"data",alpha:1,drawstyle:"none",zorder:1},mpld3_Path.prototype.finiteFilter=function(t,e){return isFinite(this.pathcoords.x(t[this.props.xindex]))&&isFinite(this.pathcoords.y(t[this.props.yindex]))},mpld3_Path.prototype.draw=function(){if(this.datafunc.defined(this.finiteFilter.bind(this)).x(function(t){return this.pathcoords.x(t[this.props.xindex])}.bind(this)).y(function(t){return this.pathcoords.y(t[this.props.yindex])}.bind(this)),this.pathcoords.zoomable?this.path=this.ax.paths.append("svg:path"):this.path=this.ax.staticPaths.append("svg:path"),this.path=this.path.attr("d",this.datafunc(this.data,this.pathcodes)).attr("class","mpld3-path").style("stroke",this.props.edgecolor).style("stroke-width",this.props.edgewidth).style("stroke-dasharray",this.props.dasharray).style("stroke-opacity",this.props.alpha).style("fill",this.props.facecolor).style("fill-opacity",this.props.alpha).attr("vector-effect","non-scaling-stroke"),null!==this.props.offset){var t=this.offsetcoords.xy(this.props.offset);this.path.attr("transform","translate("+t+")")}},mpld3_Path.prototype.elements=function(t){return this.path},mpld3.PathCollection=mpld3_PathCollection,mpld3_PathCollection.prototype=Object.create(mpld3_PlotElement.prototype),mpld3_PathCollection.prototype.constructor=mpld3_PathCollection,mpld3_PathCollection.prototype.requiredProps=["paths","offsets"],mpld3_PathCollection.prototype.defaultProps={xindex:0,yindex:1,pathtransforms:[],pathcoordinates:"display",offsetcoordinates:"data",offsetorder:"before",edgecolors:["#000000"],drawstyle:"none",edgewidths:[1],facecolors:["#0000FF"],alphas:[1],zorder:2},mpld3_PathCollection.prototype.transformFunc=function(t,e){var i=this.props.pathtransforms,s=0==i.length?"":mpld3.getTransformation("matrix("+getMod(i,e)+")").toString(),o=null===t||"undefined"==typeof t?"translate(0, 0)":"translate("+this.offsetcoords.xy(t,this.props.xindex,this.props.yindex)+")";return"after"===this.props.offsetorder?s+o:o+s},mpld3_PathCollection.prototype.pathFunc=function(t,e){return mpld3_path().x(function(t){return this.pathcoords.x(t[0])}.bind(this)).y(function(t){return this.pathcoords.y(t[1])}.bind(this)).apply(this,getMod(this.props.paths,e))},mpld3_PathCollection.prototype.styleFunc=function(t,e){var i={stroke:getMod(this.props.edgecolors,e),"stroke-width":getMod(this.props.edgewidths,e),"stroke-opacity":getMod(this.props.alphas,e),fill:getMod(this.props.facecolors,e),"fill-opacity":getMod(this.props.alphas,e)},s="";for(var o in i)s+=o+":"+i[o]+";";return s},mpld3_PathCollection.prototype.allFinite=function(t){return t instanceof Array?t.length==t.filter(isFinite).length:!0},mpld3_PathCollection.prototype.draw=function(){this.offsetcoords.zoomable||this.pathcoords.zoomable?this.group=this.ax.paths.append("svg:g"):this.group=this.ax.staticPaths.append("svg:g"),this.pathsobj=this.group.selectAll("paths").data(this.offsets.filter(this.allFinite)).enter().append("svg:path").attr("d",this.pathFunc.bind(this)).attr("class","mpld3-path").attr("transform",this.transformFunc.bind(this)).attr("style",this.styleFunc.bind(this)).attr("vector-effect","non-scaling-stroke")},mpld3_PathCollection.prototype.elements=function(t){return this.group.selectAll("path")},mpld3.Line=mpld3_Line,mpld3_Line.prototype=Object.create(mpld3_Path.prototype),mpld3_Line.prototype.constructor=mpld3_Line,mpld3_Line.prototype.requiredProps=["data"],mpld3_Line.prototype.defaultProps={xindex:0,yindex:1,coordinates:"data",color:"salmon",linewidth:2,dasharray:"none",alpha:1,zorder:2,drawstyle:"none"},mpld3.Markers=mpld3_Markers,mpld3_Markers.prototype=Object.create(mpld3_PathCollection.prototype),mpld3_Markers.prototype.constructor=mpld3_Markers,mpld3_Markers.prototype.requiredProps=["data"],mpld3_Markers.prototype.defaultProps={xindex:0,yindex:1,coordinates:"data",facecolor:"salmon",edgecolor:"black",edgewidth:1,alpha:1,markersize:6,markername:"circle",drawstyle:"none",markerpath:null,zorder:3},mpld3_Markers.prototype.pathFunc=function(t,e){return this.marker},mpld3.Image=mpld3_Image,mpld3_Image.prototype=Object.create(mpld3_PlotElement.prototype),mpld3_Image.prototype.constructor=mpld3_Image,mpld3_Image.prototype.requiredProps=["data","extent"],mpld3_Image.prototype.defaultProps={alpha:1,coordinates:"data",drawstyle:"none",zorder:1},mpld3_Image.prototype.draw=function(){this.image=this.ax.paths.append("svg:image"),this.image=this.image.attr("class","mpld3-image").attr("xlink:href","data:image/png;base64,"+this.props.data).style("opacity",this.props.alpha).attr("preserveAspectRatio","none"),this.updateDimensions()},mpld3_Image.prototype.elements=function(t){return d3.select(this.image)},mpld3_Image.prototype.updateDimensions=function(){var t=this.props.extent;this.image.attr("x",this.coords.x(t[0])).attr("y",this.coords.y(t[3])).attr("width",this.coords.x(t[1])-this.coords.x(t[0])).attr("height",this.coords.y(t[2])-this.coords.y(t[3]))},mpld3.Text=mpld3_Text,mpld3_Text.prototype=Object.create(mpld3_PlotElement.prototype),mpld3_Text.prototype.constructor=mpld3_Text,mpld3_Text.prototype.requiredProps=["text","position"],mpld3_Text.prototype.defaultProps={coordinates:"data",h_anchor:"start",v_baseline:"auto",rotation:0,fontsize:11,drawstyle:"none",color:"black",alpha:1,zorder:3},mpld3_Text.prototype.draw=function(){"data"==this.props.coordinates?this.coords.zoomable?this.obj=this.ax.paths.append("text"):this.obj=this.ax.staticPaths.append("text"):this.obj=this.ax.baseaxes.append("text"),this.obj.attr("class","mpld3-text").text(this.text).style("text-anchor",this.props.h_anchor).style("dominant-baseline",this.props.v_baseline).style("font-size",this.props.fontsize).style("fill",this.props.color).style("opacity",this.props.alpha),this.applyTransform()},mpld3_Text.prototype.elements=function(t){return d3.select(this.obj)},mpld3_Text.prototype.applyTransform=function(){var t=this.coords.xy(this.position);this.obj.attr("x",t[0]).attr("y",t[1]),this.props.rotation&&this.obj.attr("transform","rotate("+this.props.rotation+","+t+")")},mpld3.Axes=mpld3_Axes,mpld3_Axes.prototype=Object.create(mpld3_PlotElement.prototype),mpld3_Axes.prototype.constructor=mpld3_Axes,mpld3_Axes.prototype.requiredProps=["xlim","ylim"],mpld3_Axes.prototype.defaultProps={bbox:[.1,.1,.8,.8],axesbg:"#FFFFFF",axesbgalpha:1,gridOn:!1,xdomain:null,ydomain:null,xscale:"linear",yscale:"linear",zoomable:!0,axes:[{position:"left"},{position:"bottom"}],lines:[],paths:[],markers:[],texts:[],collections:[],sharex:[],sharey:[],images:[]},mpld3_Axes.prototype.draw=function(){for(var t=0;t<this.props.sharex.length;t++)this.sharex.push(mpld3.get_element(this.props.sharex[t]));for(var t=0;t<this.props.sharey.length;t++)this.sharey.push(mpld3.get_element(this.props.sharey[t]));this.baseaxes=this.fig.canvas.append("g").attr("transform","translate("+this.position[0]+","+this.position[1]+")").attr("width",this.width).attr("height",this.height).attr("class","mpld3-baseaxes"),this.axes=this.baseaxes.append("g").attr("class","mpld3-axes").style("pointer-events","visiblefill"),this.clip=this.axes.append("svg:clipPath").attr("id",this.clipid).append("svg:rect").attr("x",0).attr("y",0).attr("width",this.width).attr("height",this.height),this.axesbg=this.axes.append("svg:rect").attr("width",this.width).attr("height",this.height).attr("class","mpld3-axesbg").style("fill",this.props.axesbg).style("fill-opacity",this.props.axesbgalpha),this.pathsContainer=this.axes.append("g").attr("clip-path","url(#"+this.clipid+")").attr("x",0).attr("y",0).attr("width",this.width).attr("height",this.height).attr("class","mpld3-paths-container"),this.paths=this.pathsContainer.append("g").attr("class","mpld3-paths"),this.staticPaths=this.axes.append("g").attr("class","mpld3-staticpaths"),this.brush=d3.brush().extent([[0,0],[this.fig.width,this.fig.height]]).on("start",this.brushStart.bind(this)).on("brush",this.brushMove.bind(this)).on("end",this.brushEnd.bind(this)).on("start.nokey",function(){d3.select(window).on("keydown.brush keyup.brush",null)});for(var t=0;t<this.elements.length;t++)this.elements[t].draw()},mpld3_Axes.prototype.bindZoom=function(){this.zoom||(this.zoom=d3.zoom(),this.zoom.on("zoom",this.zoomed.bind(this)),this.axes.call(this.zoom))},mpld3_Axes.prototype.unbindZoom=function(){this.zoom&&(this.zoom.on("zoom",null),this.axes.on(".zoom",null),this.zoom=null)},mpld3_Axes.prototype.bindBrush=function(){this.brushG||(this.brushG=this.axes.append("g").attr("class","mpld3-brush").call(this.brush))},mpld3_Axes.prototype.unbindBrush=function(){this.brushG&&(this.brushG.remove(),this.brushG.on(".brush",null),this.brushG=null)},mpld3_Axes.prototype.reset=function(){this.zoom?this.doZoom(!1,d3.zoomIdentity,750):(this.bindZoom(),this.doZoom(!1,d3.zoomIdentity,750,function(){this.isSomeTypeOfZoomEnabled||this.unbindZoom()}.bind(this)))},mpld3_Axes.prototype.enableOrDisableBrushing=function(){this.isBoxzoomEnabled||this.isLinkedBrushEnabled?this.bindBrush():this.unbindBrush()},mpld3_Axes.prototype.isSomeTypeOfZoomEnabled=function(){return this.isZoomEnabled||this.isBoxzoomEnabled},mpld3_Axes.prototype.enableOrDisableZooming=function(){this.isSomeTypeOfZoomEnabled()?this.bindZoom():this.unbindZoom()},mpld3_Axes.prototype.enableLinkedBrush=function(){this.isLinkedBrushEnabled=!0,this.enableOrDisableBrushing()},mpld3_Axes.prototype.disableLinkedBrush=function(){this.isLinkedBrushEnabled=!1,this.enableOrDisableBrushing()},mpld3_Axes.prototype.enableBoxzoom=function(){this.isBoxzoomEnabled=!0,
|
|
2
|
+
this.enableOrDisableBrushing(),this.enableOrDisableZooming()},mpld3_Axes.prototype.disableBoxzoom=function(){this.isBoxzoomEnabled=!1,this.enableOrDisableBrushing(),this.enableOrDisableZooming()},mpld3_Axes.prototype.enableZoom=function(){this.isZoomEnabled=!0,this.enableOrDisableZooming(),this.axes.style("cursor","move")},mpld3_Axes.prototype.disableZoom=function(){this.isZoomEnabled=!1,this.enableOrDisableZooming(),this.axes.style("cursor",null)},mpld3_Axes.prototype.doZoom=function(t,e,i,s){if(this.props.zoomable&&this.zoom){if(i){var o=this.axes.transition().duration(i).call(this.zoom.transform,e);s&&o.on("end",s)}else this.axes.call(this.zoom.transform,e);t?(this.lastTransform=e,this.sharex.forEach(function(t){t.doZoom(!1,e,i)}),this.sharey.forEach(function(t){t.doZoom(!1,e,i)})):this.lastTransform=e}},mpld3_Axes.prototype.zoomed=function(){var t=d3.event.sourceEvent&&"zoom"!=d3.event.sourceEvent.type;if(t)this.doZoom(!0,d3.event.transform,!1);else{var e=d3.event.transform;this.paths.attr("transform",e),this.elements.forEach(function(t){t.zoomed&&t.zoomed(e)}.bind(this))}},mpld3_Axes.prototype.resetBrush=function(){this.brushG.call(this.brush.move,null)},mpld3_Axes.prototype.doBoxzoom=function(t){if(t&&this.brushG){var e=t.map(this.lastTransform.invert,this.lastTransform),i=e[1][0]-e[0][0],s=e[1][1]-e[0][1],o=(e[0][0]+e[1][0])/2,r=(e[0][1]+e[1][1])/2,n=i>s?this.width/i:this.height/s,p=this.width/2-n*o,a=this.height/2-n*r,l=d3.zoomIdentity.translate(p,a).scale(n);this.doZoom(!0,l,750),this.resetBrush()}},mpld3_Axes.prototype.brushStart=function(){this.isLinkedBrushEnabled&&(this.isCurrentLinkedBrushTarget="MouseEvent"==d3.event.sourceEvent.constructor.name,this.isCurrentLinkedBrushTarget&&this.fig.resetBrushForOtherAxes(this.axid))},mpld3_Axes.prototype.brushMove=function(){var t=d3.event.selection;this.isLinkedBrushEnabled&&this.fig.updateLinkedBrush(t)},mpld3_Axes.prototype.brushEnd=function(){var t=d3.event.selection;this.isBoxzoomEnabled&&this.doBoxzoom(t),this.isLinkedBrushEnabled&&(t||this.fig.endLinkedBrush(),this.isCurrentLinkedBrushTarget=!1)},mpld3_Axes.prototype.setTicks=function(t,e,i){this.axisList.forEach(function(s){s.props.xy==t&&s.setTicks(e,i)})},mpld3.Toolbar=mpld3_Toolbar,mpld3_Toolbar.prototype=Object.create(mpld3_PlotElement.prototype),mpld3_Toolbar.prototype.constructor=mpld3_Toolbar,mpld3_Toolbar.prototype.defaultProps={buttons:["reset","move"]},mpld3_Toolbar.prototype.addButton=function(t){this.buttons.push(new t(this))},mpld3_Toolbar.prototype.draw=function(){function t(){this.buttonsobj.transition(750).attr("y",0)}function e(){this.buttonsobj.transition(750).delay(250).attr("y",16)}mpld3.insert_css("div#"+this.fig.figid+" .mpld3-toolbar image",{cursor:"pointer",opacity:.2,display:"inline-block",margin:"0px"}),mpld3.insert_css("div#"+this.fig.figid+" .mpld3-toolbar image.active",{opacity:.4}),mpld3.insert_css("div#"+this.fig.figid+" .mpld3-toolbar image.pressed",{opacity:.6}),this.fig.canvas.on("mouseenter",t.bind(this)).on("mouseleave",e.bind(this)).on("touchenter",t.bind(this)).on("touchstart",t.bind(this)),this.toolbar=this.fig.canvas.append("svg:svg").attr("width",16*this.buttons.length).attr("height",16).attr("x",2).attr("y",this.fig.height-16-2).attr("class","mpld3-toolbar"),this.buttonsobj=this.toolbar.append("svg:g").selectAll("buttons").data(this.buttons).enter().append("svg:image").attr("class",function(t){return t.cssclass}).attr("xlink:href",function(t){return t.icon()}).attr("width",16).attr("height",16).attr("x",function(t,e){return 16*e}).attr("y",16).on("click",function(t){t.click()}).on("mouseenter",function(){d3.select(this).classed("active",!0)}).on("mouseleave",function(){d3.select(this).classed("active",!1)});for(var i=0;i<this.buttons.length;i++)this.buttons[i].onDraw()},mpld3_Toolbar.prototype.deactivate_all=function(){this.buttons.forEach(function(t){t.deactivate()})},mpld3_Toolbar.prototype.deactivate_by_action=function(t){function e(e){return-1!==t.indexOf(e)}t.length>0&&this.buttons.forEach(function(t){t.actions.filter(e).length>0&&t.deactivate()})},mpld3.Button=mpld3_Button,mpld3_Button.prototype=Object.create(mpld3_PlotElement.prototype),mpld3_Button.prototype.constructor=mpld3_Button,mpld3_Button.prototype.setState=function(t){t?this.activate():this.deactivate()},mpld3_Button.prototype.click=function(){this.active?this.deactivate():this.activate()},mpld3_Button.prototype.activate=function(){this.toolbar.deactivate_by_action(this.actions),this.onActivate(),this.active=!0,this.toolbar.toolbar.select("."+this.cssclass).classed("pressed",!0),this.sticky||this.deactivate()},mpld3_Button.prototype.deactivate=function(){this.onDeactivate(),this.active=!1,this.toolbar.toolbar.select("."+this.cssclass).classed("pressed",!1)},mpld3_Button.prototype.sticky=!1,mpld3_Button.prototype.actions=[],mpld3_Button.prototype.icon=function(){return""},mpld3_Button.prototype.onActivate=function(){},mpld3_Button.prototype.onDeactivate=function(){},mpld3_Button.prototype.onDraw=function(){},mpld3.ButtonFactory=function(t){function e(t){mpld3_Button.call(this,t,this.buttonID)}if("string"!=typeof t.buttonID)throw"ButtonFactory: buttonID must be present and be a string";e.prototype=Object.create(mpld3_Button.prototype),e.prototype.constructor=e;for(var i in t)e.prototype[i]=t[i];return e},mpld3.Plugin=mpld3_Plugin,mpld3_Plugin.prototype=Object.create(mpld3_PlotElement.prototype),mpld3_Plugin.prototype.constructor=mpld3_Plugin,mpld3_Plugin.prototype.requiredProps=[],mpld3_Plugin.prototype.defaultProps={},mpld3_Plugin.prototype.draw=function(){},mpld3.ResetPlugin=mpld3_ResetPlugin,mpld3.register_plugin("reset",mpld3_ResetPlugin),mpld3_ResetPlugin.prototype=Object.create(mpld3_Plugin.prototype),mpld3_ResetPlugin.prototype.constructor=mpld3_ResetPlugin,mpld3_ResetPlugin.prototype.requiredProps=[],mpld3_ResetPlugin.prototype.defaultProps={},mpld3.ZoomPlugin=mpld3_ZoomPlugin,mpld3.register_plugin("zoom",mpld3_ZoomPlugin),mpld3_ZoomPlugin.prototype=Object.create(mpld3_Plugin.prototype),mpld3_ZoomPlugin.prototype.constructor=mpld3_ZoomPlugin,mpld3_ZoomPlugin.prototype.requiredProps=[],mpld3_ZoomPlugin.prototype.defaultProps={button:!0,enabled:null},mpld3_ZoomPlugin.prototype.activate=function(){this.fig.enableZoom()},mpld3_ZoomPlugin.prototype.deactivate=function(){this.fig.disableZoom()},mpld3_ZoomPlugin.prototype.draw=function(){this.props.enabled?this.activate():this.deactivate()},mpld3.BoxZoomPlugin=mpld3_BoxZoomPlugin,mpld3.register_plugin("boxzoom",mpld3_BoxZoomPlugin),mpld3_BoxZoomPlugin.prototype=Object.create(mpld3_Plugin.prototype),mpld3_BoxZoomPlugin.prototype.constructor=mpld3_BoxZoomPlugin,mpld3_BoxZoomPlugin.prototype.requiredProps=[],mpld3_BoxZoomPlugin.prototype.defaultProps={button:!0,enabled:null},mpld3_BoxZoomPlugin.prototype.activate=function(){this.fig.enableBoxzoom()},mpld3_BoxZoomPlugin.prototype.deactivate=function(){this.fig.disableBoxzoom()},mpld3_BoxZoomPlugin.prototype.draw=function(){this.props.enabled?this.activate():this.deactivate()},mpld3.TooltipPlugin=mpld3_TooltipPlugin,mpld3.register_plugin("tooltip",mpld3_TooltipPlugin),mpld3_TooltipPlugin.prototype=Object.create(mpld3_Plugin.prototype),mpld3_TooltipPlugin.prototype.constructor=mpld3_TooltipPlugin,mpld3_TooltipPlugin.prototype.requiredProps=["id"],mpld3_TooltipPlugin.prototype.defaultProps={labels:null,hoffset:0,voffset:10,location:"mouse"},mpld3_TooltipPlugin.prototype.draw=function(){function t(t,e){this.tooltip.style("visibility","visible").text(null===o?"("+t+")":getMod(o,e))}function e(t,e){if("mouse"===r){var i=d3.mouse(this.fig.canvas.node());this.x=i[0]+this.props.hoffset,this.y=i[1]-this.props.voffset}this.tooltip.attr("x",this.x).attr("y",this.y)}function i(t,e){this.tooltip.style("visibility","hidden")}var s=mpld3.get_element(this.props.id,this.fig),o=this.props.labels,r=this.props.location;this.tooltip=this.fig.canvas.append("text").attr("class","mpld3-tooltip-text").attr("x",0).attr("y",0).text("").style("visibility","hidden"),"bottom left"==r||"top left"==r?(this.x=s.ax.position[0]+5+this.props.hoffset,this.tooltip.style("text-anchor","beginning")):"bottom right"==r||"top right"==r?(this.x=s.ax.position[0]+s.ax.width-5+this.props.hoffset,this.tooltip.style("text-anchor","end")):this.tooltip.style("text-anchor","middle"),"bottom left"==r||"bottom right"==r?this.y=s.ax.position[1]+s.ax.height-5+this.props.voffset:("top left"==r||"top right"==r)&&(this.y=s.ax.position[1]+5+this.props.voffset),s.elements().on("mouseover",t.bind(this)).on("mousemove",e.bind(this)).on("mouseout",i.bind(this))},mpld3.LinkedBrushPlugin=mpld3_LinkedBrushPlugin,mpld3.register_plugin("linkedbrush",mpld3_LinkedBrushPlugin),mpld3_LinkedBrushPlugin.prototype=Object.create(mpld3.Plugin.prototype),mpld3_LinkedBrushPlugin.prototype.constructor=mpld3_LinkedBrushPlugin,mpld3_LinkedBrushPlugin.prototype.requiredProps=["id"],mpld3_LinkedBrushPlugin.prototype.defaultProps={button:!0,enabled:null},mpld3_LinkedBrushPlugin.prototype.activate=function(){this.fig.enableLinkedBrush()},mpld3_LinkedBrushPlugin.prototype.deactivate=function(){this.fig.disableLinkedBrush()},mpld3_LinkedBrushPlugin.prototype.isPathInSelection=function(t,e,i,s){var o=s[0][0]<t[e]&&s[1][0]>t[e]&&s[0][1]<t[i]&&s[1][1]>t[i];return o},mpld3_LinkedBrushPlugin.prototype.invertSelection=function(t,e){var i=[e.x.invert(t[0][0]),e.x.invert(t[1][0])],s=[e.y.invert(t[1][1]),e.y.invert(t[0][1])];return[[Math.min.apply(Math,i),Math.min.apply(Math,s)],[Math.max.apply(Math,i),Math.max.apply(Math,s)]]},mpld3_LinkedBrushPlugin.prototype.update=function(t){t&&this.pathCollectionsByAxes.forEach(function(e,i){var s=e[0],o=this.objectsByAxes[i],r=this.invertSelection(t,this.fig.axes[i]),n=s.props.xindex,p=s.props.yindex;o.selectAll("path").classed("mpld3-hidden",function(t,e){return!this.isPathInSelection(t,n,p,r)}.bind(this))}.bind(this))},mpld3_LinkedBrushPlugin.prototype.end=function(){this.allObjects.selectAll("path").classed("mpld3-hidden",!1)},mpld3_LinkedBrushPlugin.prototype.draw=function(){mpld3.insert_css("#"+this.fig.figid+" path.mpld3-hidden",{stroke:"#ccc !important",fill:"#ccc !important"});var t=mpld3.get_element(this.props.id);if(!t)throw new Error("[LinkedBrush] Could not find path collection");if(!("offsets"in t.props))throw new Error("[LinkedBrush] Figure is not a scatter plot.");this.objectClass="mpld3-brushtarget-"+t.props[this.dataKey],this.pathCollectionsByAxes=this.fig.axes.map(function(e){return e.elements.map(function(e){return e.props[this.dataKey]==t.props[this.dataKey]?(e.group.classed(this.objectClass,!0),e):void 0}.bind(this)).filter(function(t){return t})}.bind(this)),this.objectsByAxes=this.fig.axes.map(function(t){return t.axes.selectAll("."+this.objectClass)}.bind(this)),this.allObjects=this.fig.canvas.selectAll("."+this.objectClass)},mpld3.register_plugin("mouseposition",MousePositionPlugin),MousePositionPlugin.prototype=Object.create(mpld3.Plugin.prototype),MousePositionPlugin.prototype.constructor=MousePositionPlugin,MousePositionPlugin.prototype.requiredProps=[],MousePositionPlugin.prototype.defaultProps={fontsize:12,fmt:".3g"},MousePositionPlugin.prototype.draw=function(){for(var t=this.fig,e=d3.format(this.props.fmt),i=t.canvas.append("text").attr("class","mpld3-coordinates").style("text-anchor","end").style("font-size",this.props.fontsize).attr("x",this.fig.width-5).attr("y",this.fig.height-5),s=0;s<this.fig.axes.length;s++){var o=function(){var o=t.axes[s];return function(){var t=d3.mouse(this),s=o.x.invert(t[0]),r=o.y.invert(t[1]);i.text("("+e(s)+", "+e(r)+")")}}();t.axes[s].baseaxes.on("mousemove",o).on("mouseout",function(){i.text("")})}},mpld3.Figure=mpld3_Figure,mpld3_Figure.prototype=Object.create(mpld3_PlotElement.prototype),mpld3_Figure.prototype.constructor=mpld3_Figure,mpld3_Figure.prototype.requiredProps=["width","height"],mpld3_Figure.prototype.defaultProps={data:{},axes:[],plugins:[{type:"reset"},{type:"zoom"},{type:"boxzoom"}]},mpld3_Figure.prototype.addPlugin=function(t){if(!t.type)return console.warn("unspecified plugin type. Skipping this");var e;if(!(t.type in mpld3.plugin_map))return console.warn("Skipping unrecognized plugin: "+e);e=mpld3.plugin_map[t.type],(t.clear_toolbar||t.buttons)&&console.warn("DEPRECATION WARNING: You are using pluginInfo.clear_toolbar or pluginInfo, which have been deprecated. Please see the build-in plugins for the new method to add buttons, otherwise contact the mpld3 maintainers.");var i=mpld3_cloneObj(t);delete i.type;var s=new e(this,i);this.plugins.push(s),this.pluginsByType[t.type]=s},mpld3_Figure.prototype.draw=function(){mpld3.insert_css("div#"+this.figid,{"font-family":"Helvetica, sans-serif"}),this.canvas=this.root.append("svg:svg").attr("class","mpld3-figure").attr("width",this.width).attr("height",this.height);for(var t=0;t<this.axes.length;t++)this.axes[t].draw();this.disableZoom();for(var t=0;t<this.plugins.length;t++)this.plugins[t].draw();this.toolbar.draw()},mpld3_Figure.prototype.resetBrushForOtherAxes=function(t){this.axes.forEach(function(e){e.axid!=t&&e.resetBrush()})},mpld3_Figure.prototype.updateLinkedBrush=function(t){this.pluginsByType.linkedbrush&&this.pluginsByType.linkedbrush.update(t)},mpld3_Figure.prototype.endLinkedBrush=function(){this.pluginsByType.linkedbrush&&this.pluginsByType.linkedbrush.end()},mpld3_Figure.prototype.reset=function(t){this.axes.forEach(function(t){t.reset()})},mpld3_Figure.prototype.enableLinkedBrush=function(){this.axes.forEach(function(t){t.enableLinkedBrush()})},mpld3_Figure.prototype.disableLinkedBrush=function(){this.axes.forEach(function(t){t.disableLinkedBrush()})},mpld3_Figure.prototype.enableBoxzoom=function(){this.axes.forEach(function(t){t.enableBoxzoom()})},mpld3_Figure.prototype.disableBoxzoom=function(){this.axes.forEach(function(t){t.disableBoxzoom()})},mpld3_Figure.prototype.enableZoom=function(){this.axes.forEach(function(t){t.enableZoom()})},mpld3_Figure.prototype.disableZoom=function(){this.axes.forEach(function(t){t.disableZoom()})},mpld3_Figure.prototype.toggleZoom=function(){this.isZoomEnabled?this.disableZoom():this.enableZoom()},mpld3_Figure.prototype.setTicks=function(t,e,i){this.axes.forEach(function(s){s.setTicks(t,e,i)})},mpld3_Figure.prototype.setXTicks=function(t,e){this.setTicks("x",t,e)},mpld3_Figure.prototype.setYTicks=function(t,e){this.setTicks("y",t,e)},mpld3_Figure.prototype.removeNaN=function(t){output=output.map(function(t){return t.map(function(t){return"number"==typeof t&&isNaN(t)?0:t})})},mpld3_Figure.prototype.parse_offsets=function(t){return t.map(function(t){return t.map(function(t){return"number"==typeof t&&isNaN(t)?0:t})})},mpld3_Figure.prototype.get_data=function(t){var e=t;return null===t||"undefined"==typeof t?e=null:"string"==typeof t&&(e=this.data[t]),e},mpld3.PlotElement=mpld3_PlotElement,mpld3_PlotElement.prototype.requiredProps=[],mpld3_PlotElement.prototype.defaultProps={},mpld3_PlotElement.prototype.processProps=function(t){t=mpld3_cloneObj(t);var e={},i=this.name();this.requiredProps.forEach(function(s){if(!(s in t))throw"property '"+s+"' must be specified for "+i;e[s]=t[s],delete t[s]});for(var s in this.defaultProps)s in t?(e[s]=t[s],delete t[s]):e[s]=this.defaultProps[s];"id"in t?(e.id=t.id,delete t.id):"id"in e||(e.id=mpld3.generateId());for(var s in t)console.warn("Unrecognized property '"+s+"' for object "+this.name()+" (value = "+t[s]+").");return e},mpld3_PlotElement.prototype.name=function(){var t=/function (.{1,})\(/,e=t.exec(this.constructor.toString());return e&&e.length>1?e[1]:""},"object"==typeof module&&module.exports?module.exports=mpld3:this.mpld3=mpld3,console.log("Loaded mpld3 version "+mpld3.version);
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mpld3",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "http://github.com/mpld3/mpld3"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "npx browserify mpld3.v0.5.
|
|
10
|
+
"build": "npx browserify mpld3.v0.5.6.min.js --standalone mpld3 -o dist/mpld3.v0.5.6.min.js"
|
|
11
11
|
},
|
|
12
|
-
"main": "dist/mpld3.v0.5.
|
|
12
|
+
"main": "dist/mpld3.v0.5.6.min.js",
|
|
13
13
|
"bundleDependencies": false,
|
|
14
14
|
"dependencies": {},
|
|
15
15
|
"devDependencies": {
|
package/dist/mpld3.v0.5.2.min.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.mpld3 = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
|
2
|
-
!function(t){function s(t){var s={};for(var i in t)s[i]=t[i];return s}function i(t,s){t="undefined"!=typeof t?t:10,s="undefined"!=typeof s?s:"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";for(var i=s.charAt(Math.round(Math.random()*(s.length-11))),e=1;t>e;e++)i+=s.charAt(Math.round(Math.random()*(s.length-1)));return i}function e(s,i){var e=t.interpolate([s[0].valueOf(),s[1].valueOf()],[i[0].valueOf(),i[1].valueOf()]);return function(t){var s=e(t);return[new Date(s[0]),new Date(s[1])]}}function o(t){return"undefined"==typeof t}function r(t){return null==t||o(t)}function n(t,s){return t.length>0?t[s%t.length]:null}function a(t){function s(t,s){var n=function(t){return"function"==typeof t?t:function(){return t}},a=n(i),p=n(e),h=[],l=[],c=0,u=-1,d=0,f=!1;if(!s){s=["M"];for(var y=1;y<t.length;y++)s.push("L")}for(;++u<s.length;){for(d=c+r[s[u]],h=[];d>c;)o.call(this,t[c],c)?(h.push(a.call(this,t[c],c),p.call(this,t[c],c)),c++):(h=null,c=d);h?f&&h.length>0?(l.push("M",h[0],h[1]),f=!1):(l.push(s[u]),l=l.concat(h)):f=!0}return c!=t.length&&console.warn("Warning: not all vertices used in Path"),l.join(" ")}var i=function(t,s){return t[0]},e=function(t,s){return t[1]},o=function(t,s){return!0},r={M:1,m:1,L:1,l:1,Q:2,q:2,T:1,t:1,S:2,s:2,C:3,c:3,Z:0,z:0};return s.x=function(t){return arguments.length?(i=t,s):i},s.y=function(t){return arguments.length?(e=t,s):e},s.defined=function(t){return arguments.length?(o=t,s):o},s.call=s,s}function p(t){function s(t){return i.forEach(function(s){t=s(t)}),t}var i=Array.prototype.slice.call(arguments,0),e=i.length;return s.domain=function(t){return arguments.length?(i[0].domain(t),s):i[0].domain()},s.range=function(t){return arguments.length?(i[e-1].range(t),s):i[e-1].range()},s.step=function(t){return i[t]},s}function h(t,s){if(_.call(this,t,s),this.cssclass="mpld3-"+this.props.xy+"grid","x"==this.props.xy)this.transform="translate(0,"+this.ax.height+")",this.position="bottom",this.scale=this.ax.xdom,this.tickSize=-this.ax.height;else{if("y"!=this.props.xy)throw"unrecognized grid xy specifier: should be 'x' or 'y'";this.transform="translate(0,0)",this.position="left",this.scale=this.ax.ydom,this.tickSize=-this.ax.width}}function l(t,s){_.call(this,t,s);var i={bottom:[0,this.ax.height],top:[0,0],left:[0,0],right:[this.ax.width,0]},e={bottom:"x",top:"x",left:"y",right:"y"};this.ax=t,this.transform="translate("+i[this.props.position]+")",this.props.xy=e[this.props.position],this.cssclass="mpld3-"+this.props.xy+"axis",this.scale=this.ax[this.props.xy+"dom"],this.tickNr=null,this.tickFormat=null}function c(t,s){if(this.trans=t,"undefined"==typeof s){if(this.ax=null,this.fig=null,"display"!==this.trans)throw"ax must be defined if transform != 'display'"}else this.ax=s,this.fig=s.fig;if(this.zoomable="data"===this.trans,this.x=this["x_"+this.trans],this.y=this["y_"+this.trans],"undefined"==typeof this.x||"undefined"==typeof this.y)throw"unrecognized coordinate code: "+this.trans}function u(t,s){_.call(this,t,s),this.data=t.fig.get_data(this.props.data),this.pathcodes=this.props.pathcodes,this.pathcoords=new c(this.props.coordinates,this.ax),this.offsetcoords=new c(this.props.offsetcoordinates,this.ax),this.datafunc=a()}function d(t,s){_.call(this,t,s),(null==this.props.facecolors||0==this.props.facecolors.length)&&(this.props.facecolors=["none"]),(null==this.props.edgecolors||0==this.props.edgecolors.length)&&(this.props.edgecolors=["none"]);var i=this.ax.fig.get_data(this.props.offsets);(null===i||0===i.length)&&(i=[null]);var e=Math.max(this.props.paths.length,i.length);if(i.length===e)this.offsets=i;else{this.offsets=[];for(var o=0;e>o;o++)this.offsets.push(n(i,o))}this.pathcoords=new c(this.props.pathcoordinates,this.ax),this.offsetcoords=new c(this.props.offsetcoordinates,this.ax)}function f(s,i){_.call(this,s,i);var e=this.props;e.facecolor="none",e.edgecolor=e.color,delete e.color,e.edgewidth=e.linewidth,delete e.linewidth;const o=e.drawstyle;switch(delete e.drawstyle,this.defaultProps=u.prototype.defaultProps,u.call(this,s,e),o){case"steps":case"steps-pre":this.datafunc=t.line().curve(t.curveStepBefore);break;case"steps-post":this.datafunc=t.line().curve(t.curveStepAfter);break;case"steps-mid":this.datafunc=t.line().curve(t.curveStep);break;default:this.datafunc=t.line().curve(t.curveLinear)}}function y(s,i){_.call(this,s,i),null!==this.props.markerpath?this.marker=0==this.props.markerpath[0].length?null:F.path().call(this.props.markerpath[0],this.props.markerpath[1]):this.marker=null===this.props.markername?null:t.symbol(this.props.markername).size(Math.pow(this.props.markersize,2))();var e={paths:[this.props.markerpath],offsets:s.fig.parse_offsets(s.fig.get_data(this.props.data,!0)),xindex:this.props.xindex,yindex:this.props.yindex,offsetcoordinates:this.props.coordinates,edgecolors:[this.props.edgecolor],edgewidths:[this.props.edgewidth],facecolors:[this.props.facecolor],alphas:[this.props.alpha],zorder:this.props.zorder,id:this.props.id};this.requiredProps=d.prototype.requiredProps,this.defaultProps=d.prototype.defaultProps,d.call(this,s,e)}function m(t,s){_.call(this,t,s),this.coords=new c(this.props.coordinates,this.ax)}function g(t,s){_.call(this,t,s),this.text=this.props.text,this.position=this.props.position,this.coords=new c(this.props.coordinates,this.ax)}function x(s,i){function e(t){return new Date(t[0],t[1],t[2],t[3],t[4],t[5])}function o(t,s){return"date"!==t?s:[e(s[0]),e(s[1])]}function r(s,i,e){var o="date"===s?t.scaleTime():"log"===s?t.scaleLog():t.scaleLinear();return o.domain(i).range(e)}_.call(this,s,i),this.axnum=this.fig.axes.length,this.axid=this.fig.figid+"_ax"+(this.axnum+1),this.clipid=this.axid+"_clip",this.props.xdomain=this.props.xdomain||this.props.xlim,this.props.ydomain=this.props.ydomain||this.props.ylim,this.sharex=[],this.sharey=[],this.elements=[],this.axisList=[];var n=this.props.bbox;this.position=[n[0]*this.fig.width,(1-n[1]-n[3])*this.fig.height],this.width=n[2]*this.fig.width,this.height=n[3]*this.fig.height,this.isZoomEnabled=null,this.zoom=null,this.lastTransform=t.zoomIdentity,this.isBoxzoomEnabled=null,this.isLinkedBrushEnabled=null,this.isCurrentLinkedBrushTarget=!1,this.brushG=null,this.props.xdomain=o(this.props.xscale,this.props.xdomain),this.props.ydomain=o(this.props.yscale,this.props.ydomain),this.x=this.xdom=r(this.props.xscale,this.props.xdomain,[0,this.width]),this.y=this.ydom=r(this.props.yscale,this.props.ydomain,[this.height,0]),"date"===this.props.xscale&&(this.x=F.multiscale(t.scaleLinear().domain(this.props.xlim).range(this.props.xdomain.map(Number)),this.xdom)),"date"===this.props.yscale&&(this.y=F.multiscale(t.scaleLinear().domain(this.props.ylim).range(this.props.ydomain.map(Number)),this.ydom));for(var a=this.props.axes,p=0;p<a.length;p++){var h=new F.Axis(this,a[p]);this.axisList.push(h),this.elements.push(h),(this.props.gridOn||h.props.grid.gridOn)&&this.elements.push(h.getGrid())}for(var l=this.props.paths,p=0;p<l.length;p++)this.elements.push(new F.Path(this,l[p]));for(var c=this.props.lines,p=0;p<c.length;p++)this.elements.push(new F.Line(this,c[p]));for(var u=this.props.markers,p=0;p<u.length;p++)this.elements.push(new F.Markers(this,u[p]));for(var d=this.props.texts,p=0;p<d.length;p++)this.elements.push(new F.Text(this,d[p]));for(var f=this.props.collections,p=0;p<f.length;p++)this.elements.push(new F.PathCollection(this,f[p]));for(var y=this.props.images,p=0;p<y.length;p++)this.elements.push(new F.Image(this,y[p]));this.elements.sort(function(t,s){return t.props.zorder-s.props.zorder})}function b(t,s){_.call(this,t,s),this.buttons=[],this.props.buttons.forEach(this.addButton.bind(this))}function v(t,s){_.call(this,t),this.toolbar=t,this.fig=this.toolbar.fig,this.cssclass="mpld3-"+s+"button",this.active=!1}function A(t,s){_.call(this,t,s)}function k(t,s){A.call(this,t,s);var i=F.ButtonFactory({buttonID:"reset",sticky:!1,onActivate:function(){this.toolbar.fig.reset()},icon:function(){return F.icons.reset}});this.fig.buttons.push(i)}function w(t,s){A.call(this,t,s),null===this.props.enabled&&(this.props.enabled=!this.props.button);var i=this.props.enabled;if(this.props.button){var e=F.ButtonFactory({buttonID:"zoom",sticky:!0,actions:["scroll","drag"],onActivate:this.activate.bind(this),onDeactivate:this.deactivate.bind(this),onDraw:function(){this.setState(i)},icon:function(){return F.icons.move}});this.fig.buttons.push(e)}}function B(t,s){A.call(this,t,s),null===this.props.enabled&&(this.props.enabled=!this.props.button);var i=this.props.enabled;if(this.props.button){var e=F.ButtonFactory({buttonID:"boxzoom",sticky:!0,actions:["drag"],onActivate:this.activate.bind(this),onDeactivate:this.deactivate.bind(this),onDraw:function(){this.setState(i)},icon:function(){return F.icons.zoom}});this.fig.buttons.push(e)}this.extentClass="boxzoombrush"}function z(t,s){A.call(this,t,s)}function E(t,s){F.Plugin.call(this,t,s),null===this.props.enabled&&(this.props.enabled=!this.props.button);var i=this.props.enabled;if(this.props.button){var e=F.ButtonFactory({buttonID:"linkedbrush",sticky:!0,actions:["drag"],onActivate:this.activate.bind(this),onDeactivate:this.deactivate.bind(this),onDraw:function(){this.setState(i)},icon:function(){return F.icons.brush}});this.fig.buttons.push(e)}this.pathCollectionsByAxes=[],this.objectsByAxes=[],this.allObjects=[],this.extentClass="linkedbrush",this.dataKey="offsets",this.objectClass=null}function P(t,s){F.Plugin.call(this,t,s)}function O(s,i){_.call(this,null,i),this.figid=s,this.width=this.props.width,this.height=this.props.height,this.data=this.props.data,this.buttons=[],this.root=t.select("#"+s).append("div").style("position","relative"),this.axes=[];for(var e=0;e<this.props.axes.length;e++)this.axes.push(new x(this,this.props.axes[e]));this.plugins=[],this.pluginsByType={},this.props.plugins.forEach(function(t){this.addPlugin(t)}.bind(this)),this.toolbar=new F.Toolbar(this,{buttons:this.buttons})}function _(t,s){this.parent=r(t)?null:t,this.props=r(s)?{}:this.processProps(s),this.fig=t instanceof O?t:t&&"fig"in t?t.fig:null,this.ax=t instanceof x?t:t&&"ax"in t?t.ax:null}var F={_mpld3IsLoaded:!0,figures:[],plugin_map:{}};F.version="0.5.2",F.register_plugin=function(t,s){F.plugin_map[t]=s},F.remove_figure=function(t){var s=document.getElementById(t);null!==s&&(s.innerHTML="");for(var i=0;i<F.figures.length;i++){var e=F.figures[i];e.figid===t&&F.figures.splice(i,1)}return!0},F.draw_figure=function(t,s,i,e){var o=document.getElementById(t);if(e="undefined"!=typeof e?e:!1,e&&F.remove_figure(t),null===o)throw t+" is not a valid id";var r=new F.Figure(t,s);return i&&i(r,o),F.figures.push(r),r.draw(),r},F.cloneObj=s,F.boundsToTransform=function(t,s){var i=t.width,e=t.height,o=s[1][0]-s[0][0],r=s[1][1]-s[0][1],n=(s[0][0]+s[1][0])/2,a=(s[0][1]+s[1][1])/2,p=Math.max(1,Math.min(8,.9/Math.max(o/i,r/e))),h=[i/2-p*n,e/2-p*a];return{translate:h,scale:p}},F.getTransformation=function(t){var s=document.createElementNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"transform",t);var i,e,o,r=s.transform.baseVal.consolidate().matrix,n=r.a,a=r.b,p=r.c,h=r.d,l=r.e,c=r.f;(i=Math.sqrt(n*n+a*a))&&(n/=i,a/=i),(o=n*p+a*h)&&(p-=n*o,h-=a*o),(e=Math.sqrt(p*p+h*h))&&(p/=e,h/=e,o/=e),a*p>n*h&&(n=-n,a=-a,o=-o,i=-i);var u={translateX:l,translateY:c,rotate:180*Math.atan2(a,n)/Math.PI,skewX:180*Math.atan(o)/Math.PI,scaleX:i,scaleY:e},d="translate("+u.translateX+","+u.translateY+")rotate("+u.rotate+")skewX("+u.skewX+")scale("+u.scaleX+","+u.scaleY+")";return d},F.merge_objects=function(t){for(var s,i={},e=0;e<arguments.length;e++){s=arguments[e];for(var o in s)i[o]=s[o]}return i},F.generate_id=function(t,s){return console.warn("mpld3.generate_id is deprecated. Use mpld3.generateId instead."),i(t,s)},F.generateId=i,F.get_element=function(t,s){var i,e,o;i="undefined"==typeof s?F.figures:"undefined"==typeof s.length?[s]:s;for(var r=0;r<i.length;r++){if(s=i[r],s.props.id===t)return s;for(var n=0;n<s.axes.length;n++){if(e=s.axes[n],e.props.id===t)return e;for(var a=0;a<e.elements.length;a++)if(o=e.elements[a],o.props.id===t)return o}}return null},F.insert_css=function(t,s){var i=document.head||document.getElementsByTagName("head")[0],e=document.createElement("style"),o=t+" {";for(var r in s)o+=r+":"+s[r]+"; ";o+="}",e.type="text/css",e.styleSheet?e.styleSheet.cssText=o:e.appendChild(document.createTextNode(o)),i.appendChild(e)},F.process_props=function(t,s,i,e){function o(t){_.call(this,null,t)}console.warn("mpld3.process_props is deprecated. Plot elements should derive from mpld3.PlotElement"),o.prototype=Object.create(_.prototype),o.prototype.constructor=o,o.prototype.requiredProps=e,o.prototype.defaultProps=i;var r=new o(s);return r.props},F.interpolateDates=e,F.path=function(){return a()},F.multiscale=p,F.icons={reset:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI\nWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gIcACMoD/OzIwAAAJhJREFUOMtjYKAx4KDUgNsMDAx7\nyNV8i4GB4T8U76VEM8mGYNNMtCH4NBM0hBjNMIwSsMzQ0MamcDkDA8NmQi6xggpUoikwQbIkHk2u\nE0rLI7vCBknBSyxeRDZAE6qHgQkq+ZeBgYERSfFPAoHNDNUDN4BswIRmKgxwEasP2dlsDAwMYlA/\n/mVgYHiBpkkGKscIDaPfVMmuAGnOTaGsXF0MAAAAAElFTkSuQmCC\n",move:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI\nWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gIcACQMfLHBNQAAANZJREFUOMud07FKA0EQBuAviaKB\nlFr7COJrpAyYRlKn8hECEkFEn8ROCCm0sBMRYgh5EgVFtEhsRjiO27vkBoZd/vn5d3b+XcrjFI9q\nxgXWkc8pUjOB93GMd3zgB9d1unjDSxmhWSHQqOJki+MtOuv/b3ZifUqctIrMxwhHuG1gim4Ma5kR\nWuEkXFgU4B0MW1Ho4TeyjX3s4TDq3zn8ALvZ7q5wX9DqLOHCDA95cFBAnOO1AL/ZdNopgY3fQcqF\nyriMe37hM9w521ZkkvlMo7o/8g7nZYQ/QDctp1nTCf0AAAAASUVORK5CYII=\n",zoom:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI\nWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gMPDiIRPL/2oQAAANBJREFUOMvF0b9KgzEcheHHVnCT\nKoI4uXbtLXgB3oJDJxevw1VwkoJ/NjepQ2/BrZRCx0ILFURQKV2kyOeSQpAmn7WDB0Lg955zEhLy\n2scdXlBggits+4WOQqjAJ3qYR7NGLrwXGU9+sGbEtlIF18FwmuBngZ+nCt6CIacC3Rx8LSl4xzgF\nn0tusBn4UyVhuA/7ZYIv5g+pE3ail25hN/qdmzCfpsJVjKKCZesDBwtzrAqGOMQj6vhCDRsY4ALH\nmOVObltR/xeG/jph6OD2r+Fv5lZBWEhMx58AAAAASUVORK5CYII=\n",brush:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI\nWXMAAEQkAABEJAFAZ8RUAAAAB3RJTUUH3gMCEiQKB9YaAgAAAWtJREFUOMuN0r1qVVEQhuFn700k\nnfEvBq0iNiIiOKXgH4KCaBeIhWARK/EibLwFCwVLjyAWaQzRGG9grC3URkHUBKKgRuWohWvL5pjj\nyTSLxcz7rZlZHyMiItqzFxGTEVF18/UoODNFxDIO4x12dkXqTcBPsCUzD+AK3ndFqhHwEsYz82gn\nN4dbmMRK9R/4KY7jAvbiWmYeHBT5Z4QCP8J1rGAeN3GvU3Mbl/Gq3qCDcxjLzOV+v78fq/iFIxFx\nPyJ2lNJpfBy2g59YzMyzEbEVLzGBJjOriLiBq5gaJrCIU3hcRCbwAtuwjm/Yg/V6I9NgDA1OR8RC\nZq6Vcd7iUwtn5h8fdMBdETGPE+Xe4ExELDRNs4bX2NfCUHe+7UExyfkCP8MhzOA7PuAkvrbwXyNF\nxF3MDqxiqlhXC7SPdaOKiN14g0u4g3H0MvOiTUSNY3iemb0ywmfMdfYyUmAJ2yPiBx6Wr/oy2Oqw\n+A1SupBzAOuE/AAAAABJRU5ErkJggg==\n"},F.Grid=h,h.prototype=Object.create(_.prototype),h.prototype.constructor=h,h.prototype.requiredProps=["xy"],h.prototype.defaultProps={color:"gray",dasharray:"2,2",alpha:"0.5",nticks:10,gridOn:!0,tickvalues:null,zorder:0},h.prototype.draw=function(){var s={left:"axisLeft",right:"axisRight",top:"axisTop",bottom:"axisBottom"}[this.position];this.grid=t[s](this.scale).ticks(this.props.nticks).tickValues(this.props.tickvalues).tickSize(this.tickSize,0,0).tickFormat(""),this.elem=this.ax.axes.append("g").attr("class",this.cssclass).attr("transform",this.transform).call(this.grid),F.insert_css("div#"+this.ax.fig.figid+" ."+this.cssclass+" .tick",{stroke:this.props.color,"stroke-dasharray":this.props.dasharray,"stroke-opacity":this.props.alpha}),F.insert_css("div#"+this.ax.fig.figid+" ."+this.cssclass+" path",{"stroke-width":0}),F.insert_css("div#"+this.ax.fig.figid+" ."+this.cssclass+" .domain",{"pointer-events":"none"})},h.prototype.zoomed=function(t){t?"x"==this.props.xy?this.elem.call(this.grid.scale(t.rescaleX(this.scale))):this.elem.call(this.grid.scale(t.rescaleY(this.scale))):this.elem.call(this.grid)},F.Axis=l,l.prototype=Object.create(_.prototype),l.prototype.constructor=l,l.prototype.requiredProps=["position"],l.prototype.defaultProps={nticks:10,tickvalues:null,tickformat:null,filtered_tickvalues:null,filtered_tickformat:null,tickformat_formatter:null,fontsize:"11px",fontcolor:"black",axiscolor:"black",scale:"linear",grid:{},zorder:0,visible:!0},l.prototype.getGrid=function(){var t={nticks:this.props.nticks,zorder:this.props.zorder,tickvalues:null,xy:this.props.xy};if(this.props.grid)for(var s in this.props.grid)t[s]=this.props.grid[s];return new h(this.ax,t)},l.prototype.wrapTicks=function(){function s(s,i,e){e=e||1.2,s.each(function(){for(var s,o=t.select(this),r=o.node().getBBox(),n=r.height,a=o.text().split(/\s+/).reverse(),p=[],h=0,l=o.attr("y"),c=n,u=o.text(null).append("tspan").attr("x",0).attr("y",l).attr("dy",c);s=a.pop();)p.push(s),u.text(p.join(" ")),u.node().getComputedTextLength()>i&&(p.pop(),u.text(p.join(" ")),p=[s],u=o.append("tspan").attr("x",0).attr("y",l).attr("dy",++h*(n*e)+c).text(s))})}var i=80;"x"==this.props.xy&&this.elem.selectAll("text").call(s,i)},l.prototype.draw=function(){var s="x"===this.props.xy?this.parent.props.xscale:this.parent.props.yscale;if("date"===s&&this.props.tickvalues){var i="x"===this.props.xy?this.parent.x.domain():this.parent.y.domain(),e="x"===this.props.xy?this.parent.xdom.domain():this.parent.ydom.domain(),o=t.scaleLinear().domain(i).range(e);this.props.tickvalues=this.props.tickvalues.map(function(t){return new Date(o(t))})}var r={left:"axisLeft",right:"axisRight",top:"axisTop",bottom:"axisBottom"}[this.props.position];this.axis=t[r](this.scale);var n=this;this.filter_ticks(this.axis.scale().domain()),"index"==this.props.tickformat_formatter?this.axis=this.axis.tickFormat(function(t,s){return n.props.filtered_tickformat[t]}):"percent"==this.props.tickformat_formatter?this.axis=this.axis.tickFormat(function(s,i){var e=s/n.props.tickformat.xmax*100,o=n.props.tickformat.decimals||0,r=t.format("."+o+"f")(e);return r+n.props.tickformat.symbol}):"str_method"==this.props.tickformat_formatter?this.axis=this.axis.tickFormat(function(s,i){var e=t.format(n.props.tickformat.format_string)(s);return n.props.tickformat.prefix+e+n.props.tickformat.suffix}):"fixed"==this.props.tickformat_formatter?this.axis=this.axis.tickFormat(function(t,s){return n.props.filtered_tickformat[s]}):this.tickFormat&&(this.axis=this.axis.tickFormat(this.tickFormat)),this.tickNr&&(this.axis=this.axis.ticks(this.tickNr)),this.axis=this.axis.tickValues(this.props.filtered_tickvalues),this.elem=this.ax.baseaxes.append("g").attr("transform",this.transform).attr("class",this.cssclass).call(this.axis),this.wrapTicks(),F.insert_css("div#"+this.ax.fig.figid+" ."+this.cssclass+" line, ."+this.cssclass+" path",{"shape-rendering":"crispEdges",stroke:this.props.axiscolor,fill:"none"}),F.insert_css("div#"+this.ax.fig.figid+" ."+this.cssclass+" text",{"font-family":"sans-serif","font-size":this.props.fontsize+"px",fill:this.props.fontcolor,stroke:"none"})},l.prototype.zoomed=function(t){this.filter_ticks(this.axis.scale().domain()),this.axis=this.axis.tickValues(this.props.filtered_tickvalues),t?("x"==this.props.xy?this.elem.call(this.axis.scale(t.rescaleX(this.scale))):this.elem.call(this.axis.scale(t.rescaleY(this.scale))),this.wrapTicks()):this.elem.call(this.axis)},l.prototype.setTicks=function(t,s){this.tickNr=t,this.tickFormat=s},l.prototype.filter_ticks=function(t){if(this.props.tickvalues){const s=this,i=this.props.tickvalues.map(function(t,s){return s}).filter(function(i,e){const o=s.props.tickvalues[i];return o>=t[0]&&o<=t[1]});this.props.filtered_tickvalues=this.props.tickvalues.filter(function(t,s){return i.includes(s)}),this.props.tickformat?this.props.filtered_tickformat=this.props.tickformat.filter(function(t,s){return i.includes(s)}):this.props.filtered_tickformat=this.props.tickformat}else this.props.filtered_tickvalues=this.props.tickvalues,this.props.filtered_tickformat=this.props.tickformat},F.Coordinates=c,c.prototype.xy=function(t,s,i){return s="undefined"==typeof s?0:s,i="undefined"==typeof i?1:i,[this.x(t[s]),this.y(t[i])]},c.prototype.x_data=function(t){return this.ax.x(t)},c.prototype.y_data=function(t){return this.ax.y(t)},c.prototype.x_display=function(t){return t},c.prototype.y_display=function(t){return t},c.prototype.x_axes=function(t){return t*this.ax.width},c.prototype.y_axes=function(t){return this.ax.height*(1-t)},c.prototype.x_figure=function(t){return t*this.fig.width-this.ax.position[0]},c.prototype.y_figure=function(t){return(1-t)*this.fig.height-this.ax.position[1]},F.Path=u,u.prototype=Object.create(_.prototype),u.prototype.constructor=u,u.prototype.requiredProps=["data"],u.prototype.defaultProps={xindex:0,yindex:1,coordinates:"data",facecolor:"green",edgecolor:"black",edgewidth:1,dasharray:"none",pathcodes:null,offset:null,offsetcoordinates:"data",alpha:1,drawstyle:"none",zorder:1},u.prototype.finiteFilter=function(t,s){return isFinite(this.pathcoords.x(t[this.props.xindex]))&&isFinite(this.pathcoords.y(t[this.props.yindex]))},u.prototype.draw=function(){if(this.datafunc.defined(this.finiteFilter.bind(this)).x(function(t){return this.pathcoords.x(t[this.props.xindex])}.bind(this)).y(function(t){return this.pathcoords.y(t[this.props.yindex])}.bind(this)),this.pathcoords.zoomable?this.path=this.ax.paths.append("svg:path"):this.path=this.ax.staticPaths.append("svg:path"),this.path=this.path.attr("d",this.datafunc(this.data,this.pathcodes)).attr("class","mpld3-path").style("stroke",this.props.edgecolor).style("stroke-width",this.props.edgewidth).style("stroke-dasharray",this.props.dasharray).style("stroke-opacity",this.props.alpha).style("fill",this.props.facecolor).style("fill-opacity",this.props.alpha).attr("vector-effect","non-scaling-stroke"),null!==this.props.offset){var t=this.offsetcoords.xy(this.props.offset);this.path.attr("transform","translate("+t+")")}},u.prototype.elements=function(t){return this.path},F.PathCollection=d,d.prototype=Object.create(_.prototype),d.prototype.constructor=d,d.prototype.requiredProps=["paths","offsets"],d.prototype.defaultProps={xindex:0,yindex:1,pathtransforms:[],pathcoordinates:"display",offsetcoordinates:"data",offsetorder:"before",edgecolors:["#000000"],drawstyle:"none",edgewidths:[1],facecolors:["#0000FF"],alphas:[1],zorder:2},d.prototype.transformFunc=function(t,s){var i=this.props.pathtransforms,e=0==i.length?"":F.getTransformation("matrix("+n(i,s)+")").toString(),o=null===t||"undefined"==typeof t?"translate(0, 0)":"translate("+this.offsetcoords.xy(t,this.props.xindex,this.props.yindex)+")";return"after"===this.props.offsetorder?e+o:o+e},d.prototype.pathFunc=function(t,s){return a().x(function(t){return this.pathcoords.x(t[0])}.bind(this)).y(function(t){return this.pathcoords.y(t[1])}.bind(this)).apply(this,n(this.props.paths,s))},d.prototype.styleFunc=function(t,s){var i={stroke:n(this.props.edgecolors,s),"stroke-width":n(this.props.edgewidths,s),"stroke-opacity":n(this.props.alphas,s),fill:n(this.props.facecolors,s),"fill-opacity":n(this.props.alphas,s)},e="";for(var o in i)e+=o+":"+i[o]+";";return e},d.prototype.allFinite=function(t){return t instanceof Array?t.length==t.filter(isFinite).length:!0},d.prototype.draw=function(){this.offsetcoords.zoomable||this.pathcoords.zoomable?this.group=this.ax.paths.append("svg:g"):this.group=this.ax.staticPaths.append("svg:g"),this.pathsobj=this.group.selectAll("paths").data(this.offsets.filter(this.allFinite)).enter().append("svg:path").attr("d",this.pathFunc.bind(this)).attr("class","mpld3-path").attr("transform",this.transformFunc.bind(this)).attr("style",this.styleFunc.bind(this)).attr("vector-effect","non-scaling-stroke")},d.prototype.elements=function(t){return this.group.selectAll("path")},F.Line=f,f.prototype=Object.create(u.prototype),f.prototype.constructor=f,f.prototype.requiredProps=["data"],f.prototype.defaultProps={xindex:0,yindex:1,coordinates:"data",color:"salmon",linewidth:2,dasharray:"none",alpha:1,zorder:2,drawstyle:"none"},F.Markers=y,y.prototype=Object.create(d.prototype),y.prototype.constructor=y,y.prototype.requiredProps=["data"],y.prototype.defaultProps={xindex:0,yindex:1,coordinates:"data",facecolor:"salmon",edgecolor:"black",edgewidth:1,alpha:1,markersize:6,markername:"circle",drawstyle:"none",markerpath:null,zorder:3},y.prototype.pathFunc=function(t,s){return this.marker},F.Image=m,m.prototype=Object.create(_.prototype),m.prototype.constructor=m,m.prototype.requiredProps=["data","extent"],m.prototype.defaultProps={alpha:1,coordinates:"data",drawstyle:"none",zorder:1},m.prototype.draw=function(){this.image=this.ax.paths.append("svg:image"),this.image=this.image.attr("class","mpld3-image").attr("xlink:href","data:image/png;base64,"+this.props.data).style("opacity",this.props.alpha).attr("preserveAspectRatio","none"),this.updateDimensions()},m.prototype.elements=function(s){return t.select(this.image)},m.prototype.updateDimensions=function(){var t=this.props.extent;this.image.attr("x",this.coords.x(t[0])).attr("y",this.coords.y(t[3])).attr("width",this.coords.x(t[1])-this.coords.x(t[0])).attr("height",this.coords.y(t[2])-this.coords.y(t[3]))},F.Text=g,g.prototype=Object.create(_.prototype),g.prototype.constructor=g,g.prototype.requiredProps=["text","position"],g.prototype.defaultProps={coordinates:"data",h_anchor:"start",v_baseline:"auto",rotation:0,fontsize:11,drawstyle:"none",color:"black",alpha:1,zorder:3},g.prototype.draw=function(){"data"==this.props.coordinates?this.coords.zoomable?this.obj=this.ax.paths.append("text"):this.obj=this.ax.staticPaths.append("text"):this.obj=this.ax.baseaxes.append("text"),this.obj.attr("class","mpld3-text").text(this.text).style("text-anchor",this.props.h_anchor).style("dominant-baseline",this.props.v_baseline).style("font-size",this.props.fontsize).style("fill",this.props.color).style("opacity",this.props.alpha),this.applyTransform()},g.prototype.elements=function(s){return t.select(this.obj)},g.prototype.applyTransform=function(){var t=this.coords.xy(this.position);this.obj.attr("x",t[0]).attr("y",t[1]),this.props.rotation&&this.obj.attr("transform","rotate("+this.props.rotation+","+t+")")},F.Axes=x,x.prototype=Object.create(_.prototype),x.prototype.constructor=x,x.prototype.requiredProps=["xlim","ylim"],x.prototype.defaultProps={bbox:[.1,.1,.8,.8],axesbg:"#FFFFFF",axesbgalpha:1,gridOn:!1,xdomain:null,ydomain:null,xscale:"linear",yscale:"linear",zoomable:!0,axes:[{position:"left"},{position:"bottom"}],lines:[],paths:[],markers:[],texts:[],collections:[],sharex:[],sharey:[],images:[]},x.prototype.draw=function(){for(var s=0;s<this.props.sharex.length;s++)this.sharex.push(F.get_element(this.props.sharex[s]));for(var s=0;s<this.props.sharey.length;s++)this.sharey.push(F.get_element(this.props.sharey[s]));this.baseaxes=this.fig.canvas.append("g").attr("transform","translate("+this.position[0]+","+this.position[1]+")").attr("width",this.width).attr("height",this.height).attr("class","mpld3-baseaxes"),this.axes=this.baseaxes.append("g").attr("class","mpld3-axes").style("pointer-events","visiblefill"),this.clip=this.axes.append("svg:clipPath").attr("id",this.clipid).append("svg:rect").attr("x",0).attr("y",0).attr("width",this.width).attr("height",this.height),this.axesbg=this.axes.append("svg:rect").attr("width",this.width).attr("height",this.height).attr("class","mpld3-axesbg").style("fill",this.props.axesbg).style("fill-opacity",this.props.axesbgalpha),this.pathsContainer=this.axes.append("g").attr("clip-path","url(#"+this.clipid+")").attr("x",0).attr("y",0).attr("width",this.width).attr("height",this.height).attr("class","mpld3-paths-container"),this.paths=this.pathsContainer.append("g").attr("class","mpld3-paths"),this.staticPaths=this.axes.append("g").attr("class","mpld3-staticpaths"),this.brush=t.brush().extent([[0,0],[this.fig.width,this.fig.height]]).on("start",this.brushStart.bind(this)).on("brush",this.brushMove.bind(this)).on("end",this.brushEnd.bind(this)).on("start.nokey",function(){t.select(window).on("keydown.brush keyup.brush",null)});for(var s=0;s<this.elements.length;s++)this.elements[s].draw()},x.prototype.bindZoom=function(){this.zoom||(this.zoom=t.zoom(),this.zoom.on("zoom",this.zoomed.bind(this)),this.axes.call(this.zoom))},x.prototype.unbindZoom=function(){this.zoom&&(this.zoom.on("zoom",null),this.axes.on(".zoom",null),this.zoom=null)},x.prototype.bindBrush=function(){this.brushG||(this.brushG=this.axes.append("g").attr("class","mpld3-brush").call(this.brush))},x.prototype.unbindBrush=function(){this.brushG&&(this.brushG.remove(),this.brushG.on(".brush",null),this.brushG=null)},x.prototype.reset=function(){this.zoom?this.doZoom(!1,t.zoomIdentity,750):(this.bindZoom(),this.doZoom(!1,t.zoomIdentity,750,function(){this.isSomeTypeOfZoomEnabled||this.unbindZoom()}.bind(this)))},x.prototype.enableOrDisableBrushing=function(){this.isBoxzoomEnabled||this.isLinkedBrushEnabled?this.bindBrush():this.unbindBrush()},x.prototype.isSomeTypeOfZoomEnabled=function(){return this.isZoomEnabled||this.isBoxzoomEnabled},x.prototype.enableOrDisableZooming=function(){this.isSomeTypeOfZoomEnabled()?this.bindZoom():this.unbindZoom()},x.prototype.enableLinkedBrush=function(){this.isLinkedBrushEnabled=!0,this.enableOrDisableBrushing()},x.prototype.disableLinkedBrush=function(){this.isLinkedBrushEnabled=!1,this.enableOrDisableBrushing()},x.prototype.enableBoxzoom=function(){this.isBoxzoomEnabled=!0,this.enableOrDisableBrushing(),this.enableOrDisableZooming()},x.prototype.disableBoxzoom=function(){this.isBoxzoomEnabled=!1,this.enableOrDisableBrushing(),this.enableOrDisableZooming()},x.prototype.enableZoom=function(){this.isZoomEnabled=!0,this.enableOrDisableZooming(),this.axes.style("cursor","move")},x.prototype.disableZoom=function(){this.isZoomEnabled=!1,this.enableOrDisableZooming(),this.axes.style("cursor",null)},x.prototype.doZoom=function(t,s,i,e){if(this.props.zoomable&&this.zoom){if(i){var o=this.axes.transition().duration(i).call(this.zoom.transform,s);e&&o.on("end",e)}else this.axes.call(this.zoom.transform,s);t?(this.lastTransform=s,this.sharex.forEach(function(t){t.doZoom(!1,s,i)}),this.sharey.forEach(function(t){t.doZoom(!1,s,i)})):this.lastTransform=s}},x.prototype.zoomed=function(){var s=t.event.sourceEvent&&"zoom"!=t.event.sourceEvent.type;if(s)this.doZoom(!0,t.event.transform,!1);else{var i=t.event.transform;this.paths.attr("transform",i),this.elements.forEach(function(t){t.zoomed&&t.zoomed(i)}.bind(this))}},x.prototype.resetBrush=function(){this.brushG.call(this.brush.move,null)},x.prototype.doBoxzoom=function(s){if(s&&this.brushG){var i=s.map(this.lastTransform.invert,this.lastTransform),e=i[1][0]-i[0][0],o=i[1][1]-i[0][1],r=(i[0][0]+i[1][0])/2,n=(i[0][1]+i[1][1])/2,a=e>o?this.width/e:this.height/o,p=this.width/2-a*r,h=this.height/2-a*n,l=t.zoomIdentity.translate(p,h).scale(a);this.doZoom(!0,l,750),this.resetBrush()}},x.prototype.brushStart=function(){this.isLinkedBrushEnabled&&(this.isCurrentLinkedBrushTarget="MouseEvent"==t.event.sourceEvent.constructor.name,this.isCurrentLinkedBrushTarget&&this.fig.resetBrushForOtherAxes(this.axid))},x.prototype.brushMove=function(){var s=t.event.selection;this.isLinkedBrushEnabled&&this.fig.updateLinkedBrush(s)},x.prototype.brushEnd=function(){var s=t.event.selection;this.isBoxzoomEnabled&&this.doBoxzoom(s),this.isLinkedBrushEnabled&&(s||this.fig.endLinkedBrush(),this.isCurrentLinkedBrushTarget=!1)},x.prototype.setTicks=function(t,s,i){this.axisList.forEach(function(e){e.props.xy==t&&e.setTicks(s,i)})},F.Toolbar=b,b.prototype=Object.create(_.prototype),b.prototype.constructor=b,b.prototype.defaultProps={buttons:["reset","move"]},b.prototype.addButton=function(t){this.buttons.push(new t(this))},b.prototype.draw=function(){function s(){this.buttonsobj.transition(750).attr("y",0)}function i(){this.buttonsobj.transition(750).delay(250).attr("y",16)}F.insert_css("div#"+this.fig.figid+" .mpld3-toolbar image",{cursor:"pointer",opacity:.2,display:"inline-block",margin:"0px"}),F.insert_css("div#"+this.fig.figid+" .mpld3-toolbar image.active",{
|
|
3
|
-
opacity:.4}),F.insert_css("div#"+this.fig.figid+" .mpld3-toolbar image.pressed",{opacity:.6}),this.fig.canvas.on("mouseenter",s.bind(this)).on("mouseleave",i.bind(this)).on("touchenter",s.bind(this)).on("touchstart",s.bind(this)),this.toolbar=this.fig.canvas.append("svg:svg").attr("width",16*this.buttons.length).attr("height",16).attr("x",2).attr("y",this.fig.height-16-2).attr("class","mpld3-toolbar"),this.buttonsobj=this.toolbar.append("svg:g").selectAll("buttons").data(this.buttons).enter().append("svg:image").attr("class",function(t){return t.cssclass}).attr("xlink:href",function(t){return t.icon()}).attr("width",16).attr("height",16).attr("x",function(t,s){return 16*s}).attr("y",16).on("click",function(t){t.click()}).on("mouseenter",function(){t.select(this).classed("active",!0)}).on("mouseleave",function(){t.select(this).classed("active",!1)});for(var e=0;e<this.buttons.length;e++)this.buttons[e].onDraw()},b.prototype.deactivate_all=function(){this.buttons.forEach(function(t){t.deactivate()})},b.prototype.deactivate_by_action=function(t){function s(s){return-1!==t.indexOf(s)}t.length>0&&this.buttons.forEach(function(t){t.actions.filter(s).length>0&&t.deactivate()})},F.Button=v,v.prototype=Object.create(_.prototype),v.prototype.constructor=v,v.prototype.setState=function(t){t?this.activate():this.deactivate()},v.prototype.click=function(){this.active?this.deactivate():this.activate()},v.prototype.activate=function(){this.toolbar.deactivate_by_action(this.actions),this.onActivate(),this.active=!0,this.toolbar.toolbar.select("."+this.cssclass).classed("pressed",!0),this.sticky||this.deactivate()},v.prototype.deactivate=function(){this.onDeactivate(),this.active=!1,this.toolbar.toolbar.select("."+this.cssclass).classed("pressed",!1)},v.prototype.sticky=!1,v.prototype.actions=[],v.prototype.icon=function(){return""},v.prototype.onActivate=function(){},v.prototype.onDeactivate=function(){},v.prototype.onDraw=function(){},F.ButtonFactory=function(t){function s(t){v.call(this,t,this.buttonID)}if("string"!=typeof t.buttonID)throw"ButtonFactory: buttonID must be present and be a string";s.prototype=Object.create(v.prototype),s.prototype.constructor=s;for(var i in t)s.prototype[i]=t[i];return s},F.Plugin=A,A.prototype=Object.create(_.prototype),A.prototype.constructor=A,A.prototype.requiredProps=[],A.prototype.defaultProps={},A.prototype.draw=function(){},F.ResetPlugin=k,F.register_plugin("reset",k),k.prototype=Object.create(A.prototype),k.prototype.constructor=k,k.prototype.requiredProps=[],k.prototype.defaultProps={},F.ZoomPlugin=w,F.register_plugin("zoom",w),w.prototype=Object.create(A.prototype),w.prototype.constructor=w,w.prototype.requiredProps=[],w.prototype.defaultProps={button:!0,enabled:null},w.prototype.activate=function(){this.fig.enableZoom()},w.prototype.deactivate=function(){this.fig.disableZoom()},w.prototype.draw=function(){this.props.enabled?this.activate():this.deactivate()},F.BoxZoomPlugin=B,F.register_plugin("boxzoom",B),B.prototype=Object.create(A.prototype),B.prototype.constructor=B,B.prototype.requiredProps=[],B.prototype.defaultProps={button:!0,enabled:null},B.prototype.activate=function(){this.fig.enableBoxzoom()},B.prototype.deactivate=function(){this.fig.disableBoxzoom()},B.prototype.draw=function(){this.props.enabled?this.activate():this.deactivate()},F.TooltipPlugin=z,F.register_plugin("tooltip",z),z.prototype=Object.create(A.prototype),z.prototype.constructor=z,z.prototype.requiredProps=["id"],z.prototype.defaultProps={labels:null,hoffset:0,voffset:10,location:"mouse"},z.prototype.draw=function(){function s(t,s){this.tooltip.style("visibility","visible").text(null===r?"("+t+")":n(r,s))}function i(s,i){if("mouse"===a){var e=t.mouse(this.fig.canvas.node());this.x=e[0]+this.props.hoffset,this.y=e[1]-this.props.voffset}this.tooltip.attr("x",this.x).attr("y",this.y)}function e(t,s){this.tooltip.style("visibility","hidden")}var o=F.get_element(this.props.id,this.fig),r=this.props.labels,a=this.props.location;this.tooltip=this.fig.canvas.append("text").attr("class","mpld3-tooltip-text").attr("x",0).attr("y",0).text("").style("visibility","hidden"),"bottom left"==a||"top left"==a?(this.x=o.ax.position[0]+5+this.props.hoffset,this.tooltip.style("text-anchor","beginning")):"bottom right"==a||"top right"==a?(this.x=o.ax.position[0]+o.ax.width-5+this.props.hoffset,this.tooltip.style("text-anchor","end")):this.tooltip.style("text-anchor","middle"),"bottom left"==a||"bottom right"==a?this.y=o.ax.position[1]+o.ax.height-5+this.props.voffset:("top left"==a||"top right"==a)&&(this.y=o.ax.position[1]+5+this.props.voffset),o.elements().on("mouseover",s.bind(this)).on("mousemove",i.bind(this)).on("mouseout",e.bind(this))},F.LinkedBrushPlugin=E,F.register_plugin("linkedbrush",E),E.prototype=Object.create(F.Plugin.prototype),E.prototype.constructor=E,E.prototype.requiredProps=["id"],E.prototype.defaultProps={button:!0,enabled:null},E.prototype.activate=function(){this.fig.enableLinkedBrush()},E.prototype.deactivate=function(){this.fig.disableLinkedBrush()},E.prototype.isPathInSelection=function(t,s,i,e){var o=e[0][0]<t[s]&&e[1][0]>t[s]&&e[0][1]<t[i]&&e[1][1]>t[i];return o},E.prototype.invertSelection=function(t,s){var i=[s.x.invert(t[0][0]),s.x.invert(t[1][0])],e=[s.y.invert(t[1][1]),s.y.invert(t[0][1])];return[[Math.min.apply(Math,i),Math.min.apply(Math,e)],[Math.max.apply(Math,i),Math.max.apply(Math,e)]]},E.prototype.update=function(t){t&&this.pathCollectionsByAxes.forEach(function(s,i){var e=s[0],o=this.objectsByAxes[i],r=this.invertSelection(t,this.fig.axes[i]),n=e.props.xindex,a=e.props.yindex;o.selectAll("path").classed("mpld3-hidden",function(t,s){return!this.isPathInSelection(t,n,a,r)}.bind(this))}.bind(this))},E.prototype.end=function(){this.allObjects.selectAll("path").classed("mpld3-hidden",!1)},E.prototype.draw=function(){F.insert_css("#"+this.fig.figid+" path.mpld3-hidden",{stroke:"#ccc !important",fill:"#ccc !important"});var t=F.get_element(this.props.id);if(!t)throw new Error("[LinkedBrush] Could not find path collection");if(!("offsets"in t.props))throw new Error("[LinkedBrush] Figure is not a scatter plot.");this.objectClass="mpld3-brushtarget-"+t.props[this.dataKey],this.pathCollectionsByAxes=this.fig.axes.map(function(s){return s.elements.map(function(s){return s.props[this.dataKey]==t.props[this.dataKey]?(s.group.classed(this.objectClass,!0),s):void 0}.bind(this)).filter(function(t){return t})}.bind(this)),this.objectsByAxes=this.fig.axes.map(function(t){return t.axes.selectAll("."+this.objectClass)}.bind(this)),this.allObjects=this.fig.canvas.selectAll("."+this.objectClass)},F.register_plugin("mouseposition",P),P.prototype=Object.create(F.Plugin.prototype),P.prototype.constructor=P,P.prototype.requiredProps=[],P.prototype.defaultProps={fontsize:12,fmt:".3g"},P.prototype.draw=function(){for(var s=this.fig,i=t.format(this.props.fmt),e=s.canvas.append("text").attr("class","mpld3-coordinates").style("text-anchor","end").style("font-size",this.props.fontsize).attr("x",this.fig.width-5).attr("y",this.fig.height-5),o=0;o<this.fig.axes.length;o++){var r=function(){var r=s.axes[o];return function(){var s=t.mouse(this),o=r.x.invert(s[0]),n=r.y.invert(s[1]);e.text("("+i(o)+", "+i(n)+")")}}();s.axes[o].baseaxes.on("mousemove",r).on("mouseout",function(){e.text("")})}},F.Figure=O,O.prototype=Object.create(_.prototype),O.prototype.constructor=O,O.prototype.requiredProps=["width","height"],O.prototype.defaultProps={data:{},axes:[],plugins:[{type:"reset"},{type:"zoom"},{type:"boxzoom"}]},O.prototype.addPlugin=function(t){if(!t.type)return console.warn("unspecified plugin type. Skipping this");var i;if(!(t.type in F.plugin_map))return console.warn("Skipping unrecognized plugin: "+i);i=F.plugin_map[t.type],(t.clear_toolbar||t.buttons)&&console.warn("DEPRECATION WARNING: You are using pluginInfo.clear_toolbar or pluginInfo, which have been deprecated. Please see the build-in plugins for the new method to add buttons, otherwise contact the mpld3 maintainers.");var e=s(t);delete e.type;var o=new i(this,e);this.plugins.push(o),this.pluginsByType[t.type]=o},O.prototype.draw=function(){F.insert_css("div#"+this.figid,{"font-family":"Helvetica, sans-serif"}),this.canvas=this.root.append("svg:svg").attr("class","mpld3-figure").attr("width",this.width).attr("height",this.height);for(var t=0;t<this.axes.length;t++)this.axes[t].draw();this.disableZoom();for(var t=0;t<this.plugins.length;t++)this.plugins[t].draw();this.toolbar.draw()},O.prototype.resetBrushForOtherAxes=function(t){this.axes.forEach(function(s){s.axid!=t&&s.resetBrush()})},O.prototype.updateLinkedBrush=function(t){this.pluginsByType.linkedbrush&&this.pluginsByType.linkedbrush.update(t)},O.prototype.endLinkedBrush=function(){this.pluginsByType.linkedbrush&&this.pluginsByType.linkedbrush.end()},O.prototype.reset=function(t){this.axes.forEach(function(t){t.reset()})},O.prototype.enableLinkedBrush=function(){this.axes.forEach(function(t){t.enableLinkedBrush()})},O.prototype.disableLinkedBrush=function(){this.axes.forEach(function(t){t.disableLinkedBrush()})},O.prototype.enableBoxzoom=function(){this.axes.forEach(function(t){t.enableBoxzoom()})},O.prototype.disableBoxzoom=function(){this.axes.forEach(function(t){t.disableBoxzoom()})},O.prototype.enableZoom=function(){this.axes.forEach(function(t){t.enableZoom()})},O.prototype.disableZoom=function(){this.axes.forEach(function(t){t.disableZoom()})},O.prototype.toggleZoom=function(){this.isZoomEnabled?this.disableZoom():this.enableZoom()},O.prototype.setTicks=function(t,s,i){this.axes.forEach(function(e){e.setTicks(t,s,i)})},O.prototype.setXTicks=function(t,s){this.setTicks("x",t,s)},O.prototype.setYTicks=function(t,s){this.setTicks("y",t,s)},O.prototype.removeNaN=function(t){output=output.map(function(t){return t.map(function(t){return"number"==typeof t&&isNaN(t)?0:t})})},O.prototype.parse_offsets=function(t){return t.map(function(t){return t.map(function(t){return"number"==typeof t&&isNaN(t)?0:t})})},O.prototype.get_data=function(t){var s=t;return null===t||"undefined"==typeof t?s=null:"string"==typeof t&&(s=this.data[t]),s},F.PlotElement=_,_.prototype.requiredProps=[],_.prototype.defaultProps={},_.prototype.processProps=function(t){t=s(t);var i={},e=this.name();this.requiredProps.forEach(function(s){if(!(s in t))throw"property '"+s+"' must be specified for "+e;i[s]=t[s],delete t[s]});for(var o in this.defaultProps)o in t?(i[o]=t[o],delete t[o]):i[o]=this.defaultProps[o];"id"in t?(i.id=t.id,delete t.id):"id"in i||(i.id=F.generateId());for(var o in t)console.warn("Unrecognized property '"+o+"' for object "+this.name()+" (value = "+t[o]+").");return i},_.prototype.name=function(){var t=/function (.{1,})\(/,s=t.exec(this.constructor.toString());return s&&s.length>1?s[1]:""},"object"==typeof module&&module.exports?module.exports=F:this.mpld3=F,console.log("Loaded mpld3 version "+F.version)}(d3);
|
|
4
|
-
|
|
5
|
-
},{}]},{},[1])(1)
|
|
6
|
-
});
|