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.56 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("depth"),zingchart.plugins.depth=zingchart.plugins.depth||{},zingchart.plugins.depth.info=zingchart.plugins.depth.info||{},zingchart.plugins.depth.crosshairX_plotLabel_jsRule||(zingchart.plugins.depth.crosshairX_plotLabel_jsRule=function(t,e){var i="",n=t["data-palette"].split(";");return e=parseInt(e,10),t.key!==t["data-mmp"]?(i='<span style="font-size:21px">'+t.scaletext+'</span><br><br><span style="color:'+n[1-e]+'">%plot-text:</span>\xa0\xa0'+t[ZC._[9]]+'<br><span style="color:'+n[1-e]+'">%data-cost:</span>\xa0\xa0'+t["data-currency"]+zingchart.formatNumber(t.key*t[ZC._[9]],{"thousands-separator":",",decimals:2}),{"border-bottom":"5px solid "+n[e],text:i}):{text:"N/A",visible:!1}}),zingchart.bind(null,"dataparse",function(t,e){for(var i=zingchart.getLoader(t.id),n=0,o=e[ZC._[16]].length;n<o;n++)if(e[ZC._[16]][n].type&&"depth"===e[ZC._[16]][n].type){var a=e[ZC._[16]][n].type;e[ZC._[16]][n]["plugin-type"]=a;var r=e[ZC._[16]][n];zingchart.normalize(r),r.type="area";var l={};r.options&&(l=r.options[a]||r.options),ZC._todash_(l);var s=l["mid-market-price"]||-1,c=l.currency||"$",h=l.palette||["#090","#900"],d=l[ZC._[10]]||{};r.gui=r.gui||{},r.gui.behaviors=r.gui.behaviors||[],r.gui.behaviors.push({id:"ZoomIn",enabled:"none"},{id:"ZoomOut",enabled:"none"},{id:"ViewAll",enabled:"none"}),r[ZC._[50]]=r[ZC._[50]]||{},r[ZC._[51]]=r[ZC._[51]]||{},r["scale-y-2"]=r["scale-y-2"]||{},r.plot=r.plot||{},r["crosshair-x"]=r["crosshair-x"]||{},r.zoom=r.zoom||{},r.zoom.active=!1,r.plotarea=r.plotarea||{},ZC._inj_(r.plotarea,{margin:"dynamic dynamic dynamic dynamic","mask-tolerance":[0,0]}),ZC._inj_(r[ZC._[50]],{item:{"font-size":10,"font-weight":"bold",rules:[{rule:"%scale-position === 2",visible:!1}]},tick:{rules:[{rule:"%scale-position === 2",visible:!1}]},normalize:!1,"thousands-separator":",","max-items":5,format:c+"%v"}),r[ZC._[50]].zooming=!0,r[ZC._[50]].markers=r[ZC._[50]].markers||[],ZC._inj_(r[ZC._[51]],{"min-value":0,zooming:!0,"auto-fit":!0,tick:{placement:"inner"},short:!0,guide:{"line-width":0},item:{"font-size":10,"font-weight":"bold",placement:"inner"}}),ZC._inj_(r["scale-y-2"],{"min-value":0,zooming:!0,master:ZC._[51],tick:{placement:"inner"},short:!0,guide:{"line-width":0},item:{"font-size":10,"font-weight":"bold",placement:"inner"}});var p=r[ZC._[11]]||[];if(p.length<2)return e;var u,g,_=-Number.MAX_VALUE,m=-Number.MAX_VALUE,z=Number.MAX_VALUE,f=-Number.MAX_VALUE;for(g=p[0][ZC._[5]]||[],u=0;u<g.length;u++)null!==g[u]&&2===g[u].length&&(_=Math.max(_,g[u][1]),-1===s&&0===g[u][1]&&(s=g[u][0]),z=Math.min(z,g[u][0]),f=Math.max(f,g[u][0]));for(p[0].scales="scale-x,scale-y",g=p[1][ZC._[5]]||[],u=0;u<g.length;u++)null!==g[u]&&2===g[u].length&&(m=Math.max(m,g[u][1]),-1===s&&0===g[u][1]&&(s=g[u][0]),z=Math.min(z,g[u][0]),f=Math.max(f,g[u][0]));p[1].scales="scale-x,scale-y",ZC._inj_(p[0],{"step-start":"after","line-color":h[0],"line-width":1,"background-color":h[0],"guide-label":{"js-rule":"zingchart.plugins.depth.crosshairX_plotLabel_jsRule(0)"}}),ZC._inj_(p[1],{"step-start":"after","line-color":h[1],"line-width":1,"background-color":h[1],"guide-label":{"js-rule":"zingchart.plugins.depth.crosshairX_plotLabel_jsRule(1)"}}),zingchart.plugins.depth.info[i.K]=zingchart.plugins.depth.info[i.K]||{},zingchart.plugins.depth.info[i.K].mmp=s,zingchart.plugins.depth.info[i.K].currency=c,ZC._inj_(r.plot,{aspect:"stepped",mode:"fast","max-nodes":0,"max-trackers":0,"data-currency":c,"data-cost":d.cost||"Cost","data-mmp":s,"data-palette":h.join(";")}),ZC._inj_(r["crosshair-x"],{"line-color":"#ccc","scale-label":{"thousands-separator":",","font-size":10,"font-weight":"bold","background-color":"#333",rules:[{rule:"%scale-key-value < "+s,"background-color":h[0]},{rule:"%scale-key-value > "+s,"background-color":h[1]}]},"plot-label":{multiple:!0,callout:!1,"background-color":"#eee",padding:"10 10 15 10","font-size":11,"font-weight":"bold"},marker:{type:"diamond",size:3}}),r["crosshair-x"].exact=!0;var b={type:"line","line-color":"#ccc","line-width":1,range:[s],"value-range":!0,"label-tolerance":20,"offset-end":100,label:{"font-size":10,"font-weight":"bold",angle:0,width:80,"offset-x":-40,"offset-y":15,text:zingchart.plugins.depth.info[i.K].currency+zingchart.formatNumber(zingchart.plugins.depth.info[i.K].mmp,{"thousands-separator":","})}};ZC._cp_(l["mmp-marker"],b),r[ZC._[50]].markers.push(b);var Z=zingchart.plugins.depth.info[i.K].zoom||.5,C=s-z,x=f-s,y=Math.min(C,x),v=.05*y,k=y*Z,w=.05*y;zingchart.plugins.depth.info[i.K].diff=k,zingchart.plugins.depth.info[i.K]["min-diff"]=v,zingchart.plugins.depth.info[i.K]["max-diff"]=y,zingchart.plugins.depth.info[i.K].step=w,zingchart.plugins.depth.info[i.K].zoom=Z,p.push({values:[[s,0]],visible:!1,"export":!1,scales:"scale-x,scale-y-2"}),r[ZC._[50]]["zoom-to-values"]=[s-k,s+k]}return e}),zingchart.bind(null,"objectsinit",function(t){var e=zingchart.getLoader(t.loader.id),i=zingchart.getGraph(e,t.graphid),n=i.o;if("depth"===n["plugin-type"]){var o=zingchart.getGraphInfo(e,n,i.L).plotarea,a={};n.options&&(a=n.options.depth||n.options),ZC._todash_(a);var r=zingchart.plugins.depth.info[e.K].currency+zingchart.formatNumber(zingchart.plugins.depth.info[e.K].mmp,{"thousands-separator":","});n[ZC._[10]]=n[ZC._[10]]||[];for(var l=n[ZC._[10]].length-1;l>=0;l--)"zc_depth"===n[ZC._[10]][l].cls&&n[ZC._[10]].splice(l,1);var s={cls:"zc_depth",id:"zc_depth_title",x:o.x+o.width/2,y:o.y+10,anchor:"t","font-size":21,"font-weight":"bold",text:r};ZC._cp_(a.title,s),n[ZC._[10]].push(s);var c={cls:"zc_depth",id:"zc_depth_subtitle",x:o.x+o.width/2,y:o.y+35,anchor:"t","font-size":12,color:"#999",text:"Mid Market Price"};ZC._cp_(a.subtitle,c),n[ZC._[10]].push(c);var h=Math.round(s["font-size"]*r.length*.35),d={cls:"zc_depth",x:o.x+o.width/2-h,y:o.y+16,width:20,height:20,anchor:"tr","border-width":1,"font-size":14,"font-weight":"bold",text:" - ","background-color":"#ddd","hover-state":{"background-color":"#eee"},tooltip:{text:"Zoom Out"},id:"zc_depth_zoomout"};ZC._cp_(a["button-zoomout"],d),n[ZC._[10]].push(d);var p={cls:"zc_depth",x:o.x+o.width/2+h,y:o.y+16,width:20,height:20,anchor:"tl","border-width":1,"font-size":14,"font-weight":"bold",text:" + ","background-color":"#ddd","hover-state":{"background-color":"#eee"},tooltip:{text:"Zoom In"},id:"zc_depth_zoomin"};ZC._cp_(a["button-zoomin"],p),n[ZC._[10]].push(p)}}),zingchart.bind(null,"label_click",function(t){if("zc_depth_zoomin"===t.label.id||"zc_depth_zoomout"===t.label.id){var e=zingchart.plugins.depth.info[t.id].mmp,i=zingchart.plugins.depth.info[t.id].step,n=zingchart.plugins.depth.info[t.id].diff,o=zingchart.plugins.depth.info[t.id]["min-diff"],a=zingchart.plugins.depth.info[t.id]["max-diff"],r=zingchart.plugins.depth.info[t.id].zoom;n+="zc_depth_zoomout"===t.label.id?i:-i,r+="zc_depth_zoomout"===t.label.id?.05:-.05,n>a?(n=a,r=1):n<o&&(n=o,r=.05),zingchart.plugins.depth.info[t.id].diff=n,zingchart.plugins.depth.info[t.id].zoom=r,zingchart.exec(t.id,"zoomto",{kmin:e-n,kmax:e+n})}}),zingchart.bind(null,"label_mouseover",function(t){"zc_depth"===t.label.cls&&zingchart.exec(t.id,"hideguide")}),zingchart.bind(null,"label_mouseout",function(t){"zc_depth"===t.label.cls&&zingchart.exec(t.id,"showguide")});