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