-
Notifications
You must be signed in to change notification settings - Fork 45
/
zingchart-api-annotations.min.js
8 lines (7 loc) · 2.81 KB
/
zingchart-api-annotations.min.js
1
2
3
4
5
6
7
8
/*
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 [email protected].
Build 2.9.15_ES6
*/
zingchart.setModule("api-annotations"),zingchart.extendAPI("removenote",function(e,t){if(t.id instanceof Array){for(var a=[],n=0;n<t.id.length;n++)a.push("zingchart-note-"+t.id[n]);zingchart.exec(e,"removeobject",{type:"label",id:a})}else{var o=t.id||"note";zingchart.exec(e,"removeobject",{type:"label",id:"zingchart-note-"+o})}}),zingchart.extendAPI("updatenote",function(e,t){var a=t.id||"note",n=t.style||{},o=t.text||"",c=t.type||"",r=parseInt(t.plotindex||"0",10),s=parseInt(t.nodeindex||"0",10),i=parseInt(t.scaleindex||"-1",10),d=t.scalevalue||"",l=parseInt(t.x||"0",10),p=parseInt(t.y||"0",10),y=parseInt(t["offset-x"]||"0",10),x=parseInt(t["offset-y"]||"-10",10),f={},h={};if(""!==c){switch(c){case"node":f={type:c,plot:r,index:s},h={type:c,plot:r,index:s};break;case"scale":-1!==i?(f={type:c,index:i},h={type:c,index:i}):""!==d&&(f={type:c,value:d},h={type:c,value:d});break;case"xy":f={type:c,x:l,y:p},h={type:c,x:l,y:p}}null!==ZC._n_(t["offset-x"])&&(h["offset-x"]=y),null!==ZC._n_(t["offset-y"])&&(h["offset-y"]=x)}var g={};zingchart.copy(n,g),""!==o&&zingchart.copy({text:o},g),zingchart.normalize(g),""!==c&&(g.hook=f,g["callout-hook"]=h),zingchart.exec(e,"updateobject",{type:"label",id:"zingchart-note-"+a,data:g})}),zingchart.extendAPI("getnotes",function(e){return zingchart.exec(e,"getobjectsbyclass",{type:"label","class":"zingchart-note"})}),zingchart.extendAPI("addnote",function(e,t){var a=t.text||"note",n=t.id||"note"+parseInt(1e4+89999*Math.random(),10),o=t.type||"xy",c=parseInt(t.plotindex||"0",10),r=parseInt(t.nodeindex||"0",10),s=parseInt(t.scaleindex||"-1",10),i=t.scalevalue||"",d=parseInt(t.x||"0",10),l=parseInt(t.y||"0",10),p=parseInt(t["offset-x"]||"0",10),y=parseInt(t["offset-y"]||"-10",10),x=t.style||{"border-width":1,"border-color":"#666","border-radius":9,shadow:!0,"shadow-distance":1,"background-color":"#ccc #eee",padding:10,"offset-y":2*y,"offset-x":2*p,anchor:"b",callout:!0,"callout-position":"bottom","callout-width":10};zingchart.normalize(x);var f={},h={};switch(o){case"node":f={type:o,plot:c,index:r},h={type:o,plot:c,index:r,"offset-x":p,"offset-y":y};break;case"scale":-1!==s?(f={type:o,index:s},h={type:o,index:s,"offset-x":p,"offset-y":y}):""!==i&&(f={type:o,value:i},h={type:o,value:i,"offset-x":p,"offset-y":y});break;case"xy":f={type:o,x:d,y:l},h={type:o,x:d,y:l,"offset-x":p,"offset-y":y}}var g={"class":"zingchart-note",id:"zingchart-note-"+n,text:a,hook:f,"callout-hook":h};zingchart.copy(x,g),zingchart.exec(e,"addobject",{type:"label",data:g})});