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) 7.52 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 */ 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(e,t){var i="",a=e["data-palette"].split(";");return t=parseInt(t,10),e.key!==e["data-mmp"]?(i='<span style="font-size:21px">'+e.scaletext+'</span><br><br><span style="color:'+a[1-t]+'">%plot-text:</span>\xa0\xa0'+e.value+'<br><span style="color:'+a[1-t]+'">%data-cost:</span>\xa0\xa0'+e["data-currency"]+zingchart.formatNumber(e.key*e.value,{"thousands-separator":",",decimals:2}),{"border-bottom":"5px solid "+a[t],text:i}):{text:"N/A",visible:!1}}),zingchart.bind(null,"dataparse",function(e,t){for(var i=zingchart.getLoader(e.id),a=0,n=t.graphset.length;a<n;a++)if(t.graphset[a].type&&"depth"===t.graphset[a].type){var o=t.graphset[a].type;t.graphset[a]["plugin-type"]=o;var l=t.graphset[a];zingchart.normalize(l),l.type="area";var r={};l.options&&(r=l.options[o]||l.options),ZC._todash_(r);var s=r["mid-market-price"]||-1,c=r.currency||"$",h=r.palette||["#090","#900"],d=r.labels||{};l.gui=l.gui||{},l.gui.behaviors=l.gui.behaviors||[],l.gui.behaviors.push({id:"ZoomIn",enabled:"none"},{id:"ZoomOut",enabled:"none"},{id:"ViewAll",enabled:"none"}),l["scale-x"]=l["scale-x"]||{},l["scale-y"]=l["scale-y"]||{},l["scale-y-2"]=l["scale-y-2"]||{},l.plot=l.plot||{},l["crosshair-x"]=l["crosshair-x"]||{},l.zoom=l.zoom||{},l.zoom.active=!1,l.plotarea=l.plotarea||{},ZC._inj_(l.plotarea,{margin:"dynamic dynamic dynamic dynamic","mask-tolerance":[0,0]}),ZC._inj_(l["scale-x"],{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"}),l["scale-x"].zooming=!0,l["scale-x"].markers=l["scale-x"].markers||[],ZC._inj_(l["scale-y"],{"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_(l["scale-y-2"],{"min-value":0,zooming:!0,master:"scale-y",tick:{placement:"inner"},short:!0,guide:{"line-width":0},item:{"font-size":10,"font-weight":"bold",placement:"inner"}});var p=l.series||[];if(p.length<2)return t;var g,u,m=-Number.MAX_VALUE,z=-Number.MAX_VALUE,f=Number.MAX_VALUE,b=-Number.MAX_VALUE;for(u=p[0].values||[],g=0;g<u.length;g++)null!==u[g]&&2===u[g].length&&(m=Math.max(m,u[g][1]),-1===s&&0===u[g][1]&&(s=u[g][0]),f=Math.min(f,u[g][0]),b=Math.max(b,u[g][0]));for(p[0].scales="scale-x,scale-y",u=p[1].values||[],g=0;g<u.length;g++)null!==u[g]&&2===u[g].length&&(z=Math.max(z,u[g][1]),-1===s&&0===u[g][1]&&(s=u[g][0]),f=Math.min(f,u[g][0]),b=Math.max(b,u[g][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_(l.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_(l["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}}),l["crosshair-x"].exact=!0;var _={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_(r["mmp-marker"],_),l["scale-x"].markers.push(_);var x=zingchart.plugins.depth.info[i.K].zoom||.5,y=s-f,v=b-s,k=Math.min(y,v),w=.05*k,Z=k*x,j=.05*k;zingchart.plugins.depth.info[i.K].diff=Z,zingchart.plugins.depth.info[i.K]["min-diff"]=w,zingchart.plugins.depth.info[i.K]["max-diff"]=k,zingchart.plugins.depth.info[i.K].step=j,zingchart.plugins.depth.info[i.K].zoom=x,p.push({values:[[s,0]],visible:!1,"export":!1,scales:"scale-x,scale-y-2"}),l["scale-x"]["zoom-to-values"]=[s-Z,s+Z]}return t}),zingchart.bind(null,"objectsinit",function(e){var t=zingchart.getLoader(e.loader.id),i=zingchart.getGraph(t,e.graphid),a=i.o;if("depth"===a["plugin-type"]){var n=zingchart.getGraphInfo(t,a,i.L).plotarea,o={};a.options&&(o=a.options.depth||a.options),ZC._todash_(o);var l=zingchart.plugins.depth.info[t.K].currency+zingchart.formatNumber(zingchart.plugins.depth.info[t.K].mmp,{"thousands-separator":","});a.labels=a.labels||[];for(var r=a.labels.length-1;r>=0;r--)"zc_depth"===a.labels[r].cls&&a.labels.splice(r,1);var s={cls:"zc_depth",id:"zc_depth_title",x:n.x+n.width/2,y:n.y+10,anchor:"t","font-size":21,"font-weight":"bold",text:l};ZC._cp_(o.title,s),a.labels.push(s);var c={cls:"zc_depth",id:"zc_depth_subtitle",x:n.x+n.width/2,y:n.y+35,anchor:"t","font-size":12,color:"#999",text:"Mid Market Price"};ZC._cp_(o.subtitle,c),a.labels.push(c);var h=Math.round(s["font-size"]*l.length*.35),d={cls:"zc_depth",x:n.x+n.width/2-h,y:n.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_(o["button-zoomout"],d),a.labels.push(d);var p={cls:"zc_depth",x:n.x+n.width/2+h,y:n.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_(o["button-zoomin"],p),a.labels.push(p)}}),zingchart.bind(null,"label_click",function(e){if("zc_depth_zoomin"===e.label.id||"zc_depth_zoomout"===e.label.id){var t=zingchart.plugins.depth.info[e.id].mmp,i=zingchart.plugins.depth.info[e.id].step,a=zingchart.plugins.depth.info[e.id].diff,n=zingchart.plugins.depth.info[e.id]["min-diff"],o=zingchart.plugins.depth.info[e.id]["max-diff"],l=zingchart.plugins.depth.info[e.id].zoom;a+="zc_depth_zoomout"===e.label.id?i:-i,l+="zc_depth_zoomout"===e.label.id?.05:-.05,a>o?(a=o,l=1):a<n&&(a=n,l=.05),zingchart.plugins.depth.info[e.id].diff=a,zingchart.plugins.depth.info[e.id].zoom=l,zingchart.exec(e.id,"zoomto",{kmin:t-a,kmax:t+a})}}),zingchart.bind(null,"label_mouseover",function(e){"zc_depth"===e.label.cls&&zingchart.exec(e.id,"hideguide")}),zingchart.bind(null,"label_mouseout",function(e){"zc_depth"===e.label.cls&&zingchart.exec(e.id,"showguide")});