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.53 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.11_ES6
*/
zingchart.setModule("boxplot"),ZC.ZCBoxPlot={getDefaults:function(e,o){var t={};ZC._cp_(ZC.ZCBoxPlot.B8,t);var l=t.palette;ZC.ZCBoxPlot.O3[o]&&(ZC._cp_(ZC.ZCBoxPlot.O3[o],t),l=ZC.ZCBoxPlot.O3[o].palette);var i=l[e%l.length];return t.box[ZC._[61]]=i,t.outlier.marker[ZC._[61]]=i,t.level["line-color"]=i,t.connector["line-color"]=i,t},B8:{palette:["#89b92e","#0392bb","#cc3300","#da9b04","#6e4503","#1540a0"],box:{"background-color":"#fff","border-width":1,"border-color":"#89b92e","hover-state":{"background-color":"transparent"}},outlier:{marker:{"background-color":"#fff","border-width":1,"border-color":"#89b92e",size:6}},level:{"line-width":2,"line-style":"solid","line-color":"#89b92e"},connector:{"line-width":1,"line-style":"solid","line-color":"#89b92e"}},O3:{light:{palette:["#29A2CC","#7CA82B","#D31E1E","#EF8535","#A14BC9","#A05F18","#265E96","#6B7075"],box:{"background-color":"#29A2CC","border-width":1,"border-color":"#29A2CC","hover-state":{"background-color":"transparent"}},outlier:{marker:{"background-color":"#29A2CC","border-width":1,"border-color":"#fff",size:4}},level:{"line-width":2,"line-style":"solid","line-color":"#fff"},"line-median-level":{"line-color":"#ffffff","line-width":2},connector:{"line-width":1,"line-style":"solid","line-color":"#29A2CC"}},dark:{palette:["#29A2CC","#7CA82B","#D31E1E","#EF8535","#A14BC9","#A05F18","#265E96","#6B7075"],box:{"background-color":"#29A2CC","border-width":1,"border-color":"#29A2CC","hover-state":{"background-color":"transparent"}},outlier:{marker:{"background-color":"#29A2CC","border-width":1,"border-color":"#fff",size:4}},level:{"line-width":2,"line-style":"solid","line-color":"#221F1F"},"line-median-level":{"line-color":"#221F1F","line-width":2},connector:{"line-width":1,"line-style":"solid","line-color":"#29A2CC"}}}},zingchart.bind(null,"dataparse",function(e,o){for(var t=e.theme,l=0,i=o[ZC._[16]].length;l<i;l++)if(o[ZC._[16]][l].type&&("boxplot"===o[ZC._[16]][l].type||"hboxplot"===o[ZC._[16]][l].type)){var n=o[ZC._[16]][l].type;o[ZC._[16]][l]["plugin-type"]=n;var a=o[ZC._[16]][l];ZC._todash_(a);var r,p,d,c={};a.options&&(c=a.options[n]||a.options),ZC._todash_(c),a[ZC._[50]]=a[ZC._[50]]||{},a[ZC._[50]][ZC._[5]]=a[ZC._[50]][ZC._[5]]||[],a[ZC._[51]]=a[ZC._[51]]||{},a[ZC._[51]]["min-value"]=null!==ZC._n_(a[ZC._[51]]["min-value"])?a[ZC._[51]]["min-value"]:"auto",a[ZC._[11]]=a[ZC._[11]]||[],a[ZC._[11]][0]=a[ZC._[11]][0]||{},a[ZC._[11]][0][ZC._[5]]=a[ZC._[11]][0][ZC._[5]]||[],a.type="boxplot"===n?"mixed":"hmixed",a.plot=a.plot||{},a.plot.mode="normal",a.tooltip=a.tooltip||{},a.tooltip[ZC._[0]]=a.tooltip[ZC._[0]]||"#29A2CC";var h=a[ZC._[11]];ZC._todash_(h);var _=0,C="";for(r=0;r<h.length;r++)if(null===ZC._n_(h[r].type)||"boxplot"===h[r].type){var s=h[r]["data-box"]||[],x=h[r]["data-outlier"]||[],Z=h[r].options||{},b=ZC.ZCBoxPlot.getDefaults(_,t),g={id:"boxplot-bar-"+r,type:"boxplot"===n?"vbar":"hbar",mode:"normal",scales:h[r].scales,options:Z};for(C in ZC._cp_(b.box,g),ZC._cp_(h[r],g),h[r])0===C.indexOf("data-")&&"data-box"!==C&&"data-outlier"!==C&&(g[C]=h[r][C]);var u=[],v=[],f=[],y=[],m=[],A=[],w=[];for(p=0,d=s.length;p<d;p++){var B=p,k=0;6===s[p].length&&(B=s[p][0],k=1);var z=s[p][0+k],E=s[p][1+k],F=s[p][2+k],O=s[p][3+k],j=s[p][4+k];u.push([B,O-E,z-E,j-E,F-E]),v.push(E),f.push(z),y.push(j),m.push(F),w.push(E),A.push(O)}g[ZC._[5]]=u,g["extra-values"]=3,g["offset-values"]=v,g["data-min"]=f,g["data-max"]=y,g["data-median"]=m,g["data-lower-quartile"]=w,g["data-upper-quartile"]=A,ZC._cp_(c.box,g),ZC._cp_(Z.box,g);var K={id:"boxplot-scatter"+r,type:"boxplot"===n?"scatter":"hscatter",mode:"normal",scales:h[r].scales,options:Z,values:x};for(C in ZC._cp_(b.outlier,K),ZC._cp_(c.outlier,K),ZC._cp_(Z.outlier,K),h[r])0===C.indexOf("data-")&&"data-box"!==C&&"data-outlier"!==C&&(K[C]=h[r][C]);h.push(g),x.length&&h.push(K),_++}for(r=h.length-1;r>=0;r--)null!==ZC._n_(h[r].type)&&"boxplot"!==h[r].type||h.splice(r,1)}return o}),zingchart.bind(null,"legend_item_click",function(e){var o,t,l=zingchart.getLoader(e.id),i=zingchart.getGraph(l,e.graphid).o;if(i["plugin-type"]=i["plugin-type"]||"","boxplot"===i["plugin-type"]||"hboxplot"===i["plugin-type"]){var n=zingchart.exec(e.id,"getobjectsbyclass",{type:"shape",graphid:e.graphid,cls:"boxplot-line-"+e.plotindex});for(o=0,t=n.length;o<t;o++)zingchart.exec(e.id,"updateobject",{type:"shape",graphid:e.graphid,id:n[o],data:{alpha:e.visible?0:1}})}}),zingchart.bind(null,"objectsinit",function(e){var o,t=zingchart.getLoader(e.loader.id),l=zingchart.getGraph(t,e.graphid),i=l.o,n=t.LV;if(i["plugin-type"]=i["plugin-type"]||"","boxplot"===i["plugin-type"]||"hboxplot"===i["plugin-type"]){var a={};i.options&&(a=i.options[i["plugin-type"]]||i.options),ZC._todash_(a);var r=i.shapes||[];for(o=r.length-1;o>=0;o--)-1!==r[o]["class"].indexOf("boxplot-line-")&&r.splice(o,1);var p,d=[];for(o=0;o<l.AZ.A3.length;o++)-1!==l.AZ.A3[o].H9.indexOf("boxplot-bar")&&d.push(o);var c=i[ZC._[11]];ZC._todash_(c);for(var h=0,_=0;_<d.length;_++){p=d[_];var C=zingchart.exec(e.loader.id,"getobjectinfo",{object:"plot",graphid:l.L,plotindex:p}),s=l.BK(C.scales[1]),x=c[p].options||{},Z=ZC.ZCBoxPlot.getDefaults(h,n);for(o=0;o<l.AZ.A3[p].R.length;o++){var b,g,u,v,f,y,m=zingchart.exec(e.loader.id,"getobjectinfo",{object:"node",graphid:l.L,plotindex:p,nodeindex:o});if(m.onviewport){"boxplot"===i["plugin-type"]?(b=ZC._i_(s.AK(m.xdata.min)),g=ZC._i_(s.AK(m.xdata.median)),u=ZC._i_(s.AK(m.xdata.max))):(v=ZC._i_(s.AK(m.xdata.min)),f=ZC._i_(s.AK(m.xdata.median)),y=ZC._i_(s.AK(m.xdata.max)));var A={type:"line",id:"boxplot-line-max-connector-"+p+"-"+o,"class":"boxplot-line-"+p,flat:!1,points:"boxplot"===i["plugin-type"]?[[m.x+m.width/2,s.AW?m.y+m.height:m.y],[m.x+m.width/2,u]]:[[s.AW?m.x:m.x+m.width,m.y+m.height/2],[y,m.y+m.height/2]]};ZC._cp_(Z.connector,A),ZC._cp_(a["line-max-connector"],A),ZC._cp_(x["line-max-connector"],A),r.push(A);var w={type:"line",id:"boxplot-line-max-level-"+p+"-"+o,"class":"boxplot-line-"+p,flat:!1,points:"boxplot"===i["plugin-type"]?[[m.x+.25*m.width,u],[m.x+.75*m.width,u]]:[[y,m.y+.25*m.height],[y,m.y+.75*m.height]]};ZC._cp_(Z.level,w),ZC._cp_(a["line-max-level"],w),ZC._cp_(x["line-max-level"],w),r.push(w);var B={type:"line",id:"boxplot-line-min-connector-"+p+"-"+o,"class":"boxplot-line-"+p,flat:!1,points:"boxplot"===i["plugin-type"]?[[m.x+m.width/2,s.AW?m.y:m.y+m.height],[m.x+m.width/2,b]]:[[s.AW?m.x+m.width:m.x,m.y+m.height/2],[v,m.y+m.height/2]]};ZC._cp_(Z.connector,B),ZC._cp_(a["line-min-connector"],B),ZC._cp_(x["line-min-connector"],B),r.push(B);var k={type:"line",id:"boxplot-line-min-level-"+p+"-"+o,"class":"boxplot-line-"+p,flat:!1,points:"boxplot"===i["plugin-type"]?[[m.x+.25*m.width,b],[m.x+.75*m.width,b]]:[[v,m.y+.25*m.height],[v,m.y+.75*m.height]]};ZC._cp_(Z.level,k),ZC._cp_(a["line-min-level"],k),ZC._cp_(x["line-min-level"],k),r.push(k);var z={type:"line",id:"boxplot-line-median-level-"+p+"-"+o,"class":"boxplot-line-"+p,flat:!1,points:"boxplot"===i["plugin-type"]?[[m.x,g],[m.x+m.width-.5,g]]:[[f,m.y],[f,m.y+m.height-.5]]};ZC._cp_(Z.level,z),ZC._cp_(Z["line-median-level"],z),ZC._cp_(a["line-median-level"],z),ZC._cp_(x["line-median-level"],z),r.push(z)}}h++}i.shapes=r}});