zingchart
Version:
Our JavaScript charting library is a commercial product. But the full branded version is free to try, forever.
8 lines (7 loc) • 7.25 kB
JavaScript
/*
All of the code within the ZingChart software is developed and copyrighted by ZingChart, Inc., and may not be copied,
replicated, or used in any other software or application without prior permission from ZingChart. All usage must coincide with the
ZingChart End User License Agreement which can be requested by email at support@zingchart.com.
Build 2.9.16-hf1_ES6
*/
zingchart.setModule("boxplot"),ZC.ZCBoxPlot={getDefaults:function(e,t,l){var i={},o=zingchart.getLoader(e);if(null===ZC._n_(o))return{};ZC._cp_({palette:o.B6.B6.palette||[]},i),ZC._cp_(ZC.ZCBoxPlot.B6,i),ZC.ZCBoxPlot.O5[l]&&ZC._cp_(ZC.ZCBoxPlot.O5[l],i);var n=i.palette[t%i.palette.length];return i.box[ZC._[0]]=n[1],i.box[ZC._[61]]=n[2],i.outlier.marker[ZC._[0]]=n[2],i.outlier.marker[ZC._[61]]=n[1],i.level["line-color"]=n[1],i["line-median-level"]["line-color"]=n[0],i.connector["line-color"]=n[1],ZC._cp_(o.B6.B6.boxplot,i),i},B6:{box:{"border-width":1,"hover-state":{visible:!1}},outlier:{marker:{"border-width":1,size:6}},level:{"line-width":2,"line-style":"solid"},"line-median-level":{"line-width":2},connector:{"line-width":1,"line-style":"solid"}},O5:{light:{box:{"border-width":1},outlier:{marker:{"border-width":1,size:4}},level:{"line-width":2,"line-style":"solid"},"line-median-level":{"line-width":2},connector:{"line-width":1,"line-style":"solid"}},dark:{box:{"border-width":1},outlier:{marker:{"border-width":1,size:4}},level:{"line-width":2,"line-style":"solid"},"line-median-level":{"line-width":2},connector:{"line-width":1,"line-style":"solid"}}}},zingchart.bind(null,"dataparse",function(e,t){for(var l=e.theme,i=e.id,o=0,n=t[ZC._[16]].length;o<n;o++)if(t[ZC._[16]][o].type&&("boxplot"===t[ZC._[16]][o].type||"hboxplot"===t[ZC._[16]][o].type)){var a=t[ZC._[16]][o].type;t[ZC._[16]][o]["plugin-type"]=a;var p=t[ZC._[16]][o];ZC._todash_(p);var r,d,_,h={};p.options&&(h=p.options[a]||p.options),ZC._todash_(h),p[ZC._[50]]=p[ZC._[50]]||{},p[ZC._[50]][ZC._[5]]=p[ZC._[50]][ZC._[5]]||[],p[ZC._[51]]=p[ZC._[51]]||{},p[ZC._[51]]["min-value"]=null!==ZC._n_(p[ZC._[51]]["min-value"])?p[ZC._[51]]["min-value"]:"auto",p[ZC._[11]]=p[ZC._[11]]||[],p[ZC._[11]][0]=p[ZC._[11]][0]||{},p[ZC._[11]][0][ZC._[5]]=p[ZC._[11]][0][ZC._[5]]||[],p.type="boxplot"===a?"mixed":"hmixed",p.plot=p.plot||{},p.plot.mode="normal",p.tooltip=p.tooltip||{};var c=p[ZC._[11]];ZC._todash_(c);var s=0,x="";for(r=0;r<c.length;r++)if(null===ZC._n_(c[r].type)||"boxplot"===c[r].type){var C=c[r]["data-box"]||[],Z=c[r]["data-outlier"]||[],b=c[r].options||{},u=ZC.ZCBoxPlot.getDefaults(i,s,l),g={id:"boxplot-bar-"+r,type:"boxplot"===a?"vbar":"hbar",mode:"normal",scales:c[r].scales,options:b,"tooltip-text":"Maximum:<b>%data-max</b><br>Upper Quartile:<b>%data-upper-quartile</b><br>Median:<b>%data-median</b><br>Lower Quartile:<b>%data-lower-quartile</b><br>Minimum:<b>%data-min</b>"};for(x in ZC._cp_(u.box,g),ZC._cp_(c[r],g),c[r])0===x.indexOf("data-")&&"data-box"!==x&&"data-outlier"!==x&&(g[x]=c[r][x]);var v=[],y=[],m=[],f=[],w=[],z=[],A=[];for(d=0,_=C.length;d<_;d++){var B=d,L=0;6===C[d].length&&(B=C[d][0],L=1);var O=C[d][0+L],j=C[d][1+L],k=C[d][2+L],P=C[d][3+L],q=C[d][4+L];v.push([B,P-j,O-j,q-j,k-j]),y.push(j),m.push(O),f.push(q),w.push(k),A.push(j),z.push(P)}g[ZC._[5]]=v,g["extra-values"]=3,g["offset-values"]=y,g["data-min"]=m,g["data-max"]=f,g["data-median"]=w,g["data-lower-quartile"]=A,g["data-upper-quartile"]=z,ZC._cp_(h.box,g),ZC._cp_(b.box,g);var D={id:"boxplot-scatter"+r,type:"boxplot"===a?"scatter":"hscatter",mode:"normal",scales:c[r].scales,options:b,text:"Outliers","tooltip-text":"Outlier:%node-value",values:Z};for(x in ZC._cp_(u.outlier,D),ZC._cp_(h.outlier,D),ZC._cp_(b.outlier,D),c[r])0===x.indexOf("data-")&&"data-box"!==x&&"data-outlier"!==x&&(D[x]=c[r][x]);c.push(g),Z.length&&c.push(D),s++}for(r=c.length-1;r>=0;r--)null!==ZC._n_(c[r].type)&&"boxplot"!==c[r].type||c.splice(r,1)}return t}),zingchart.bind(null,"legend_item_click",function(e){var t,l,i=zingchart.getLoader(e.id),o=zingchart.getGraph(i,e.graphid).o;if(o["plugin-type"]=o["plugin-type"]||"","boxplot"===o["plugin-type"]||"hboxplot"===o["plugin-type"]){var n=zingchart.exec(e.id,"getobjectsbyclass",{type:"shape",graphid:e.graphid,cls:"boxplot-line-"+e.plotindex});for(t=0,l=n.length;t<l;t++)zingchart.exec(e.id,"updateobject",{type:"shape",graphid:e.graphid,id:n[t],data:{alpha:e.visible?0:1}})}}),zingchart.bind(null,"objectsinit",function(e){var t,l=e.loader.id,i=zingchart.getLoader(l),o=zingchart.getGraph(i,e.graphid),n=o.o,a=i.LC;if(n["plugin-type"]=n["plugin-type"]||"","boxplot"===n["plugin-type"]||"hboxplot"===n["plugin-type"]){var p={};n.options&&(p=n.options[n["plugin-type"]]||n.options),ZC._todash_(p);var r=n.shapes||[];for(t=r.length-1;t>=0;t--)null!==ZC._n_(r[t]["class"])&&-1!==r[t]["class"].indexOf("boxplot-line-")&&r.splice(t,1);var d,_=[];for(t=0;t<o.AY.A3.length;t++)-1!==o.AY.A3[t].HD.indexOf("boxplot-bar")&&_.push(t);var h=n[ZC._[11]];ZC._todash_(h);for(var c=0,s=0;s<_.length;s++){d=_[s];var x=zingchart.exec(e.loader.id,"getobjectinfo",{object:"plot",graphid:o.L,plotindex:d}),C=o.BK(x.scales[1]),Z=h[d].options||{},b=ZC.ZCBoxPlot.getDefaults(l,c,a);for(t=0;t<o.AY.A3[d].R.length;t++){var u,g,v,y,m,f,w=zingchart.exec(e.loader.id,"getobjectinfo",{object:"node",graphid:o.L,plotindex:d,nodeindex:t});if(w.onviewport&&w.visible){"boxplot"===n["plugin-type"]?(u=ZC._i_(C.AL(w.xdata.min)),g=ZC._i_(C.AL(w.xdata.median)),v=ZC._i_(C.AL(w.xdata.max))):(y=ZC._i_(C.AL(w.xdata.min)),m=ZC._i_(C.AL(w.xdata.median)),f=ZC._i_(C.AL(w.xdata.max)));var z={type:"line",id:"boxplot-line-max-connector-"+d+"-"+t,"class":"boxplot-line-"+d,flat:!1,points:"boxplot"===n["plugin-type"]?[[w.x+w.width/2,C.AX?w.y+w.height:w.y],[w.x+w.width/2,v]]:[[C.AX?w.x:w.x+w.width,w.y+w.height/2],[f,w.y+w.height/2]]};ZC._cp_(b.connector,z),ZC._cp_(p.line,z),ZC._cp_(p["line-max-connector"],z),ZC._cp_(Z["line-max-connector"],z),r.push(z);var A={type:"line",id:"boxplot-line-max-level-"+d+"-"+t,"class":"boxplot-line-"+d,flat:!1,points:"boxplot"===n["plugin-type"]?[[w.x+.25*w.width,v],[w.x+.75*w.width,v]]:[[f,w.y+.25*w.height],[f,w.y+.75*w.height]]};ZC._cp_(b.level,A),ZC._cp_(p.line,A),ZC._cp_(p["line-max-level"],A),ZC._cp_(Z["line-max-level"],A),r.push(A);var B={type:"line",id:"boxplot-line-min-connector-"+d+"-"+t,"class":"boxplot-line-"+d,flat:!1,points:"boxplot"===n["plugin-type"]?[[w.x+w.width/2,C.AX?w.y:w.y+w.height],[w.x+w.width/2,u]]:[[C.AX?w.x+w.width:w.x,w.y+w.height/2],[y,w.y+w.height/2]]};ZC._cp_(b.connector,B),ZC._cp_(p.line,B),ZC._cp_(p["line-min-connector"],B),ZC._cp_(Z["line-min-connector"],B),r.push(B);var L={type:"line",id:"boxplot-line-min-level-"+d+"-"+t,"class":"boxplot-line-"+d,flat:!1,points:"boxplot"===n["plugin-type"]?[[w.x+.25*w.width,u],[w.x+.75*w.width,u]]:[[y,w.y+.25*w.height],[y,w.y+.75*w.height]]};ZC._cp_(b.level,L),ZC._cp_(p.line,L),ZC._cp_(p["line-min-level"],L),ZC._cp_(Z["line-min-level"],L),r.push(L);var O={type:"line",id:"boxplot-line-median-level-"+d+"-"+t,"class":"boxplot-line-"+d,flat:!1,points:"boxplot"===n["plugin-type"]?[[w.x,g],[w.x+w.width-.5,g]]:[[m,w.y],[m,w.y+w.height-.5]]};ZC._cp_(b.level,O),ZC._cp_(b["line-median-level"],O),ZC._cp_(p.line,O),ZC._cp_(p["line-median-level"],O),ZC._cp_(Z["line-median-level"],O),r.push(O)}}c++}n.shapes=r}});