32 lines
35 KiB
JavaScript
32 lines
35 KiB
JavaScript
|
!function(){return function(e,o,t){if("undefined"==typeof Bokeh)throw new Error("Cannot find Bokeh. You have to load it prior to loading plugins.");var l=Bokeh._;for(var r in e)Bokeh.require.modules[r]=e[r];for(var s=0;s<t.length;s++){var n=Bokeh.require(t[s]);l.isObject(n.models)&&Bokeh.Models.register_locations(n.models),l.extend(Bokeh,l.omit(n,"models"))}}({api:[function(e,o,t){var l;l=e("underscore"),o.exports={LinAlg:e("./api/linalg"),Charts:e("./api/charts"),Plotting:e("./api/plotting"),Document:e("./document").Document,sprintf:e("sprintf")},l.extend(o.exports,e("./api/models"))},{"./api/charts":"api/charts","./api/linalg":"api/linalg","./api/models":"api/models","./api/plotting":"api/plotting","./document":"document",sprintf:"sprintf",underscore:"underscore"}],"api/charts":[function(e,o,t){var l,r,s,n,a,i,d,c,u,m,_,p,h,g;s=e("underscore"),l=e("jquery"),h=e("sprintf"),r=e("../document").Document,i=e("../embed"),u=e("./models"),_=e("../palettes/palettes"),g=function(e){return e.reduce(function(e){return function(e,o){return e+o}}(this),0)},a=function(e){var o;return o=[],e.reduce(function(e,t,l){return o[l]=e+t},0),o},m=function(e){return h("#%06x",e)},d=function(e){var o,t,l;return l=parseInt(e.substr(1,2),16),t=parseInt(e.substr(3,2),16),o=parseInt(e.substr(5,2),16),[l,t,o]},c=function(e){var o,t,l,r;return r=e[0],t=e[1],o=e[2],l=1-(.299*r+.587*t+.114*o)/255,l>=.6},p=function(e,o){var t,l,r,n,i,p,f,y,x,k,w,v,b,M,T,S,z,R,A,B,C,D,P,L,q,j,G,F,I,O,U,W,H,E,Z,Q,N,$,X,Y,K,V,J,ee,oe;for(null==o&&(o={}),z=[],J=[],M=S=0,L=Math.min(e.labels.length,e.values.length);0<=L?S<L:S>L;M=0<=L?++S:--S)e.values[M]>0&&(z.push(e.labels[M]),J.push(e.values[M]));return H=null!=(q=o.start_angle)?q:0,p=null!=(j=o.end_angle)?j:H+2*Math.PI,t=Math.abs(p-H),Y=function(e){return t*e},V=g(J),R=J.map(function(e){return e/V}),r=a(R),f=r.map(function(e){return H+Y(e)}),E=[H].concat(f.slice(0,-1)),w=s.zip(E,f).map(function(e){return function(e){var o,t;return t=e[0],o=e[1],(t+o)/2}}(this)),null==o.center?(n=0,i=0):s.isArray(o.center)?(n=o.center[0],i=o.center[1]):(n=o.center.x,i=o.center.y),T=null!=(G=o.inner_radius)?G:0,A=null!=(F=o.outer_radius)?F:1,B=s.isArray(o.palette)?o.palette:_[null!=(I=o.palette)?I:"Spectral11"].map(m),l=function(){var e,o,t;for(t=[],M=e=0,o=R.length;0<=o?e<o:e>o;M=0<=o?++e:--e)t.push(B[M%B.length]);return t}(),Q=l.map(function(e){return c(d(e))?"white":"black"}),X=function(e,o){return[e*Math.cos(o),e*Math.sin(o)]},v=(T+A)/2,O=s.unzip(w.map(function(e){return function(e){return X(v,e)}}(this))),N=O[0],$=O[1],N=N.map(function(e){return e+n}),$=$.map(function(e){return e+i}),Z=w.map(function(e){return e>=Math.PI/2&&e<=3*Math.PI/2?e+Math.PI:e}),W=new Bokeh.ColumnDataSource({data:{labels:z,values:J,percentages:R.map(function(e){return function(e){return h("%.2f%%",100*e)}}(this)),start_angles:E,end_angles:f,text_angles:Z,colors:l,text_colors:Q,text_cx:N,text_cy:$}}),y=new u.AnnularWedge({x:n,y:i,inner_radius:T,outer_radius:A,start_angle:{field:"start_angles"},end_angle:{field:"end_angles"},line_color:null,line_width:1,fill_color:{field:"colors"}}),k=new u.AnnularWedge({x:n,y:i,inner_radius:T,outer_radius:A,start_angle:{field:"start_angles"},end_angle:{field:"end_angles"},line_color:null,line_width:1,fill_color:{field:"colors"},fill_alpha:.8}),D=new u.GlyphRenderer({data_source:W,glyph:y,hover_glyph:k}),x=new u.Text({x:{field:"text_cx"},y:{field:"text_cy"},text:{field:null!=(U=o.slice_labels)?U:"labels"},angle:{field:"text_angles"},text_align:"center",text_baseline:"middle",text_color:{field:"text_colors"},text_font_size:"9pt"}),P=new u.GlyphRenderer({data_source:W,glyph:x}),ee=new u.DataRange1d({renderers:[D],range_padding:.2}),oe=new u.DataRange1d({renderers:[D],range_padding:.2}),C=new u.Plot({x_range:ee,y_range:oe}),null!=o.width&&(C.plot_width=o.width),null!=o.height&&(C.plot_height=o.height),C.add_renderers(D,P),K="<div>@labels</div><div><b>@values</b> (@percentages)</div>",b=new u.HoverTool({renderers:[D],tooltips:K}),C.add_tools(b),C},n=function(e,o){var t,l,r,n,a,i,d,c,p,h,g,f,y,x,k,w,v,b,M,T,S,z,R,A,B,C,D,P,L,q,j,G,F,I,
|
||
|
dimension:e,ticker:s.ticker}),this.add_layout(s,t),this.add_layout(a)},o.prototype._get_axis_class=function(e,o){return null==e?null:"linear"===e?g.LinearAxis:"log"===e?g.LogAxis:"datetime"===e?g.DatetimeAxis:"auto"===e?o instanceof g.FactorRange?g.CategoricalAxis:g.LinearAxis:void 0},o.prototype._get_num_minor_ticks=function(e,o){if(a.isNumber(o)){if(o<=1)throw new Error("num_minor_ticks must be > 1");return o}return null==o?0:"auto"===o?e===g.LogAxis?10:5:void 0},o.prototype._process_tools=function(e){var o,t;return a.isString(e)&&(e=e.split(/\s*,\s*/)),o=function(){var o,l,r;for(r=[],o=0,l=e.length;o<l;o++)t=e[o],a.isString(t)?r.push(c[t](this)):r.push(t);return r}.call(this)},o.prototype._update_legend=function(e,o){var t,l,r,s,n,i;for(l=a.clone(this._legend.legends),t=0,r=l.length;t<r;t++)if(n=l[t],s=n[0],i=n[1],s===e)return i.push(o),void(this._legend.legends=l);return l.push([e,[o]]),this._legend.legends=l},o}(g.Plot),p=function(e,o){return null==e&&(e={}),null==o&&(o={}),new n(e,o)},f=function(e,o){var t,n,i,d,c,u,m;if(u=a.isArray(e),i=new s,u)for(d=0,c=e.length;d<c;d++)t=e[d],i.add_root(t);else i.add_root(e);return n=l("<div class="+r+">"),l(null!=o?o:"body").append(n),m=_.add_document_standalone(i,n),u?m:m[e.id]},m=function(e,o,t){return y("#%02x%02x%02x",e,o,t)},h=function(e,o){var t,l,r,s,n,i,d,c,u,m,_,p,h,f,y,x,k,w,v;for(null==o&&(o={}),k=a.isUndefined(o.toolbar_location)?"above":o.toolbar_location,y=a.isUndefined(o.sizing_mode)?"fixed":o.sizing_mode,w="fixed"===o.sizing_mode?"scale_width":y,v=[],f=[],r=0,d=e.length;r<d;r++){for(_=e[r],h=[],p=[],s=0,c=_.length;s<c;s++){if(l=_[s],l instanceof g.Plot&&(h=h.concat(l.toolbar.tools),l.toolbar_location=null),null===l){for(n=0,u=_.length;n<u&&(m=_[n],!(m instanceof g.Plot));n++);l=new g.Spacer({width:m.plot_width,height:m.plot_height})}if(!(l instanceof g.LayoutDOM))throw new Error("only LayoutDOM items can be inserted into Grid");l.sizing_mode=y,p.push(l)}v=v.concat(h),_=new g.Row({children:p,sizing_mode:y}),f.push(_)}return t=new g.Column({children:f,sizing_mode:y}),i=function(){if(!k)return t;switch(x=new g.ToolbarBox({tools:v,sizing_mode:w,toolbar_location:k}),k){case"above":return new g.Column({children:[x,t],sizing_mode:y});case"below":return new g.Column({children:[t,x],sizing_mode:y});case"left":return new g.Row({children:[x,t],sizing_mode:y});case"right":return new g.Row({children:[t,x],sizing_mode:y})}}()},o.exports={Figure:n,figure:p,show:f,color:m,gridplot:h}},{"../document":"document","../embed":"embed","./models":"api/models",jquery:"jquery",sprintf:"sprintf",underscore:"underscore"}]},{},["api"])}();/*
|
||
|
Copyright (c) 2012, Continuum Analytics, Inc.
|
||
|
All rights reserved.
|
||
|
|
||
|
Redistribution and use in source and binary forms, with or without modification,
|
||
|
are permitted provided that the following conditions are met:
|
||
|
|
||
|
Redistributions of source code must retain the above copyright notice,
|
||
|
this list of conditions and the following disclaimer.
|
||
|
|
||
|
Redistributions in binary form must reproduce the above copyright notice,
|
||
|
this list of conditions and the following disclaimer in the documentation
|
||
|
and/or other materials provided with the distribution.
|
||
|
|
||
|
Neither the name of Continuum Analytics nor the names of any contributors
|
||
|
may be used to endorse or promote products derived from this software
|
||
|
without specific prior written permission.
|
||
|
|
||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||
|
THE POSSIBILITY OF SUCH DAMAGE.
|
||
|
*/
|