UNPKG

zingchart

Version:

Our JavaScript charting library is a commercial product. But the full branded version is free to try, forever.

8 lines (7 loc) 5.68 kB
/* 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("svg-simple-selection"),function(){var t=[{zcattr:ZC._[0],svgattr:"fill",svgdefault:"none"},{zcattr:"alpha",svgattr:"fill-opacity",svgdefault:"1"},{zcattr:ZC._[61],svgattr:"stroke",svgdefault:"none"},{zcattr:ZC._[62],svgattr:"stroke-width",svgdefault:"0"}],e=ZC.CQ._append_;function a(e,a,r,i,n){var s;a["p"+r]=a["p"+r]||{},e.CC["p"+r]=e.CC["p"+r]||{},n?(a["p"+r]["n"+i]=!0,e.CC["p"+r]["n"+i]=!0):(delete a["p"+r]["n"+i],delete e.CC["p"+r]["n"+i]);var l="#"+e.K+ZC._[35]+r+"-node-"+i+"-path",o=ZC.A5(l),d="#"+e.K+ZC._[35]+r+"-node-"+i+"-preview-path",g=ZC.A5(d);if(n)for(s=0;s<t.length;s++)n[t[s].zcattr]&&(o.attr("data-"+t[s].svgattr,o.attr(t[s].svgattr)||t[s].svgdefault).attr(t[s].svgattr,n[t[s].zcattr]),g.length&&g.attr("data-"+t[s].svgattr,g.attr(t[s].svgattr)||t[s].svgdefault).attr(t[s].svgattr,n[t[s].zcattr]));else for(s=0;s<t.length;s++)o.attr("data-"+t[s].svgattr)&&(o.attr(t[s].svgattr,o.attr("data-"+t[s].svgattr)),g.length&&g.attr(t[s].svgattr,o.attr("data-"+t[s].svgattr)))}ZC.CQ._append_=function(a,r,i){var n=r.H,s=zingchart.getModules(n);if(-1!==ZC.AV(s,"svg-simple-selection")){if(-1!==i.id.indexOf(ZC._[35])){var l=i.id.split(ZC._[35])[0].replace(n.K+"-graph-",""),o=zingchart.getGraph(n,l),d=o.K;if(o&&("vbar"===o.AF||"hbar"===o.AF)&&ZC.SSS&&ZC.SSS[d]){var g=ZC.SSS[d].selection;for(var p in g){var c=p.replace("p","");if(ZC.SSS[d].defs["series-"+c])for(var S in g["p"+c]){var C=S.replace("n","");if(-1!==i.id.indexOf(ZC._[35]+c+"-node-"+C+"-path")||-1!==i.id.indexOf(ZC._[35]+c+"-node-"+C+"-preview-path")){var v=ZC.SSS[d].defs["series-"+c][ZC._[73]];if(v)for(var f=0;f<t.length;f++)v[t[f].zcattr]&&(i.setAttribute("data-"+t[f].svgattr,i.getAttribute(t[f].svgattr)||t[f].svgdefault),i.setAttribute(t[f].svgattr,v[t[f].zcattr]))}}}}}e(a,r,i)}else e(a,r,i)},zingchart.bind(null,"load",function(t){for(var e,r,i,n,s,l=zingchart.getLoader(t.id),o=zingchart.exec(t.id,"getgraphlength"),d=0;d<o;d++){var g=zingchart.getGraph(l,d);if(g){var p=g.K;if(ZC.SSS[p]&&ZC.SSS[p].selection)for(e in ZC.SSS[p].selection)if(i=parseInt(e.replace("p",""),10),ZC.SSS[p].defs["series-"+i])for(r in s=ZC.SSS[p].defs["series-"+i][ZC._[73]],ZC.SSS[p].selection[e])n=parseInt(r.replace("n",""),10),a(g,ZC.SSS[p].selection,i,n,s)}}}),zingchart.bind(null,"gcomplete",function(e){var a=zingchart.getLoader(e.id),r=zingchart.getGraph(a,e.graphid),i=zingchart.getModules(a);if(-1!==ZC.AV(i,"svg-simple-selection")&&("vbar"===r.AF||"hbar"===r.AF)){var n,s,l,o,d,g,p,c,S,C,v=r.K;if(JSON.stringify(r.CC)!==JSON.stringify(ZC.SSS[v].selection)){for(l in n=ZC.SSS[v].selection)for(o in n["p"+(d=l.replace("p",""))])for(g=o.replace("n",""),p="#"+r.K+ZC._[35]+d+"-node-"+g+"-path",c=ZC.A5(p),S="#"+r.K+ZC._[35]+d+"-node-"+g+"-preview-path",C=ZC.A5(S),s=0;s<t.length;s++)c.attr("data-"+t[s].svgattr)&&(c.attr(t[s].svgattr,c.attr("data-"+t[s].svgattr)),C.length&&C.attr(t[s].svgattr,c.attr("data-"+t[s].svgattr)));for(l in ZC.SSS[v].selection={},n=r.CC)for(o in n["p"+(d=l.replace("p",""))])if(g=o.replace("n",""),p="#"+r.K+ZC._[35]+d+"-node-"+g+"-path",c=ZC.A5(p),S="#"+r.K+ZC._[35]+d+"-node-"+g+"-preview-path",C=ZC.A5(S),ZC.SSS[v].defs["series-"+d]){var f=ZC.SSS[v].defs["series-"+d][ZC._[73]];for(s=0;s<t.length;s++)f[t[s].zcattr]&&(c.attr("data-"+t[s].svgattr,c.attr(t[s].svgattr)||t[s].svgdefault).attr(t[s].svgattr,f[t[s].zcattr]),C.length&&C.attr("data-"+t[s].svgattr,C.attr(t[s].svgattr)||t[s].svgdefault).attr(t[s].svgattr,f[t[s].zcattr]));ZC.SSS[v].selection[l]=ZC.SSS[v].selection[l]||{},ZC.SSS[v].selection[l][o]=!0}}}}),zingchart.bind(null,"dataparse",function(t,e){var a,r,i,n,s,l,o=zingchart.getLoader(t.id),d=zingchart.getModules(o);if(-1===ZC.AV(d,"svg-simple-selection"))return e;for(a=0,r=e[ZC._[16]].length;a<r;a++){var g=e[ZC._[16]][a];ZC._todash_(g);var p=g.id||"id"+a,c=t.id+"-graph-"+p;if("bar"===g.type||"vbar"===g.type||"hbar"===g.type){l={plot:{"selection-mode":"none","selected-state":{}}};var S=g.plot||{};(i=S["selection-mode"])&&(l.plot["selection-mode"]=i,g.plot["selection-mode"]="none"),(i=S[ZC._[73]])&&(l.plot[ZC._[73]]={},ZC._cp_(i,l.plot[ZC._[73]]));var C=g[ZC._[11]]||[];for(n=0,s=C.length;n<s;n++)C[n]&&(l["series-"+n]={"selection-mode":l.plot["selection-mode"],"selected-state":{}},ZC._cp_(l.plot[ZC._[73]],l["series-"+n][ZC._[73]]),(i=C[n]["selection-mode"])&&(l["series-"+n]["selection-mode"]=i),(i=C[n][ZC._[73]])&&ZC._cp_(i,l["series-"+n][ZC._[73]]),g[ZC._[11]][n]["selection-mode"]="none")}ZC.SSS=ZC.SSS||{},ZC.SSS[c]={defs:l,selection:{}}}return e}),zingchart.bind(null,"node_click",function(t){var e,r=zingchart.getLoader(t.id),i=zingchart.getGraph(r,t.graphid),n=zingchart.getModules(r);if(-1!==ZC.AV(n,"svg-simple-selection")&&("vbar"===i.AF||"hbar"===i.AF)){var s,l,o,d,g=i.K;if(ZC.SSS&&ZC.SSS[g]){var p=t.plotindex,c=ZC.SSS[g].selection;if(e=ZC.SSS[g].defs["series-"+p]){var S=e["selection-mode"],C=e[ZC._[73]],v=!1;if(c["p"+t.plotindex]&&c["p"+t.plotindex]["n"+t.nodeindex]&&(v=!0),!v)switch(S){default:break;case"plot":if(c["p"+t.plotindex])for(s in c["p"+t.plotindex])o=s.replace("n",""),a(i,c,t.plotindex,o,null);break;case"graph":for(l in c)if(d=l.replace("p",""),ZC.SSS[g].defs["series-"+d]&&"graph"===ZC.SSS[g].defs["series-"+d]["selection-mode"])for(s in c["p"+d])a(i,c,d,o=s.replace("n",""),null)}a(i,c,t.plotindex,t.nodeindex,v?null:C)}}}})}();