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.91 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("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,r=!1,s=0,c=0,l=0,g=0,u=0,p=e.plotindex,f=e.nodeindex,h=e.value,x=[],v=(t=zingchart.getGraph(a,e.graphid)).getData(),m={};v.options&&(m=v.options.dragging||v.options);var b=zingchart.exec(e.id,"getobjectinfo",{object:"plot",plotindex:e.plotindex});if(b.xdata.dragging){var z=0;typeof m[ZC._[12]]!==ZC._[31]&&(z=parseInt(m[ZC._[12]],10)),typeof b.xdata["dragging-decimals"]!==ZC._[31]&&(z=parseInt(b.xdata["dragging-decimals"],10));var _=null,Z=null;typeof b.xdata["dragging-min-value"]!==ZC._[31]&&(_=parseFloat(b.xdata["dragging-min-value"])),typeof b.xdata["dragging-max-value"]!==ZC._[31]&&(Z=parseFloat(b.xdata["dragging-max-value"]));for(var C=0;C<b.scales.length;C++)-1===b.scales[C].indexOf(ZC._[51])&&-1===b.scales[C].indexOf(ZC._[52])||(i=b.scales[C]);var y={};switch(-1===ZC.AV(["pie","pie3d","nestedpie"],b.type)&&(y=zingchart.exec(e.id,"getobjectinfo",{object:"scale",name:i})),b.type){case"line":case"area":y.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,A,E=ZC.A5("#"+e.id+"-top");x=[].concat(zingchart.exec(e.id,"getseriesvalues",{plotindex:e.plotindex})),zingchart.SKIP.LEGEND=!0;var V=y[ZC._[20]],j=function(t){o?(c=t.pageX,s=t.pageY,o=!1):(l=t.pageX-c,g=s-t.pageY),M=t.pageX,A=t.pageY,e.ev.pageX,e.ev.pageY,function(t){switch(b.type){case"line":case"area":y.inversed?(u=l,g=0,V=y[ZC._[19]]):(u=g,l=0);break;case"hbar":case"hbullet":case"hbar3d":u=l,g=0,V=y[ZC._[19]];break;case"pie":case"nestedpie":case"pie3d":u=l,V=F*Math.min(y[ZC._[19]],y[ZC._[20]])/2-y.offsetStart-y.offsetEnd;break;case"radar":var n=[y.x+y[ZC._[19]]/2,y.y+y[ZC._[20]]/2],i=Math.sqrt((c-E.offset().left-n[0])*(c-E.offset().left-n[0])+(s-E.offset().top-n[1])*(s-E.offset().top-n[1])),o=Math.sqrt((M-E.offset().left-n[0])*(M-E.offset().left-n[0])+(A-E.offset().top-n[1])*(A-E.offset().top-n[1]));u=o-i,V=F*Math.min(y[ZC._[19]],y[ZC._[20]])/2-y.offsetStart-y.offsetEnd;break;default:u=g,l=0}if(Math.abs(u)>1){r=!0,zingchart.exec(e.id,"setmode",{mode:"static"});var p=zingchart.exec(e.id,"getselection");if(h=-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/V).toFixed(z)):parseFloat((e.value+(y.maxValue-y.minValue)*u/V).toFixed(z)),d){for(var f=[],v=0;v<x.length;v++)null===ZC._n_(p)||null===ZC._n_(p[e.plotindex])||null!==ZC._n_(p[e.plotindex])&&-1!==ZC.AV(p[e.plotindex],v)?b.stacked&&"100%"===b.stackType?f[v]=parseFloat((x[v]+100*u/V).toFixed(z)):f[v]=parseFloat((x[v]+(y.maxValue-y.minValue)*u/V).toFixed(z)):f[v]=x[v],null!==ZC._n_(_)&&(f[v]=Math.max(f[v],_)),null!==ZC._n_(Z)&&(f[v]=Math.min(f[v],Z));zingchart.exec(e.id,"setseriesvalues",{plotindex:e.plotindex,values:f}),e["zingchart.plugins.dragging.update.type"]="plot",e["zingchart.plugins.dragging.update.values"]=f,zingchart.fireEvent("zingchart.plugins.dragging.update",a,e)}else null!==ZC._n_(_)&&(h=Math.max(h,_)),null!==ZC._n_(Z)&&(h=Math.min(h,Z)),zingchart.exec(e.id,"setnodevalue",{plotindex:e.plotindex,nodeindex:e.nodeindex,value:h}),e["zingchart.plugins.dragging.update.type"]="node",e["zingchart.plugins.dragging.update.value"]=h,zingchart.fireEvent("zingchart.plugins.dragging.update",a,e);zingchart.exec(e.id,"showtooltip",e)}}()};ZC.A5(document.body).bind(ZC._[48],j),ZC.A5(document.body).bind(ZC._[49],function(n){if(ZC.A5(document.body).unbind(ZC._[48],j),r){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:f,value:h});var i=t.AZ.A3[p].FK(f);i&&i.P3(n,ZC._[49]),zingchart.fireEvent("zingchart.plugins.dragging.complete",a,e),document.body.style.cursor="default"}r=!1})}}});