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) 4.9 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("dragging"),zingchart.bind(null,"node_mouseout",function(){document.body.style.cursor="default"}),zingchart.bind(null,"node_mouseup",function(){document.body.style.cursor="default"}),zingchart.bind(null,"node_click",function(){document.body.style.cursor="default"}),zingchart.bind(null,"node_mousedown",function(e){var a=zingchart.getLoader(e.id),t=zingchart.getGraph(a,e.graphid),n=zingchart.getModules(a);if(-1!==ZC.AV(n,"dragging")){e.ev.preventDefault();var i,d=e.ev.shiftKey,o=!0,s=!1,r=0,c=0,l=0,g=0,u=0,p=e.plotindex,h=e.nodeindex,f=e.value,x=[],m=(t=zingchart.getGraph(a,e.graphid)).getData(),v={};m.options&&(v=m.options.dragging||m.options);var b=zingchart.exec(e.id,"getobjectinfo",{object:"plot",plotindex:e.plotindex});if(b.xdata.dragging){var z=0;"undefined"!=typeof v.decimals&&(z=parseInt(v.decimals,10)),"undefined"!=typeof b.xdata["dragging-decimals"]&&(z=parseInt(b.xdata["dragging-decimals"],10));var y=null,_=null;"undefined"!=typeof b.xdata["dragging-min-value"]&&(y=parseFloat(b.xdata["dragging-min-value"])),"undefined"!=typeof b.xdata["dragging-max-value"]&&(_=parseFloat(b.xdata["dragging-max-value"]));for(var C=0;C<b.scales.length;C++)-1===b.scales[C].indexOf("scale-y")&&-1===b.scales[C].indexOf("scale-v")||(i=b.scales[C]);var Z={};switch(-1===ZC.AV(["pie","pie3d","nestedpie"],b.type)&&(Z=zingchart.exec(e.id,"getobjectinfo",{object:"scale",name:i})),b.type){case"line":case"area":Z.inversed?document.body.style.cursor="ew-resize":document.body.style.cursor="ns-resize";break;case"hbar":case"hbar3d":case"hbullet":document.body.style.cursor="ew-resize";break;case"pie":case"nestedpie":case"pie3d":case"radar":document.body.style.cursor="move";break;default:document.body.style.cursor="ns-resize"}var F=1,k=zingchart.exec(e.id,"getobjectinfo",{object:"scale",name:"scale"});k&&k.sizeFactor&&(F=k.sizeFactor);var M,w,A=ZC.A4("#"+e.id+"-top");x=[].concat(zingchart.exec(e.id,"getseriesvalues",{plotindex:e.plotindex})),zingchart.SKIP.LEGEND=!0;var E=Z.height,V=function(t){o?(c=t.pageX,r=t.pageY,o=!1):(l=t.pageX-c,g=r-t.pageY),M=t.pageX,w=t.pageY,e.ev.pageX,e.ev.pageY,function(t){switch(b.type){case"line":case"area":Z.inversed?(u=l,g=0,E=Z.width):(u=g,l=0);break;case"hbar":case"hbullet":case"hbar3d":u=l,g=0,E=Z.width;break;case"pie":case"nestedpie":case"pie3d":u=l,E=F*Math.min(Z.width,Z.height)/2-Z.offsetStart-Z.offsetEnd;break;case"radar":var n=[Z.x+Z.width/2,Z.y+Z.height/2],i=Math.sqrt((c-A.offset().left-n[0])*(c-A.offset().left-n[0])+(r-A.offset().top-n[1])*(r-A.offset().top-n[1])),o=Math.sqrt((M-A.offset().left-n[0])*(M-A.offset().left-n[0])+(w-A.offset().top-n[1])*(w-A.offset().top-n[1]));u=o-i,E=F*Math.min(Z.width,Z.height)/2-Z.offsetStart-Z.offsetEnd;break;default:u=g,l=0}if(Math.abs(u)>1){s=!0,zingchart.exec(e.id,"setmode",{mode:"static"});var p=zingchart.exec(e.id,"getselection");if(f=-1!==ZC.AV(["pie","pie3d","nestedpie"],b.type)?Math.max(0===z?1:1/z,parseFloat(e.value+u)):b.stacked&&"100%"===b.stackType?parseFloat((e.value+100*u/E).toFixed(z)):parseFloat((e.value+(Z.maxValue-Z.minValue)*u/E).toFixed(z)),d){for(var h=[],m=0;m<x.length;m++)null===ZC._n_(p)||null===ZC._n_(p[e.plotindex])||null!==ZC._n_(p[e.plotindex])&&-1!==ZC.AV(p[e.plotindex],m)?b.stacked&&"100%"===b.stackType?h[m]=parseFloat((x[m]+100*u/E).toFixed(z)):h[m]=parseFloat((x[m]+(Z.maxValue-Z.minValue)*u/E).toFixed(z)):h[m]=x[m],null!==ZC._n_(y)&&(h[m]=Math.max(h[m],y)),null!==ZC._n_(_)&&(h[m]=Math.min(h[m],_));zingchart.exec(e.id,"setseriesvalues",{plotindex:e.plotindex,values:h}),e["zingchart.plugins.dragging.update.type"]="plot",e["zingchart.plugins.dragging.update.values"]=h,zingchart.fireEvent("zingchart.plugins.dragging.update",a,e)}else null!==ZC._n_(y)&&(f=Math.max(f,y)),null!==ZC._n_(_)&&(f=Math.min(f,_)),zingchart.exec(e.id,"setnodevalue",{plotindex:e.plotindex,nodeindex:e.nodeindex,value:f}),e["zingchart.plugins.dragging.update.type"]="node",e["zingchart.plugins.dragging.update.value"]=f,zingchart.fireEvent("zingchart.plugins.dragging.update",a,e);zingchart.exec(e.id,"showtooltip",e)}}()};ZC.A4(document.body).bind("mousemove",V),ZC.A4(document.body).bind("mouseup",function(n){if(ZC.A4(document.body).unbind("mousemove",V),s){o=!0,zingchart.SKIP.LEGEND=!1,zingchart.exec(e.id,"setmode",{mode:""}),d?zingchart.exec(e.id,"update",{}):zingchart.exec(e.id,"setnodevalue",{plotindex:p,nodeindex:h,value:f});var i=t.AY.A3[p].FQ(h);i&&i.X6(n,"mouseup"),zingchart.fireEvent("zingchart.plugins.dragging.complete",a,e),document.body.style.cursor="default"}s=!1})}}});