UNPKG

@fusioncharts/core

Version:

JavaScript Data Visualisation Library

1 lines 3.03 kB
"use strict";exports.__esModule=true;exports.default=_default;function _default(R){var win=window,UNDEF,toFloat=win.parseFloat,ARRAY="array",BLANK="",COMMA=",",SPACE=" ",NONE="none",createNode=R._createNode,setFillAndStroke=R._setFillAndStroke,Element=R.el.constructor,LITEPATH="litepath",CSSFLOOD="position:absolute;left:0;top:0;width:21600px;height:21600px;",COORD21600="21600 21600",s2vcmd={Q:"L",Z:"X",q:"l",z:"x",",":" "},p2s=/,?([achlmqrstvxz]),?/gi,p2srep,path2string=function path2string(){return this.join(COMMA).replace(p2s,p2srep)},litepathsetter,vmlTransformHelper;if(R.svg){p2srep="$1";litepathsetter=function litepathsetter(){var o=this,path=R.is(arguments[0],ARRAY)?arguments[0]:Array.prototype.slice.call(arguments);if(!path){path="M0,0"}else if(typeof path==="string"){path=path.replace(p2s,p2srep)}else{path.toString=path2string}o.node.setAttribute("d",path.toString())};R._engine.litepath=function(path,svg,zoom,group,attributes){var el=createNode("path"),p;(group||svg).canvas.appendChild(el);p=new Element(el,svg,group);p.type=LITEPATH;p.id=el.raphaelid=R._oid++;el.raphael=true;setFillAndStroke(p,attributes||{fill:NONE,stroke:"#000"});return p};R._getPath.litepath=function(el){return R.parsePathString(el.node.getAttribute("d"))}}else if(R.vml){p2srep=function p2srep(cmd,$1){return s2vcmd[$1]||$1};vmlTransformHelper=function vmlTransformHelper(){var o=this;o._transform.apply(o,arguments);o._.bcoord&&(o.node.coordsize=o._.bcoord);return o};litepathsetter=function litepathsetter(_path){var o=this,path=_path;if(!path){path="M0,0"}else if(typeof path==="string"){path=path.replace(p2s,p2srep)}else{path.toString=path2string}o.node.path=path;return o};R._engine.litepath=function(pathString,vml,_zoom,group,attributes){var el=createNode("shape"),s=el.style,p=new Element(el,vml,group),attr=attributes||{fill:NONE,stroke:"#000"},skew,zoom=_zoom;s.cssText=CSSFLOOD;zoom=toFloat(zoom);if(isNaN(zoom)){el.coordsize=COORD21600}else{p._.bzoom=zoom;s.width="1px";s.height="1px";el.coordsize=p._.bcoord=zoom+SPACE+zoom}el.coordorigin=vml.coordorigin;p.type=LITEPATH;p.id=el.raphaelid=R._oid++;el.raphael=true;p._transform=p.transform;p.transform=vmlTransformHelper;R._setFillAndStroke(p,attr);(group||vml).canvas.appendChild(el);skew=createNode("skew");skew.on=true;el.appendChild(skew);p.skew=skew;return p};R._getPath.litepath=function(el){return R.parsePathString(el.node.path||BLANK)}}R.fn[LITEPATH]=function(_path,_zoomInput,_group){var paper=this,attributes,zoom,out,path=_path,zoomInput=_zoomInput,group=_group;if(typeof path==="object"&&path.constructor!==Element){attributes=path;path=path.litepath;zoom=path.zoom;group=path.group}if(zoomInput&&zoomInput.constructor===Element){group=zoomInput;zoom=UNDEF}else{zoom=zoomInput}if(path&&path.constructor===Element){group=path;path=BLANK}out=R._engine[LITEPATH](path,this,zoom,group,attributes);out.ca[LITEPATH]=litepathsetter;path&&out.attr(LITEPATH,R.is(path,ARRAY)?[path]:path);return paper.__set__&&this.__set__.push(out),paper._elementsById[out.id]=out}}