echarts_renderers.js 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391
  1. import {
  2. BoundingRect_default,
  3. CompoundPath_default,
  4. DEFAULT_FONT,
  5. DEFAULT_FONT_FAMILY,
  6. DEFAULT_PATH_STYLE,
  7. Eventful_default,
  8. Image_default,
  9. PathProxy_default,
  10. Path_default,
  11. REDRAW_BIT,
  12. TEXT_ALIGN_TO_ANCHOR,
  13. TSpan_default,
  14. __extends,
  15. adjustTextY,
  16. assert,
  17. brush,
  18. brushSingle,
  19. clone,
  20. copyTransform,
  21. createCanvasPattern,
  22. createCubicEasingFunc,
  23. createOrUpdateImage,
  24. devicePixelRatio,
  25. disableUserSelect,
  26. each,
  27. encodeBase64,
  28. env_default,
  29. extend,
  30. filter,
  31. getCanvasGradient,
  32. getIdURL,
  33. getLineDash,
  34. getLineHeight,
  35. getMatrixStr,
  36. getPathPrecision,
  37. getSRTTransformString,
  38. getShadowKey,
  39. getSize,
  40. hasSeparateFont,
  41. hasShadow,
  42. indexOf,
  43. isAroundZero,
  44. isArray,
  45. isFunction,
  46. isGradient,
  47. isGradientObject,
  48. isImagePattern,
  49. isImagePatternObject,
  50. isLinearGradient,
  51. isNumber,
  52. isObject,
  53. isPattern,
  54. isRadialGradient,
  55. isString,
  56. keys,
  57. logError,
  58. map,
  59. merge,
  60. normalizeColor,
  61. parseFontSize,
  62. platformApi,
  63. requestAnimationFrame_default,
  64. retrieve2,
  65. round4
  66. } from "./chunk-NFL6MJ5K.js";
  67. import {
  68. init_define_APP_INFO
  69. } from "./chunk-XY75H3MP.js";
  70. // dep:echarts_renderers
  71. init_define_APP_INFO();
  72. // node_modules/echarts/renderers.js
  73. init_define_APP_INFO();
  74. // node_modules/echarts/lib/export/renderers.js
  75. init_define_APP_INFO();
  76. // node_modules/echarts/lib/renderer/installSVGRenderer.js
  77. init_define_APP_INFO();
  78. // node_modules/zrender/lib/svg/Painter.js
  79. init_define_APP_INFO();
  80. // node_modules/zrender/lib/svg/graphic.js
  81. init_define_APP_INFO();
  82. // node_modules/zrender/lib/svg/SVGPathRebuilder.js
  83. init_define_APP_INFO();
  84. var mathSin = Math.sin;
  85. var mathCos = Math.cos;
  86. var PI = Math.PI;
  87. var PI2 = Math.PI * 2;
  88. var degree = 180 / PI;
  89. var SVGPathRebuilder = function() {
  90. function SVGPathRebuilder2() {
  91. }
  92. SVGPathRebuilder2.prototype.reset = function(precision) {
  93. this._start = true;
  94. this._d = [];
  95. this._str = "";
  96. this._p = Math.pow(10, precision || 4);
  97. };
  98. SVGPathRebuilder2.prototype.moveTo = function(x, y) {
  99. this._add("M", x, y);
  100. };
  101. SVGPathRebuilder2.prototype.lineTo = function(x, y) {
  102. this._add("L", x, y);
  103. };
  104. SVGPathRebuilder2.prototype.bezierCurveTo = function(x, y, x2, y2, x3, y3) {
  105. this._add("C", x, y, x2, y2, x3, y3);
  106. };
  107. SVGPathRebuilder2.prototype.quadraticCurveTo = function(x, y, x2, y2) {
  108. this._add("Q", x, y, x2, y2);
  109. };
  110. SVGPathRebuilder2.prototype.arc = function(cx, cy, r, startAngle, endAngle, anticlockwise) {
  111. this.ellipse(cx, cy, r, r, 0, startAngle, endAngle, anticlockwise);
  112. };
  113. SVGPathRebuilder2.prototype.ellipse = function(cx, cy, rx, ry, psi, startAngle, endAngle, anticlockwise) {
  114. var dTheta = endAngle - startAngle;
  115. var clockwise = !anticlockwise;
  116. var dThetaPositive = Math.abs(dTheta);
  117. var isCircle = isAroundZero(dThetaPositive - PI2) || (clockwise ? dTheta >= PI2 : -dTheta >= PI2);
  118. var unifiedTheta = dTheta > 0 ? dTheta % PI2 : dTheta % PI2 + PI2;
  119. var large = false;
  120. if (isCircle) {
  121. large = true;
  122. } else if (isAroundZero(dThetaPositive)) {
  123. large = false;
  124. } else {
  125. large = unifiedTheta >= PI === !!clockwise;
  126. }
  127. var x0 = cx + rx * mathCos(startAngle);
  128. var y0 = cy + ry * mathSin(startAngle);
  129. if (this._start) {
  130. this._add("M", x0, y0);
  131. }
  132. var xRot = Math.round(psi * degree);
  133. if (isCircle) {
  134. var p = 1 / this._p;
  135. var dTheta_1 = (clockwise ? 1 : -1) * (PI2 - p);
  136. this._add("A", rx, ry, xRot, 1, +clockwise, cx + rx * mathCos(startAngle + dTheta_1), cy + ry * mathSin(startAngle + dTheta_1));
  137. if (p > 0.01) {
  138. this._add("A", rx, ry, xRot, 0, +clockwise, x0, y0);
  139. }
  140. } else {
  141. var x = cx + rx * mathCos(endAngle);
  142. var y = cy + ry * mathSin(endAngle);
  143. this._add("A", rx, ry, xRot, +large, +clockwise, x, y);
  144. }
  145. };
  146. SVGPathRebuilder2.prototype.rect = function(x, y, w, h) {
  147. this._add("M", x, y);
  148. this._add("l", w, 0);
  149. this._add("l", 0, h);
  150. this._add("l", -w, 0);
  151. this._add("Z");
  152. };
  153. SVGPathRebuilder2.prototype.closePath = function() {
  154. if (this._d.length > 0) {
  155. this._add("Z");
  156. }
  157. };
  158. SVGPathRebuilder2.prototype._add = function(cmd, a, b, c, d, e, f, g, h) {
  159. var vals = [];
  160. var p = this._p;
  161. for (var i = 1; i < arguments.length; i++) {
  162. var val = arguments[i];
  163. if (isNaN(val)) {
  164. this._invalid = true;
  165. return;
  166. }
  167. vals.push(Math.round(val * p) / p);
  168. }
  169. this._d.push(cmd + vals.join(" "));
  170. this._start = cmd === "Z";
  171. };
  172. SVGPathRebuilder2.prototype.generateStr = function() {
  173. this._str = this._invalid ? "" : this._d.join("");
  174. this._d = [];
  175. };
  176. SVGPathRebuilder2.prototype.getStr = function() {
  177. return this._str;
  178. };
  179. return SVGPathRebuilder2;
  180. }();
  181. var SVGPathRebuilder_default = SVGPathRebuilder;
  182. // node_modules/zrender/lib/svg/mapStyleToAttrs.js
  183. init_define_APP_INFO();
  184. var NONE = "none";
  185. var mathRound = Math.round;
  186. function pathHasFill(style) {
  187. var fill = style.fill;
  188. return fill != null && fill !== NONE;
  189. }
  190. function pathHasStroke(style) {
  191. var stroke = style.stroke;
  192. return stroke != null && stroke !== NONE;
  193. }
  194. var strokeProps = ["lineCap", "miterLimit", "lineJoin"];
  195. var svgStrokeProps = map(strokeProps, function(prop) {
  196. return "stroke-" + prop.toLowerCase();
  197. });
  198. function mapStyleToAttrs(updateAttr, style, el, forceUpdate) {
  199. var opacity = style.opacity == null ? 1 : style.opacity;
  200. if (el instanceof Image_default) {
  201. updateAttr("opacity", opacity);
  202. return;
  203. }
  204. if (pathHasFill(style)) {
  205. var fill = normalizeColor(style.fill);
  206. updateAttr("fill", fill.color);
  207. var fillOpacity = style.fillOpacity != null ? style.fillOpacity * fill.opacity * opacity : fill.opacity * opacity;
  208. if (forceUpdate || fillOpacity < 1) {
  209. updateAttr("fill-opacity", fillOpacity);
  210. }
  211. } else {
  212. updateAttr("fill", NONE);
  213. }
  214. if (pathHasStroke(style)) {
  215. var stroke = normalizeColor(style.stroke);
  216. updateAttr("stroke", stroke.color);
  217. var strokeScale = style.strokeNoScale ? el.getLineScale() : 1;
  218. var strokeWidth = strokeScale ? (style.lineWidth || 0) / strokeScale : 0;
  219. var strokeOpacity = style.strokeOpacity != null ? style.strokeOpacity * stroke.opacity * opacity : stroke.opacity * opacity;
  220. var strokeFirst = style.strokeFirst;
  221. if (forceUpdate || strokeWidth !== 1) {
  222. updateAttr("stroke-width", strokeWidth);
  223. }
  224. if (forceUpdate || strokeFirst) {
  225. updateAttr("paint-order", strokeFirst ? "stroke" : "fill");
  226. }
  227. if (forceUpdate || strokeOpacity < 1) {
  228. updateAttr("stroke-opacity", strokeOpacity);
  229. }
  230. if (style.lineDash) {
  231. var _a = getLineDash(el), lineDash = _a[0], lineDashOffset = _a[1];
  232. if (lineDash) {
  233. lineDashOffset = mathRound(lineDashOffset || 0);
  234. updateAttr("stroke-dasharray", lineDash.join(","));
  235. if (lineDashOffset || forceUpdate) {
  236. updateAttr("stroke-dashoffset", lineDashOffset);
  237. }
  238. }
  239. } else if (forceUpdate) {
  240. updateAttr("stroke-dasharray", NONE);
  241. }
  242. for (var i = 0; i < strokeProps.length; i++) {
  243. var propName = strokeProps[i];
  244. if (forceUpdate || style[propName] !== DEFAULT_PATH_STYLE[propName]) {
  245. var val = style[propName] || DEFAULT_PATH_STYLE[propName];
  246. val && updateAttr(svgStrokeProps[i], val);
  247. }
  248. }
  249. } else if (forceUpdate) {
  250. updateAttr("stroke", NONE);
  251. }
  252. }
  253. // node_modules/zrender/lib/svg/core.js
  254. init_define_APP_INFO();
  255. var SVGNS = "http://www.w3.org/2000/svg";
  256. var XLINKNS = "http://www.w3.org/1999/xlink";
  257. var XMLNS = "http://www.w3.org/2000/xmlns/";
  258. var XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
  259. function createElement(name) {
  260. return document.createElementNS(SVGNS, name);
  261. }
  262. function createVNode(tag, key, attrs, children, text) {
  263. return {
  264. tag,
  265. attrs: attrs || {},
  266. children,
  267. text,
  268. key
  269. };
  270. }
  271. function createElementOpen(name, attrs) {
  272. var attrsStr = [];
  273. if (attrs) {
  274. for (var key in attrs) {
  275. var val = attrs[key];
  276. var part = key;
  277. if (val === false) {
  278. continue;
  279. } else if (val !== true && val != null) {
  280. part += '="' + val + '"';
  281. }
  282. attrsStr.push(part);
  283. }
  284. }
  285. return "<" + name + " " + attrsStr.join(" ") + ">";
  286. }
  287. function createElementClose(name) {
  288. return "</" + name + ">";
  289. }
  290. function vNodeToString(el, opts) {
  291. opts = opts || {};
  292. var S = opts.newline ? "\n" : "";
  293. function convertElToString(el2) {
  294. var children = el2.children, tag = el2.tag, attrs = el2.attrs;
  295. return createElementOpen(tag, attrs) + (el2.text || "") + (children ? "" + S + map(children, function(child) {
  296. return convertElToString(child);
  297. }).join(S) + S : "") + createElementClose(tag);
  298. }
  299. return convertElToString(el);
  300. }
  301. function getCssString(selectorNodes, animationNodes, opts) {
  302. opts = opts || {};
  303. var S = opts.newline ? "\n" : "";
  304. var bracketBegin = " {" + S;
  305. var bracketEnd = S + "}";
  306. var selectors = map(keys(selectorNodes), function(className) {
  307. return className + bracketBegin + map(keys(selectorNodes[className]), function(attrName) {
  308. return attrName + ":" + selectorNodes[className][attrName] + ";";
  309. }).join(S) + bracketEnd;
  310. }).join(S);
  311. var animations = map(keys(animationNodes), function(animationName) {
  312. return "@keyframes " + animationName + bracketBegin + map(keys(animationNodes[animationName]), function(percent) {
  313. return percent + bracketBegin + map(keys(animationNodes[animationName][percent]), function(attrName) {
  314. var val = animationNodes[animationName][percent][attrName];
  315. if (attrName === "d") {
  316. val = 'path("' + val + '")';
  317. }
  318. return attrName + ":" + val + ";";
  319. }).join(S) + bracketEnd;
  320. }).join(S) + bracketEnd;
  321. }).join(S);
  322. if (!selectors && !animations) {
  323. return "";
  324. }
  325. return ["<![CDATA[", selectors, animations, "]]>"].join(S);
  326. }
  327. function createBrushScope(zrId) {
  328. return {
  329. zrId,
  330. shadowCache: {},
  331. patternCache: {},
  332. gradientCache: {},
  333. clipPathCache: {},
  334. defs: {},
  335. cssNodes: {},
  336. cssAnims: {},
  337. cssClassIdx: 0,
  338. cssAnimIdx: 0,
  339. shadowIdx: 0,
  340. gradientIdx: 0,
  341. patternIdx: 0,
  342. clipPathIdx: 0
  343. };
  344. }
  345. function createSVGVNode(width, height, children, useViewBox) {
  346. return createVNode("svg", "root", {
  347. "width": width,
  348. "height": height,
  349. "xmlns": SVGNS,
  350. "xmlns:xlink": XLINKNS,
  351. "version": "1.1",
  352. "baseProfile": "full",
  353. "viewBox": useViewBox ? "0 0 " + width + " " + height : false
  354. }, children);
  355. }
  356. // node_modules/zrender/lib/svg/cssAnimation.js
  357. init_define_APP_INFO();
  358. var EASING_MAP = {
  359. cubicIn: "0.32,0,0.67,0",
  360. cubicOut: "0.33,1,0.68,1",
  361. cubicInOut: "0.65,0,0.35,1",
  362. quadraticIn: "0.11,0,0.5,0",
  363. quadraticOut: "0.5,1,0.89,1",
  364. quadraticInOut: "0.45,0,0.55,1",
  365. quarticIn: "0.5,0,0.75,0",
  366. quarticOut: "0.25,1,0.5,1",
  367. quarticInOut: "0.76,0,0.24,1",
  368. quinticIn: "0.64,0,0.78,0",
  369. quinticOut: "0.22,1,0.36,1",
  370. quinticInOut: "0.83,0,0.17,1",
  371. sinusoidalIn: "0.12,0,0.39,0",
  372. sinusoidalOut: "0.61,1,0.88,1",
  373. sinusoidalInOut: "0.37,0,0.63,1",
  374. exponentialIn: "0.7,0,0.84,0",
  375. exponentialOut: "0.16,1,0.3,1",
  376. exponentialInOut: "0.87,0,0.13,1",
  377. circularIn: "0.55,0,1,0.45",
  378. circularOut: "0,0.55,0.45,1",
  379. circularInOut: "0.85,0,0.15,1"
  380. };
  381. var transformOriginKey = "transform-origin";
  382. function buildPathString(el, kfShape, path) {
  383. var shape = extend({}, el.shape);
  384. extend(shape, kfShape);
  385. el.buildPath(path, shape);
  386. var svgPathBuilder = new SVGPathRebuilder_default();
  387. svgPathBuilder.reset(getPathPrecision(el));
  388. path.rebuildPath(svgPathBuilder, 1);
  389. svgPathBuilder.generateStr();
  390. return svgPathBuilder.getStr();
  391. }
  392. function setTransformOrigin(target, transform) {
  393. var originX = transform.originX, originY = transform.originY;
  394. if (originX || originY) {
  395. target[transformOriginKey] = originX + "px " + originY + "px";
  396. }
  397. }
  398. var ANIMATE_STYLE_MAP = {
  399. fill: "fill",
  400. opacity: "opacity",
  401. lineWidth: "stroke-width",
  402. lineDashOffset: "stroke-dashoffset"
  403. };
  404. function addAnimation(cssAnim, scope) {
  405. var animationName = scope.zrId + "-ani-" + scope.cssAnimIdx++;
  406. scope.cssAnims[animationName] = cssAnim;
  407. return animationName;
  408. }
  409. function createCompoundPathCSSAnimation(el, attrs, scope) {
  410. var paths = el.shape.paths;
  411. var composedAnim = {};
  412. var cssAnimationCfg;
  413. var cssAnimationName;
  414. each(paths, function(path) {
  415. var subScope = createBrushScope(scope.zrId);
  416. subScope.animation = true;
  417. createCSSAnimation(path, {}, subScope, true);
  418. var cssAnims = subScope.cssAnims;
  419. var cssNodes = subScope.cssNodes;
  420. var animNames = keys(cssAnims);
  421. var len = animNames.length;
  422. if (!len) {
  423. return;
  424. }
  425. cssAnimationName = animNames[len - 1];
  426. var lastAnim = cssAnims[cssAnimationName];
  427. for (var percent in lastAnim) {
  428. var kf = lastAnim[percent];
  429. composedAnim[percent] = composedAnim[percent] || { d: "" };
  430. composedAnim[percent].d += kf.d || "";
  431. }
  432. for (var className in cssNodes) {
  433. var val = cssNodes[className].animation;
  434. if (val.indexOf(cssAnimationName) >= 0) {
  435. cssAnimationCfg = val;
  436. }
  437. }
  438. });
  439. if (!cssAnimationCfg) {
  440. return;
  441. }
  442. attrs.d = false;
  443. var animationName = addAnimation(composedAnim, scope);
  444. return cssAnimationCfg.replace(cssAnimationName, animationName);
  445. }
  446. function getEasingFunc(easing) {
  447. return isString(easing) ? EASING_MAP[easing] ? "cubic-bezier(" + EASING_MAP[easing] + ")" : createCubicEasingFunc(easing) ? easing : "" : "";
  448. }
  449. function createCSSAnimation(el, attrs, scope, onlyShape) {
  450. var animators = el.animators;
  451. var len = animators.length;
  452. var cssAnimations = [];
  453. if (el instanceof CompoundPath_default) {
  454. var animationCfg = createCompoundPathCSSAnimation(el, attrs, scope);
  455. if (animationCfg) {
  456. cssAnimations.push(animationCfg);
  457. } else if (!len) {
  458. return;
  459. }
  460. } else if (!len) {
  461. return;
  462. }
  463. var groupAnimators = {};
  464. for (var i = 0; i < len; i++) {
  465. var animator = animators[i];
  466. var cfgArr = [animator.getMaxTime() / 1e3 + "s"];
  467. var easing = getEasingFunc(animator.getClip().easing);
  468. var delay = animator.getDelay();
  469. if (easing) {
  470. cfgArr.push(easing);
  471. } else {
  472. cfgArr.push("linear");
  473. }
  474. if (delay) {
  475. cfgArr.push(delay / 1e3 + "s");
  476. }
  477. if (animator.getLoop()) {
  478. cfgArr.push("infinite");
  479. }
  480. var cfg = cfgArr.join(" ");
  481. groupAnimators[cfg] = groupAnimators[cfg] || [cfg, []];
  482. groupAnimators[cfg][1].push(animator);
  483. }
  484. function createSingleCSSAnimation(groupAnimator) {
  485. var animators2 = groupAnimator[1];
  486. var len2 = animators2.length;
  487. var transformKfs = {};
  488. var shapeKfs = {};
  489. var finalKfs = {};
  490. var animationTimingFunctionAttrName = "animation-timing-function";
  491. function saveAnimatorTrackToCssKfs(animator3, cssKfs, toCssAttrName) {
  492. var tracks = animator3.getTracks();
  493. var maxTime = animator3.getMaxTime();
  494. for (var k = 0; k < tracks.length; k++) {
  495. var track = tracks[k];
  496. if (track.needsAnimate()) {
  497. var kfs = track.keyframes;
  498. var attrName = track.propName;
  499. toCssAttrName && (attrName = toCssAttrName(attrName));
  500. if (attrName) {
  501. for (var i3 = 0; i3 < kfs.length; i3++) {
  502. var kf = kfs[i3];
  503. var percent2 = Math.round(kf.time / maxTime * 100) + "%";
  504. var kfEasing = getEasingFunc(kf.easing);
  505. var rawValue = kf.rawValue;
  506. if (isString(rawValue) || isNumber(rawValue)) {
  507. cssKfs[percent2] = cssKfs[percent2] || {};
  508. cssKfs[percent2][attrName] = kf.rawValue;
  509. if (kfEasing) {
  510. cssKfs[percent2][animationTimingFunctionAttrName] = kfEasing;
  511. }
  512. }
  513. }
  514. }
  515. }
  516. }
  517. }
  518. for (var i2 = 0; i2 < len2; i2++) {
  519. var animator2 = animators2[i2];
  520. var targetProp = animator2.targetName;
  521. if (!targetProp) {
  522. !onlyShape && saveAnimatorTrackToCssKfs(animator2, transformKfs);
  523. } else if (targetProp === "shape") {
  524. saveAnimatorTrackToCssKfs(animator2, shapeKfs);
  525. }
  526. }
  527. for (var percent in transformKfs) {
  528. var transform = {};
  529. copyTransform(transform, el);
  530. extend(transform, transformKfs[percent]);
  531. var str = getSRTTransformString(transform);
  532. var timingFunction = transformKfs[percent][animationTimingFunctionAttrName];
  533. finalKfs[percent] = str ? {
  534. transform: str
  535. } : {};
  536. setTransformOrigin(finalKfs[percent], transform);
  537. if (timingFunction) {
  538. finalKfs[percent][animationTimingFunctionAttrName] = timingFunction;
  539. }
  540. }
  541. ;
  542. var path;
  543. var canAnimateShape = true;
  544. for (var percent in shapeKfs) {
  545. finalKfs[percent] = finalKfs[percent] || {};
  546. var isFirst = !path;
  547. var timingFunction = shapeKfs[percent][animationTimingFunctionAttrName];
  548. if (isFirst) {
  549. path = new PathProxy_default();
  550. }
  551. var len_1 = path.len();
  552. path.reset();
  553. finalKfs[percent].d = buildPathString(el, shapeKfs[percent], path);
  554. var newLen = path.len();
  555. if (!isFirst && len_1 !== newLen) {
  556. canAnimateShape = false;
  557. break;
  558. }
  559. if (timingFunction) {
  560. finalKfs[percent][animationTimingFunctionAttrName] = timingFunction;
  561. }
  562. }
  563. ;
  564. if (!canAnimateShape) {
  565. for (var percent in finalKfs) {
  566. delete finalKfs[percent].d;
  567. }
  568. }
  569. if (!onlyShape) {
  570. for (var i2 = 0; i2 < len2; i2++) {
  571. var animator2 = animators2[i2];
  572. var targetProp = animator2.targetName;
  573. if (targetProp === "style") {
  574. saveAnimatorTrackToCssKfs(animator2, finalKfs, function(propName) {
  575. return ANIMATE_STYLE_MAP[propName];
  576. });
  577. }
  578. }
  579. }
  580. var percents = keys(finalKfs);
  581. var allTransformOriginSame = true;
  582. var transformOrigin;
  583. for (var i2 = 1; i2 < percents.length; i2++) {
  584. var p0 = percents[i2 - 1];
  585. var p1 = percents[i2];
  586. if (finalKfs[p0][transformOriginKey] !== finalKfs[p1][transformOriginKey]) {
  587. allTransformOriginSame = false;
  588. break;
  589. }
  590. transformOrigin = finalKfs[p0][transformOriginKey];
  591. }
  592. if (allTransformOriginSame && transformOrigin) {
  593. for (var percent in finalKfs) {
  594. if (finalKfs[percent][transformOriginKey]) {
  595. delete finalKfs[percent][transformOriginKey];
  596. }
  597. }
  598. attrs[transformOriginKey] = transformOrigin;
  599. }
  600. if (filter(percents, function(percent2) {
  601. return keys(finalKfs[percent2]).length > 0;
  602. }).length) {
  603. var animationName = addAnimation(finalKfs, scope);
  604. return animationName + " " + groupAnimator[0] + " both";
  605. }
  606. }
  607. for (var key in groupAnimators) {
  608. var animationCfg = createSingleCSSAnimation(groupAnimators[key]);
  609. if (animationCfg) {
  610. cssAnimations.push(animationCfg);
  611. }
  612. }
  613. if (cssAnimations.length) {
  614. var className = scope.zrId + "-cls-" + scope.cssClassIdx++;
  615. scope.cssNodes["." + className] = {
  616. animation: cssAnimations.join(",")
  617. };
  618. attrs["class"] = className;
  619. }
  620. }
  621. // node_modules/zrender/lib/svg/graphic.js
  622. var round = Math.round;
  623. function isImageLike(val) {
  624. return val && isString(val.src);
  625. }
  626. function isCanvasLike(val) {
  627. return val && isFunction(val.toDataURL);
  628. }
  629. function setStyleAttrs(attrs, style, el, scope) {
  630. mapStyleToAttrs(function(key, val) {
  631. var isFillStroke = key === "fill" || key === "stroke";
  632. if (isFillStroke && isGradient(val)) {
  633. setGradient(style, attrs, key, scope);
  634. } else if (isFillStroke && isPattern(val)) {
  635. setPattern(el, attrs, key, scope);
  636. } else {
  637. attrs[key] = val;
  638. }
  639. }, style, el, false);
  640. setShadow(el, attrs, scope);
  641. }
  642. function noRotateScale(m) {
  643. return isAroundZero(m[0] - 1) && isAroundZero(m[1]) && isAroundZero(m[2]) && isAroundZero(m[3] - 1);
  644. }
  645. function noTranslate(m) {
  646. return isAroundZero(m[4]) && isAroundZero(m[5]);
  647. }
  648. function setTransform(attrs, m, compress) {
  649. if (m && !(noTranslate(m) && noRotateScale(m))) {
  650. var mul = compress ? 10 : 1e4;
  651. attrs.transform = noRotateScale(m) ? "translate(" + round(m[4] * mul) / mul + " " + round(m[5] * mul) / mul + ")" : getMatrixStr(m);
  652. }
  653. }
  654. function convertPolyShape(shape, attrs, mul) {
  655. var points = shape.points;
  656. var strArr = [];
  657. for (var i = 0; i < points.length; i++) {
  658. strArr.push(round(points[i][0] * mul) / mul);
  659. strArr.push(round(points[i][1] * mul) / mul);
  660. }
  661. attrs.points = strArr.join(" ");
  662. }
  663. function validatePolyShape(shape) {
  664. return !shape.smooth;
  665. }
  666. function createAttrsConvert(desc) {
  667. var normalizedDesc = map(desc, function(item) {
  668. return typeof item === "string" ? [item, item] : item;
  669. });
  670. return function(shape, attrs, mul) {
  671. for (var i = 0; i < normalizedDesc.length; i++) {
  672. var item = normalizedDesc[i];
  673. var val = shape[item[0]];
  674. if (val != null) {
  675. attrs[item[1]] = round(val * mul) / mul;
  676. }
  677. }
  678. };
  679. }
  680. var buitinShapesDef = {
  681. circle: [createAttrsConvert(["cx", "cy", "r"])],
  682. polyline: [convertPolyShape, validatePolyShape],
  683. polygon: [convertPolyShape, validatePolyShape]
  684. };
  685. function hasShapeAnimation(el) {
  686. var animators = el.animators;
  687. for (var i = 0; i < animators.length; i++) {
  688. if (animators[i].targetName === "shape") {
  689. return true;
  690. }
  691. }
  692. return false;
  693. }
  694. function brushSVGPath(el, scope) {
  695. var style = el.style;
  696. var shape = el.shape;
  697. var builtinShpDef = buitinShapesDef[el.type];
  698. var attrs = {};
  699. var needsAnimate = scope.animation;
  700. var svgElType = "path";
  701. var strokePercent = el.style.strokePercent;
  702. var precision = scope.compress && getPathPrecision(el) || 4;
  703. if (builtinShpDef && !scope.willUpdate && !(builtinShpDef[1] && !builtinShpDef[1](shape)) && !(needsAnimate && hasShapeAnimation(el)) && !(strokePercent < 1)) {
  704. svgElType = el.type;
  705. var mul = Math.pow(10, precision);
  706. builtinShpDef[0](shape, attrs, mul);
  707. } else {
  708. if (!el.path) {
  709. el.createPathProxy();
  710. }
  711. var path = el.path;
  712. if (el.shapeChanged()) {
  713. path.beginPath();
  714. el.buildPath(path, el.shape);
  715. el.pathUpdated();
  716. }
  717. var pathVersion = path.getVersion();
  718. var elExt = el;
  719. var svgPathBuilder = elExt.__svgPathBuilder;
  720. if (elExt.__svgPathVersion !== pathVersion || !svgPathBuilder || strokePercent !== elExt.__svgPathStrokePercent) {
  721. if (!svgPathBuilder) {
  722. svgPathBuilder = elExt.__svgPathBuilder = new SVGPathRebuilder_default();
  723. }
  724. svgPathBuilder.reset(precision);
  725. path.rebuildPath(svgPathBuilder, strokePercent);
  726. svgPathBuilder.generateStr();
  727. elExt.__svgPathVersion = pathVersion;
  728. elExt.__svgPathStrokePercent = strokePercent;
  729. }
  730. attrs.d = svgPathBuilder.getStr();
  731. }
  732. setTransform(attrs, el.transform);
  733. setStyleAttrs(attrs, style, el, scope);
  734. scope.animation && createCSSAnimation(el, attrs, scope);
  735. return createVNode(svgElType, el.id + "", attrs);
  736. }
  737. function brushSVGImage(el, scope) {
  738. var style = el.style;
  739. var image = style.image;
  740. if (image && !isString(image)) {
  741. if (isImageLike(image)) {
  742. image = image.src;
  743. } else if (isCanvasLike(image)) {
  744. image = image.toDataURL();
  745. }
  746. }
  747. if (!image) {
  748. return;
  749. }
  750. var x = style.x || 0;
  751. var y = style.y || 0;
  752. var dw = style.width;
  753. var dh = style.height;
  754. var attrs = {
  755. href: image,
  756. width: dw,
  757. height: dh
  758. };
  759. if (x) {
  760. attrs.x = x;
  761. }
  762. if (y) {
  763. attrs.y = y;
  764. }
  765. setTransform(attrs, el.transform);
  766. setStyleAttrs(attrs, style, el, scope);
  767. scope.animation && createCSSAnimation(el, attrs, scope);
  768. return createVNode("image", el.id + "", attrs);
  769. }
  770. function brushSVGTSpan(el, scope) {
  771. var style = el.style;
  772. var text = style.text;
  773. text != null && (text += "");
  774. if (!text || isNaN(style.x) || isNaN(style.y)) {
  775. return;
  776. }
  777. var font = style.font || DEFAULT_FONT;
  778. var x = style.x || 0;
  779. var y = adjustTextY(style.y || 0, getLineHeight(font), style.textBaseline);
  780. var textAlign = TEXT_ALIGN_TO_ANCHOR[style.textAlign] || style.textAlign;
  781. var attrs = {
  782. "dominant-baseline": "central",
  783. "text-anchor": textAlign
  784. };
  785. if (hasSeparateFont(style)) {
  786. var separatedFontStr = "";
  787. var fontStyle = style.fontStyle;
  788. var fontSize = parseFontSize(style.fontSize);
  789. if (!parseFloat(fontSize)) {
  790. return;
  791. }
  792. var fontFamily = style.fontFamily || DEFAULT_FONT_FAMILY;
  793. var fontWeight = style.fontWeight;
  794. separatedFontStr += "font-size:" + fontSize + ";font-family:" + fontFamily + ";";
  795. if (fontStyle && fontStyle !== "normal") {
  796. separatedFontStr += "font-style:" + fontStyle + ";";
  797. }
  798. if (fontWeight && fontWeight !== "normal") {
  799. separatedFontStr += "font-weight:" + fontWeight + ";";
  800. }
  801. attrs.style = separatedFontStr;
  802. } else {
  803. attrs.style = "font: " + font;
  804. }
  805. if (text.match(/\s/)) {
  806. attrs["xml:space"] = "preserve";
  807. }
  808. if (x) {
  809. attrs.x = x;
  810. }
  811. if (y) {
  812. attrs.y = y;
  813. }
  814. setTransform(attrs, el.transform);
  815. setStyleAttrs(attrs, style, el, scope);
  816. scope.animation && createCSSAnimation(el, attrs, scope);
  817. return createVNode("text", el.id + "", attrs, void 0, text);
  818. }
  819. function brush2(el, scope) {
  820. if (el instanceof Path_default) {
  821. return brushSVGPath(el, scope);
  822. } else if (el instanceof Image_default) {
  823. return brushSVGImage(el, scope);
  824. } else if (el instanceof TSpan_default) {
  825. return brushSVGTSpan(el, scope);
  826. }
  827. }
  828. function setShadow(el, attrs, scope) {
  829. var style = el.style;
  830. if (hasShadow(style)) {
  831. var shadowKey = getShadowKey(el);
  832. var shadowCache = scope.shadowCache;
  833. var shadowId = shadowCache[shadowKey];
  834. if (!shadowId) {
  835. var globalScale = el.getGlobalScale();
  836. var scaleX = globalScale[0];
  837. var scaleY = globalScale[1];
  838. if (!scaleX || !scaleY) {
  839. return;
  840. }
  841. var offsetX = style.shadowOffsetX || 0;
  842. var offsetY = style.shadowOffsetY || 0;
  843. var blur_1 = style.shadowBlur;
  844. var _a = normalizeColor(style.shadowColor), opacity = _a.opacity, color = _a.color;
  845. var stdDx = blur_1 / 2 / scaleX;
  846. var stdDy = blur_1 / 2 / scaleY;
  847. var stdDeviation = stdDx + " " + stdDy;
  848. shadowId = scope.zrId + "-s" + scope.shadowIdx++;
  849. scope.defs[shadowId] = createVNode("filter", shadowId, {
  850. "id": shadowId,
  851. "x": "-100%",
  852. "y": "-100%",
  853. "width": "300%",
  854. "height": "300%"
  855. }, [
  856. createVNode("feDropShadow", "", {
  857. "dx": offsetX / scaleX,
  858. "dy": offsetY / scaleY,
  859. "stdDeviation": stdDeviation,
  860. "flood-color": color,
  861. "flood-opacity": opacity
  862. })
  863. ]);
  864. shadowCache[shadowKey] = shadowId;
  865. }
  866. attrs.filter = getIdURL(shadowId);
  867. }
  868. }
  869. function setGradient(style, attrs, target, scope) {
  870. var val = style[target];
  871. var gradientTag;
  872. var gradientAttrs = {
  873. "gradientUnits": val.global ? "userSpaceOnUse" : "objectBoundingBox"
  874. };
  875. if (isLinearGradient(val)) {
  876. gradientTag = "linearGradient";
  877. gradientAttrs.x1 = val.x;
  878. gradientAttrs.y1 = val.y;
  879. gradientAttrs.x2 = val.x2;
  880. gradientAttrs.y2 = val.y2;
  881. } else if (isRadialGradient(val)) {
  882. gradientTag = "radialGradient";
  883. gradientAttrs.cx = retrieve2(val.x, 0.5);
  884. gradientAttrs.cy = retrieve2(val.y, 0.5);
  885. gradientAttrs.r = retrieve2(val.r, 0.5);
  886. } else {
  887. if (true) {
  888. logError("Illegal gradient type.");
  889. }
  890. return;
  891. }
  892. var colors = val.colorStops;
  893. var colorStops = [];
  894. for (var i = 0, len = colors.length; i < len; ++i) {
  895. var offset = round4(colors[i].offset) * 100 + "%";
  896. var stopColor = colors[i].color;
  897. var _a = normalizeColor(stopColor), color = _a.color, opacity = _a.opacity;
  898. var stopsAttrs = {
  899. "offset": offset
  900. };
  901. stopsAttrs["stop-color"] = color;
  902. if (opacity < 1) {
  903. stopsAttrs["stop-opacity"] = opacity;
  904. }
  905. colorStops.push(createVNode("stop", i + "", stopsAttrs));
  906. }
  907. var gradientVNode = createVNode(gradientTag, "", gradientAttrs, colorStops);
  908. var gradientKey = vNodeToString(gradientVNode);
  909. var gradientCache = scope.gradientCache;
  910. var gradientId = gradientCache[gradientKey];
  911. if (!gradientId) {
  912. gradientId = scope.zrId + "-g" + scope.gradientIdx++;
  913. gradientCache[gradientKey] = gradientId;
  914. gradientAttrs.id = gradientId;
  915. scope.defs[gradientId] = createVNode(gradientTag, gradientId, gradientAttrs, colorStops);
  916. }
  917. attrs[target] = getIdURL(gradientId);
  918. }
  919. function setPattern(el, attrs, target, scope) {
  920. var val = el.style[target];
  921. var patternAttrs = {
  922. "patternUnits": "userSpaceOnUse"
  923. };
  924. var child;
  925. if (isImagePattern(val)) {
  926. var imageWidth_1 = val.imageWidth;
  927. var imageHeight_1 = val.imageHeight;
  928. var imageSrc = void 0;
  929. var patternImage = val.image;
  930. if (isString(patternImage)) {
  931. imageSrc = patternImage;
  932. } else if (isImageLike(patternImage)) {
  933. imageSrc = patternImage.src;
  934. } else if (isCanvasLike(patternImage)) {
  935. imageSrc = patternImage.toDataURL();
  936. }
  937. if (typeof Image === "undefined") {
  938. var errMsg = "Image width/height must been given explictly in svg-ssr renderer.";
  939. assert(imageWidth_1, errMsg);
  940. assert(imageHeight_1, errMsg);
  941. } else if (imageWidth_1 == null || imageHeight_1 == null) {
  942. var setSizeToVNode_1 = function(vNode, img) {
  943. if (vNode) {
  944. var svgEl = vNode.elm;
  945. var width = vNode.attrs.width = imageWidth_1 || img.width;
  946. var height = vNode.attrs.height = imageHeight_1 || img.height;
  947. if (svgEl) {
  948. svgEl.setAttribute("width", width);
  949. svgEl.setAttribute("height", height);
  950. }
  951. }
  952. };
  953. var createdImage = createOrUpdateImage(imageSrc, null, el, function(img) {
  954. setSizeToVNode_1(patternVNode, img);
  955. setSizeToVNode_1(child, img);
  956. });
  957. if (createdImage && createdImage.width && createdImage.height) {
  958. imageWidth_1 = imageWidth_1 || createdImage.width;
  959. imageHeight_1 = imageHeight_1 || createdImage.height;
  960. }
  961. }
  962. child = createVNode("image", "img", {
  963. href: imageSrc,
  964. width: imageWidth_1,
  965. height: imageHeight_1
  966. });
  967. patternAttrs.width = imageWidth_1;
  968. patternAttrs.height = imageHeight_1;
  969. } else if (val.svgElement) {
  970. child = clone(val.svgElement);
  971. patternAttrs.width = val.svgWidth;
  972. patternAttrs.height = val.svgHeight;
  973. }
  974. if (!child) {
  975. return;
  976. }
  977. patternAttrs.patternTransform = getSRTTransformString(val);
  978. var patternVNode = createVNode("pattern", "", patternAttrs, [child]);
  979. var patternKey = vNodeToString(patternVNode);
  980. var patternCache = scope.patternCache;
  981. var patternId = patternCache[patternKey];
  982. if (!patternId) {
  983. patternId = scope.zrId + "-p" + scope.patternIdx++;
  984. patternCache[patternKey] = patternId;
  985. patternAttrs.id = patternId;
  986. patternVNode = scope.defs[patternId] = createVNode("pattern", patternId, patternAttrs, [child]);
  987. }
  988. attrs[target] = getIdURL(patternId);
  989. }
  990. function setClipPath(clipPath, attrs, scope) {
  991. var clipPathCache = scope.clipPathCache, defs = scope.defs;
  992. var clipPathId = clipPathCache[clipPath.id];
  993. if (!clipPathId) {
  994. clipPathId = scope.zrId + "-c" + scope.clipPathIdx++;
  995. var clipPathAttrs = {
  996. id: clipPathId
  997. };
  998. clipPathCache[clipPath.id] = clipPathId;
  999. defs[clipPathId] = createVNode("clipPath", clipPathId, clipPathAttrs, [brushSVGPath(clipPath, scope)]);
  1000. }
  1001. attrs["clip-path"] = getIdURL(clipPathId);
  1002. }
  1003. // node_modules/zrender/lib/svg/patch.js
  1004. init_define_APP_INFO();
  1005. // node_modules/zrender/lib/svg/domapi.js
  1006. init_define_APP_INFO();
  1007. function createTextNode(text) {
  1008. return document.createTextNode(text);
  1009. }
  1010. function insertBefore(parentNode2, newNode, referenceNode) {
  1011. parentNode2.insertBefore(newNode, referenceNode);
  1012. }
  1013. function removeChild(node, child) {
  1014. node.removeChild(child);
  1015. }
  1016. function appendChild(node, child) {
  1017. node.appendChild(child);
  1018. }
  1019. function parentNode(node) {
  1020. return node.parentNode;
  1021. }
  1022. function nextSibling(node) {
  1023. return node.nextSibling;
  1024. }
  1025. function setTextContent(node, text) {
  1026. node.textContent = text;
  1027. }
  1028. // node_modules/zrender/lib/svg/patch.js
  1029. var colonChar = 58;
  1030. var xChar = 120;
  1031. var emptyNode = createVNode("", "");
  1032. function isUndef(s) {
  1033. return s === void 0;
  1034. }
  1035. function isDef(s) {
  1036. return s !== void 0;
  1037. }
  1038. function createKeyToOldIdx(children, beginIdx, endIdx) {
  1039. var map2 = {};
  1040. for (var i = beginIdx; i <= endIdx; ++i) {
  1041. var key = children[i].key;
  1042. if (key !== void 0) {
  1043. if (true) {
  1044. if (map2[key] != null) {
  1045. console.error("Duplicate key " + key);
  1046. }
  1047. }
  1048. map2[key] = i;
  1049. }
  1050. }
  1051. return map2;
  1052. }
  1053. function sameVnode(vnode1, vnode2) {
  1054. var isSameKey = vnode1.key === vnode2.key;
  1055. var isSameTag = vnode1.tag === vnode2.tag;
  1056. return isSameTag && isSameKey;
  1057. }
  1058. function createElm(vnode) {
  1059. var i;
  1060. var children = vnode.children;
  1061. var tag = vnode.tag;
  1062. if (isDef(tag)) {
  1063. var elm = vnode.elm = createElement(tag);
  1064. updateAttrs(emptyNode, vnode);
  1065. if (isArray(children)) {
  1066. for (i = 0; i < children.length; ++i) {
  1067. var ch = children[i];
  1068. if (ch != null) {
  1069. appendChild(elm, createElm(ch));
  1070. }
  1071. }
  1072. } else if (isDef(vnode.text) && !isObject(vnode.text)) {
  1073. appendChild(elm, createTextNode(vnode.text));
  1074. }
  1075. } else {
  1076. vnode.elm = createTextNode(vnode.text);
  1077. }
  1078. return vnode.elm;
  1079. }
  1080. function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
  1081. for (; startIdx <= endIdx; ++startIdx) {
  1082. var ch = vnodes[startIdx];
  1083. if (ch != null) {
  1084. insertBefore(parentElm, createElm(ch), before);
  1085. }
  1086. }
  1087. }
  1088. function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
  1089. for (; startIdx <= endIdx; ++startIdx) {
  1090. var ch = vnodes[startIdx];
  1091. if (ch != null) {
  1092. if (isDef(ch.tag)) {
  1093. var parent_1 = parentNode(ch.elm);
  1094. removeChild(parent_1, ch.elm);
  1095. } else {
  1096. removeChild(parentElm, ch.elm);
  1097. }
  1098. }
  1099. }
  1100. }
  1101. function updateAttrs(oldVnode, vnode) {
  1102. var key;
  1103. var elm = vnode.elm;
  1104. var oldAttrs = oldVnode && oldVnode.attrs || {};
  1105. var attrs = vnode.attrs || {};
  1106. if (oldAttrs === attrs) {
  1107. return;
  1108. }
  1109. for (key in attrs) {
  1110. var cur = attrs[key];
  1111. var old = oldAttrs[key];
  1112. if (old !== cur) {
  1113. if (cur === true) {
  1114. elm.setAttribute(key, "");
  1115. } else if (cur === false) {
  1116. elm.removeAttribute(key);
  1117. } else {
  1118. if (key.charCodeAt(0) !== xChar) {
  1119. elm.setAttribute(key, cur);
  1120. } else if (key === "xmlns:xlink" || key === "xmlns") {
  1121. elm.setAttributeNS(XMLNS, key, cur);
  1122. } else if (key.charCodeAt(3) === colonChar) {
  1123. elm.setAttributeNS(XML_NAMESPACE, key, cur);
  1124. } else if (key.charCodeAt(5) === colonChar) {
  1125. elm.setAttributeNS(XLINKNS, key, cur);
  1126. } else {
  1127. elm.setAttribute(key, cur);
  1128. }
  1129. }
  1130. }
  1131. }
  1132. for (key in oldAttrs) {
  1133. if (!(key in attrs)) {
  1134. elm.removeAttribute(key);
  1135. }
  1136. }
  1137. }
  1138. function updateChildren(parentElm, oldCh, newCh) {
  1139. var oldStartIdx = 0;
  1140. var newStartIdx = 0;
  1141. var oldEndIdx = oldCh.length - 1;
  1142. var oldStartVnode = oldCh[0];
  1143. var oldEndVnode = oldCh[oldEndIdx];
  1144. var newEndIdx = newCh.length - 1;
  1145. var newStartVnode = newCh[0];
  1146. var newEndVnode = newCh[newEndIdx];
  1147. var oldKeyToIdx;
  1148. var idxInOld;
  1149. var elmToMove;
  1150. var before;
  1151. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  1152. if (oldStartVnode == null) {
  1153. oldStartVnode = oldCh[++oldStartIdx];
  1154. } else if (oldEndVnode == null) {
  1155. oldEndVnode = oldCh[--oldEndIdx];
  1156. } else if (newStartVnode == null) {
  1157. newStartVnode = newCh[++newStartIdx];
  1158. } else if (newEndVnode == null) {
  1159. newEndVnode = newCh[--newEndIdx];
  1160. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  1161. patchVnode(oldStartVnode, newStartVnode);
  1162. oldStartVnode = oldCh[++oldStartIdx];
  1163. newStartVnode = newCh[++newStartIdx];
  1164. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  1165. patchVnode(oldEndVnode, newEndVnode);
  1166. oldEndVnode = oldCh[--oldEndIdx];
  1167. newEndVnode = newCh[--newEndIdx];
  1168. } else if (sameVnode(oldStartVnode, newEndVnode)) {
  1169. patchVnode(oldStartVnode, newEndVnode);
  1170. insertBefore(parentElm, oldStartVnode.elm, nextSibling(oldEndVnode.elm));
  1171. oldStartVnode = oldCh[++oldStartIdx];
  1172. newEndVnode = newCh[--newEndIdx];
  1173. } else if (sameVnode(oldEndVnode, newStartVnode)) {
  1174. patchVnode(oldEndVnode, newStartVnode);
  1175. insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  1176. oldEndVnode = oldCh[--oldEndIdx];
  1177. newStartVnode = newCh[++newStartIdx];
  1178. } else {
  1179. if (isUndef(oldKeyToIdx)) {
  1180. oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
  1181. }
  1182. idxInOld = oldKeyToIdx[newStartVnode.key];
  1183. if (isUndef(idxInOld)) {
  1184. insertBefore(parentElm, createElm(newStartVnode), oldStartVnode.elm);
  1185. } else {
  1186. elmToMove = oldCh[idxInOld];
  1187. if (elmToMove.tag !== newStartVnode.tag) {
  1188. insertBefore(parentElm, createElm(newStartVnode), oldStartVnode.elm);
  1189. } else {
  1190. patchVnode(elmToMove, newStartVnode);
  1191. oldCh[idxInOld] = void 0;
  1192. insertBefore(parentElm, elmToMove.elm, oldStartVnode.elm);
  1193. }
  1194. }
  1195. newStartVnode = newCh[++newStartIdx];
  1196. }
  1197. }
  1198. if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
  1199. if (oldStartIdx > oldEndIdx) {
  1200. before = newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].elm;
  1201. addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
  1202. } else {
  1203. removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
  1204. }
  1205. }
  1206. }
  1207. function patchVnode(oldVnode, vnode) {
  1208. var elm = vnode.elm = oldVnode.elm;
  1209. var oldCh = oldVnode.children;
  1210. var ch = vnode.children;
  1211. if (oldVnode === vnode) {
  1212. return;
  1213. }
  1214. updateAttrs(oldVnode, vnode);
  1215. if (isUndef(vnode.text)) {
  1216. if (isDef(oldCh) && isDef(ch)) {
  1217. if (oldCh !== ch) {
  1218. updateChildren(elm, oldCh, ch);
  1219. }
  1220. } else if (isDef(ch)) {
  1221. if (isDef(oldVnode.text)) {
  1222. setTextContent(elm, "");
  1223. }
  1224. addVnodes(elm, null, ch, 0, ch.length - 1);
  1225. } else if (isDef(oldCh)) {
  1226. removeVnodes(elm, oldCh, 0, oldCh.length - 1);
  1227. } else if (isDef(oldVnode.text)) {
  1228. setTextContent(elm, "");
  1229. }
  1230. } else if (oldVnode.text !== vnode.text) {
  1231. if (isDef(oldCh)) {
  1232. removeVnodes(elm, oldCh, 0, oldCh.length - 1);
  1233. }
  1234. setTextContent(elm, vnode.text);
  1235. }
  1236. }
  1237. function patch(oldVnode, vnode) {
  1238. if (sameVnode(oldVnode, vnode)) {
  1239. patchVnode(oldVnode, vnode);
  1240. } else {
  1241. var elm = oldVnode.elm;
  1242. var parent_2 = parentNode(elm);
  1243. createElm(vnode);
  1244. if (parent_2 !== null) {
  1245. insertBefore(parent_2, vnode.elm, nextSibling(elm));
  1246. removeVnodes(parent_2, [oldVnode], 0, 0);
  1247. }
  1248. }
  1249. return vnode;
  1250. }
  1251. // node_modules/zrender/lib/svg/Painter.js
  1252. var svgId = 0;
  1253. var SVGPainter = function() {
  1254. function SVGPainter2(root, storage, opts) {
  1255. this.type = "svg";
  1256. this.refreshHover = createMethodNotSupport("refreshHover");
  1257. this.configLayer = createMethodNotSupport("configLayer");
  1258. this.storage = storage;
  1259. this._opts = opts = extend({}, opts);
  1260. this.root = root;
  1261. this._id = "zr" + svgId++;
  1262. this._oldVNode = createSVGVNode(opts.width, opts.height);
  1263. if (root && !opts.ssr) {
  1264. var viewport = this._viewport = document.createElement("div");
  1265. viewport.style.cssText = "position:relative;overflow:hidden";
  1266. var svgDom = this._svgDom = this._oldVNode.elm = createElement("svg");
  1267. updateAttrs(null, this._oldVNode);
  1268. viewport.appendChild(svgDom);
  1269. root.appendChild(viewport);
  1270. }
  1271. this.resize(opts.width, opts.height);
  1272. }
  1273. SVGPainter2.prototype.getType = function() {
  1274. return this.type;
  1275. };
  1276. SVGPainter2.prototype.getViewportRoot = function() {
  1277. return this._viewport;
  1278. };
  1279. SVGPainter2.prototype.getViewportRootOffset = function() {
  1280. var viewportRoot = this.getViewportRoot();
  1281. if (viewportRoot) {
  1282. return {
  1283. offsetLeft: viewportRoot.offsetLeft || 0,
  1284. offsetTop: viewportRoot.offsetTop || 0
  1285. };
  1286. }
  1287. };
  1288. SVGPainter2.prototype.getSvgDom = function() {
  1289. return this._svgDom;
  1290. };
  1291. SVGPainter2.prototype.refresh = function() {
  1292. if (this.root) {
  1293. var vnode = this.renderToVNode({
  1294. willUpdate: true
  1295. });
  1296. vnode.attrs.style = "position:absolute;left:0;top:0;user-select:none";
  1297. patch(this._oldVNode, vnode);
  1298. this._oldVNode = vnode;
  1299. }
  1300. };
  1301. SVGPainter2.prototype.renderOneToVNode = function(el) {
  1302. return brush2(el, createBrushScope(this._id));
  1303. };
  1304. SVGPainter2.prototype.renderToVNode = function(opts) {
  1305. opts = opts || {};
  1306. var list = this.storage.getDisplayList(true);
  1307. var bgColor = this._backgroundColor;
  1308. var width = this._width;
  1309. var height = this._height;
  1310. var scope = createBrushScope(this._id);
  1311. scope.animation = opts.animation;
  1312. scope.willUpdate = opts.willUpdate;
  1313. scope.compress = opts.compress;
  1314. var children = [];
  1315. if (bgColor && bgColor !== "none") {
  1316. var _a = normalizeColor(bgColor), color = _a.color, opacity = _a.opacity;
  1317. this._bgVNode = createVNode("rect", "bg", {
  1318. width,
  1319. height,
  1320. x: "0",
  1321. y: "0",
  1322. id: "0",
  1323. fill: color,
  1324. "fill-opacity": opacity
  1325. });
  1326. children.push(this._bgVNode);
  1327. } else {
  1328. this._bgVNode = null;
  1329. }
  1330. var mainVNode = !opts.compress ? this._mainVNode = createVNode("g", "main", {}, []) : null;
  1331. this._paintList(list, scope, mainVNode ? mainVNode.children : children);
  1332. mainVNode && children.push(mainVNode);
  1333. var defs = map(keys(scope.defs), function(id) {
  1334. return scope.defs[id];
  1335. });
  1336. if (defs.length) {
  1337. children.push(createVNode("defs", "defs", {}, defs));
  1338. }
  1339. if (opts.animation) {
  1340. var animationCssStr = getCssString(scope.cssNodes, scope.cssAnims, { newline: true });
  1341. if (animationCssStr) {
  1342. var styleNode = createVNode("style", "stl", {}, [], animationCssStr);
  1343. children.push(styleNode);
  1344. }
  1345. }
  1346. return createSVGVNode(width, height, children, opts.useViewBox);
  1347. };
  1348. SVGPainter2.prototype.renderToString = function(opts) {
  1349. opts = opts || {};
  1350. return vNodeToString(this.renderToVNode({
  1351. animation: retrieve2(opts.cssAnimation, true),
  1352. willUpdate: false,
  1353. compress: true,
  1354. useViewBox: retrieve2(opts.useViewBox, true)
  1355. }), { newline: true });
  1356. };
  1357. SVGPainter2.prototype.setBackgroundColor = function(backgroundColor) {
  1358. this._backgroundColor = backgroundColor;
  1359. var bgVNode = this._bgVNode;
  1360. if (bgVNode && bgVNode.elm) {
  1361. var _a = normalizeColor(backgroundColor), color = _a.color, opacity = _a.opacity;
  1362. bgVNode.elm.setAttribute("fill", color);
  1363. if (opacity < 1) {
  1364. bgVNode.elm.setAttribute("fill-opacity", opacity);
  1365. }
  1366. }
  1367. };
  1368. SVGPainter2.prototype.getSvgRoot = function() {
  1369. return this._mainVNode && this._mainVNode.elm;
  1370. };
  1371. SVGPainter2.prototype._paintList = function(list, scope, out) {
  1372. var listLen = list.length;
  1373. var clipPathsGroupsStack = [];
  1374. var clipPathsGroupsStackDepth = 0;
  1375. var currentClipPathGroup;
  1376. var prevClipPaths;
  1377. var clipGroupNodeIdx = 0;
  1378. for (var i = 0; i < listLen; i++) {
  1379. var displayable = list[i];
  1380. if (!displayable.invisible) {
  1381. var clipPaths = displayable.__clipPaths;
  1382. var len = clipPaths && clipPaths.length || 0;
  1383. var prevLen = prevClipPaths && prevClipPaths.length || 0;
  1384. var lca = void 0;
  1385. for (lca = Math.max(len - 1, prevLen - 1); lca >= 0; lca--) {
  1386. if (clipPaths && prevClipPaths && clipPaths[lca] === prevClipPaths[lca]) {
  1387. break;
  1388. }
  1389. }
  1390. for (var i_1 = prevLen - 1; i_1 > lca; i_1--) {
  1391. clipPathsGroupsStackDepth--;
  1392. currentClipPathGroup = clipPathsGroupsStack[clipPathsGroupsStackDepth - 1];
  1393. }
  1394. for (var i_2 = lca + 1; i_2 < len; i_2++) {
  1395. var groupAttrs = {};
  1396. setClipPath(clipPaths[i_2], groupAttrs, scope);
  1397. var g = createVNode("g", "clip-g-" + clipGroupNodeIdx++, groupAttrs, []);
  1398. (currentClipPathGroup ? currentClipPathGroup.children : out).push(g);
  1399. clipPathsGroupsStack[clipPathsGroupsStackDepth++] = g;
  1400. currentClipPathGroup = g;
  1401. }
  1402. prevClipPaths = clipPaths;
  1403. var ret = brush2(displayable, scope);
  1404. if (ret) {
  1405. (currentClipPathGroup ? currentClipPathGroup.children : out).push(ret);
  1406. }
  1407. }
  1408. }
  1409. };
  1410. SVGPainter2.prototype.resize = function(width, height) {
  1411. var opts = this._opts;
  1412. var root = this.root;
  1413. var viewport = this._viewport;
  1414. width != null && (opts.width = width);
  1415. height != null && (opts.height = height);
  1416. if (root && viewport) {
  1417. viewport.style.display = "none";
  1418. width = getSize(root, 0, opts);
  1419. height = getSize(root, 1, opts);
  1420. viewport.style.display = "";
  1421. }
  1422. if (this._width !== width || this._height !== height) {
  1423. this._width = width;
  1424. this._height = height;
  1425. if (viewport) {
  1426. var viewportStyle = viewport.style;
  1427. viewportStyle.width = width + "px";
  1428. viewportStyle.height = height + "px";
  1429. }
  1430. var svgDom = this._svgDom;
  1431. if (svgDom) {
  1432. svgDom.setAttribute("width", width);
  1433. svgDom.setAttribute("height", height);
  1434. }
  1435. }
  1436. };
  1437. SVGPainter2.prototype.getWidth = function() {
  1438. return this._width;
  1439. };
  1440. SVGPainter2.prototype.getHeight = function() {
  1441. return this._height;
  1442. };
  1443. SVGPainter2.prototype.dispose = function() {
  1444. if (this.root) {
  1445. this.root.innerHTML = "";
  1446. }
  1447. this._svgDom = this._viewport = this.storage = this._oldVNode = this._bgVNode = this._mainVNode = null;
  1448. };
  1449. SVGPainter2.prototype.clear = function() {
  1450. if (this._svgDom) {
  1451. this._svgDom.innerHTML = null;
  1452. }
  1453. this._oldVNode = null;
  1454. };
  1455. SVGPainter2.prototype.toDataURL = function(base64) {
  1456. var str = encodeURIComponent(this.renderToString());
  1457. var prefix = "data:image/svg+xml;";
  1458. if (base64) {
  1459. str = encodeBase64(str);
  1460. return str && prefix + "base64," + str;
  1461. }
  1462. return prefix + "charset=UTF-8," + str;
  1463. };
  1464. return SVGPainter2;
  1465. }();
  1466. function createMethodNotSupport(method) {
  1467. return function() {
  1468. if (true) {
  1469. logError('In SVG mode painter not support method "' + method + '"');
  1470. }
  1471. };
  1472. }
  1473. var Painter_default = SVGPainter;
  1474. // node_modules/echarts/lib/renderer/installSVGRenderer.js
  1475. function install(registers) {
  1476. registers.registerPainter("svg", Painter_default);
  1477. }
  1478. // node_modules/echarts/lib/renderer/installCanvasRenderer.js
  1479. init_define_APP_INFO();
  1480. // node_modules/zrender/lib/canvas/Painter.js
  1481. init_define_APP_INFO();
  1482. // node_modules/zrender/lib/canvas/Layer.js
  1483. init_define_APP_INFO();
  1484. function createDom(id, painter, dpr) {
  1485. var newDom = platformApi.createCanvas();
  1486. var width = painter.getWidth();
  1487. var height = painter.getHeight();
  1488. var newDomStyle = newDom.style;
  1489. if (newDomStyle) {
  1490. newDomStyle.position = "absolute";
  1491. newDomStyle.left = "0";
  1492. newDomStyle.top = "0";
  1493. newDomStyle.width = width + "px";
  1494. newDomStyle.height = height + "px";
  1495. newDom.setAttribute("data-zr-dom-id", id);
  1496. }
  1497. newDom.width = width * dpr;
  1498. newDom.height = height * dpr;
  1499. return newDom;
  1500. }
  1501. var Layer = function(_super) {
  1502. __extends(Layer2, _super);
  1503. function Layer2(id, painter, dpr) {
  1504. var _this = _super.call(this) || this;
  1505. _this.motionBlur = false;
  1506. _this.lastFrameAlpha = 0.7;
  1507. _this.dpr = 1;
  1508. _this.virtual = false;
  1509. _this.config = {};
  1510. _this.incremental = false;
  1511. _this.zlevel = 0;
  1512. _this.maxRepaintRectCount = 5;
  1513. _this.__dirty = true;
  1514. _this.__firstTimePaint = true;
  1515. _this.__used = false;
  1516. _this.__drawIndex = 0;
  1517. _this.__startIndex = 0;
  1518. _this.__endIndex = 0;
  1519. _this.__prevStartIndex = null;
  1520. _this.__prevEndIndex = null;
  1521. var dom;
  1522. dpr = dpr || devicePixelRatio;
  1523. if (typeof id === "string") {
  1524. dom = createDom(id, painter, dpr);
  1525. } else if (isObject(id)) {
  1526. dom = id;
  1527. id = dom.id;
  1528. }
  1529. _this.id = id;
  1530. _this.dom = dom;
  1531. var domStyle = dom.style;
  1532. if (domStyle) {
  1533. disableUserSelect(dom);
  1534. dom.onselectstart = function() {
  1535. return false;
  1536. };
  1537. domStyle.padding = "0";
  1538. domStyle.margin = "0";
  1539. domStyle.borderWidth = "0";
  1540. }
  1541. _this.painter = painter;
  1542. _this.dpr = dpr;
  1543. return _this;
  1544. }
  1545. Layer2.prototype.getElementCount = function() {
  1546. return this.__endIndex - this.__startIndex;
  1547. };
  1548. Layer2.prototype.afterBrush = function() {
  1549. this.__prevStartIndex = this.__startIndex;
  1550. this.__prevEndIndex = this.__endIndex;
  1551. };
  1552. Layer2.prototype.initContext = function() {
  1553. this.ctx = this.dom.getContext("2d");
  1554. this.ctx.dpr = this.dpr;
  1555. };
  1556. Layer2.prototype.setUnpainted = function() {
  1557. this.__firstTimePaint = true;
  1558. };
  1559. Layer2.prototype.createBackBuffer = function() {
  1560. var dpr = this.dpr;
  1561. this.domBack = createDom("back-" + this.id, this.painter, dpr);
  1562. this.ctxBack = this.domBack.getContext("2d");
  1563. if (dpr !== 1) {
  1564. this.ctxBack.scale(dpr, dpr);
  1565. }
  1566. };
  1567. Layer2.prototype.createRepaintRects = function(displayList, prevList, viewWidth, viewHeight) {
  1568. if (this.__firstTimePaint) {
  1569. this.__firstTimePaint = false;
  1570. return null;
  1571. }
  1572. var mergedRepaintRects = [];
  1573. var maxRepaintRectCount = this.maxRepaintRectCount;
  1574. var full = false;
  1575. var pendingRect = new BoundingRect_default(0, 0, 0, 0);
  1576. function addRectToMergePool(rect) {
  1577. if (!rect.isFinite() || rect.isZero()) {
  1578. return;
  1579. }
  1580. if (mergedRepaintRects.length === 0) {
  1581. var boundingRect = new BoundingRect_default(0, 0, 0, 0);
  1582. boundingRect.copy(rect);
  1583. mergedRepaintRects.push(boundingRect);
  1584. } else {
  1585. var isMerged = false;
  1586. var minDeltaArea = Infinity;
  1587. var bestRectToMergeIdx = 0;
  1588. for (var i2 = 0; i2 < mergedRepaintRects.length; ++i2) {
  1589. var mergedRect = mergedRepaintRects[i2];
  1590. if (mergedRect.intersect(rect)) {
  1591. var pendingRect_1 = new BoundingRect_default(0, 0, 0, 0);
  1592. pendingRect_1.copy(mergedRect);
  1593. pendingRect_1.union(rect);
  1594. mergedRepaintRects[i2] = pendingRect_1;
  1595. isMerged = true;
  1596. break;
  1597. } else if (full) {
  1598. pendingRect.copy(rect);
  1599. pendingRect.union(mergedRect);
  1600. var aArea = rect.width * rect.height;
  1601. var bArea = mergedRect.width * mergedRect.height;
  1602. var pendingArea = pendingRect.width * pendingRect.height;
  1603. var deltaArea = pendingArea - aArea - bArea;
  1604. if (deltaArea < minDeltaArea) {
  1605. minDeltaArea = deltaArea;
  1606. bestRectToMergeIdx = i2;
  1607. }
  1608. }
  1609. }
  1610. if (full) {
  1611. mergedRepaintRects[bestRectToMergeIdx].union(rect);
  1612. isMerged = true;
  1613. }
  1614. if (!isMerged) {
  1615. var boundingRect = new BoundingRect_default(0, 0, 0, 0);
  1616. boundingRect.copy(rect);
  1617. mergedRepaintRects.push(boundingRect);
  1618. }
  1619. if (!full) {
  1620. full = mergedRepaintRects.length >= maxRepaintRectCount;
  1621. }
  1622. }
  1623. }
  1624. for (var i = this.__startIndex; i < this.__endIndex; ++i) {
  1625. var el = displayList[i];
  1626. if (el) {
  1627. var shouldPaint = el.shouldBePainted(viewWidth, viewHeight, true, true);
  1628. var prevRect = el.__isRendered && (el.__dirty & REDRAW_BIT || !shouldPaint) ? el.getPrevPaintRect() : null;
  1629. if (prevRect) {
  1630. addRectToMergePool(prevRect);
  1631. }
  1632. var curRect = shouldPaint && (el.__dirty & REDRAW_BIT || !el.__isRendered) ? el.getPaintRect() : null;
  1633. if (curRect) {
  1634. addRectToMergePool(curRect);
  1635. }
  1636. }
  1637. }
  1638. for (var i = this.__prevStartIndex; i < this.__prevEndIndex; ++i) {
  1639. var el = prevList[i];
  1640. var shouldPaint = el.shouldBePainted(viewWidth, viewHeight, true, true);
  1641. if (el && (!shouldPaint || !el.__zr) && el.__isRendered) {
  1642. var prevRect = el.getPrevPaintRect();
  1643. if (prevRect) {
  1644. addRectToMergePool(prevRect);
  1645. }
  1646. }
  1647. }
  1648. var hasIntersections;
  1649. do {
  1650. hasIntersections = false;
  1651. for (var i = 0; i < mergedRepaintRects.length; ) {
  1652. if (mergedRepaintRects[i].isZero()) {
  1653. mergedRepaintRects.splice(i, 1);
  1654. continue;
  1655. }
  1656. for (var j = i + 1; j < mergedRepaintRects.length; ) {
  1657. if (mergedRepaintRects[i].intersect(mergedRepaintRects[j])) {
  1658. hasIntersections = true;
  1659. mergedRepaintRects[i].union(mergedRepaintRects[j]);
  1660. mergedRepaintRects.splice(j, 1);
  1661. } else {
  1662. j++;
  1663. }
  1664. }
  1665. i++;
  1666. }
  1667. } while (hasIntersections);
  1668. this._paintRects = mergedRepaintRects;
  1669. return mergedRepaintRects;
  1670. };
  1671. Layer2.prototype.debugGetPaintRects = function() {
  1672. return (this._paintRects || []).slice();
  1673. };
  1674. Layer2.prototype.resize = function(width, height) {
  1675. var dpr = this.dpr;
  1676. var dom = this.dom;
  1677. var domStyle = dom.style;
  1678. var domBack = this.domBack;
  1679. if (domStyle) {
  1680. domStyle.width = width + "px";
  1681. domStyle.height = height + "px";
  1682. }
  1683. dom.width = width * dpr;
  1684. dom.height = height * dpr;
  1685. if (domBack) {
  1686. domBack.width = width * dpr;
  1687. domBack.height = height * dpr;
  1688. if (dpr !== 1) {
  1689. this.ctxBack.scale(dpr, dpr);
  1690. }
  1691. }
  1692. };
  1693. Layer2.prototype.clear = function(clearAll, clearColor, repaintRects) {
  1694. var dom = this.dom;
  1695. var ctx = this.ctx;
  1696. var width = dom.width;
  1697. var height = dom.height;
  1698. clearColor = clearColor || this.clearColor;
  1699. var haveMotionBLur = this.motionBlur && !clearAll;
  1700. var lastFrameAlpha = this.lastFrameAlpha;
  1701. var dpr = this.dpr;
  1702. var self = this;
  1703. if (haveMotionBLur) {
  1704. if (!this.domBack) {
  1705. this.createBackBuffer();
  1706. }
  1707. this.ctxBack.globalCompositeOperation = "copy";
  1708. this.ctxBack.drawImage(dom, 0, 0, width / dpr, height / dpr);
  1709. }
  1710. var domBack = this.domBack;
  1711. function doClear(x, y, width2, height2) {
  1712. ctx.clearRect(x, y, width2, height2);
  1713. if (clearColor && clearColor !== "transparent") {
  1714. var clearColorGradientOrPattern = void 0;
  1715. if (isGradientObject(clearColor)) {
  1716. clearColorGradientOrPattern = clearColor.__canvasGradient || getCanvasGradient(ctx, clearColor, {
  1717. x: 0,
  1718. y: 0,
  1719. width: width2,
  1720. height: height2
  1721. });
  1722. clearColor.__canvasGradient = clearColorGradientOrPattern;
  1723. } else if (isImagePatternObject(clearColor)) {
  1724. clearColorGradientOrPattern = createCanvasPattern(ctx, clearColor, {
  1725. dirty: function() {
  1726. self.setUnpainted();
  1727. self.__painter.refresh();
  1728. }
  1729. });
  1730. }
  1731. ctx.save();
  1732. ctx.fillStyle = clearColorGradientOrPattern || clearColor;
  1733. ctx.fillRect(x, y, width2, height2);
  1734. ctx.restore();
  1735. }
  1736. if (haveMotionBLur) {
  1737. ctx.save();
  1738. ctx.globalAlpha = lastFrameAlpha;
  1739. ctx.drawImage(domBack, x, y, width2, height2);
  1740. ctx.restore();
  1741. }
  1742. }
  1743. ;
  1744. if (!repaintRects || haveMotionBLur) {
  1745. doClear(0, 0, width, height);
  1746. } else if (repaintRects.length) {
  1747. each(repaintRects, function(rect) {
  1748. doClear(rect.x * dpr, rect.y * dpr, rect.width * dpr, rect.height * dpr);
  1749. });
  1750. }
  1751. };
  1752. return Layer2;
  1753. }(Eventful_default);
  1754. var Layer_default = Layer;
  1755. // node_modules/zrender/lib/canvas/Painter.js
  1756. var HOVER_LAYER_ZLEVEL = 1e5;
  1757. var CANVAS_ZLEVEL = 314159;
  1758. var EL_AFTER_INCREMENTAL_INC = 0.01;
  1759. var INCREMENTAL_INC = 1e-3;
  1760. function isLayerValid(layer) {
  1761. if (!layer) {
  1762. return false;
  1763. }
  1764. if (layer.__builtin__) {
  1765. return true;
  1766. }
  1767. if (typeof layer.resize !== "function" || typeof layer.refresh !== "function") {
  1768. return false;
  1769. }
  1770. return true;
  1771. }
  1772. function createRoot(width, height) {
  1773. var domRoot = document.createElement("div");
  1774. domRoot.style.cssText = [
  1775. "position:relative",
  1776. "width:" + width + "px",
  1777. "height:" + height + "px",
  1778. "padding:0",
  1779. "margin:0",
  1780. "border-width:0"
  1781. ].join(";") + ";";
  1782. return domRoot;
  1783. }
  1784. var CanvasPainter = function() {
  1785. function CanvasPainter2(root, storage, opts, id) {
  1786. this.type = "canvas";
  1787. this._zlevelList = [];
  1788. this._prevDisplayList = [];
  1789. this._layers = {};
  1790. this._layerConfig = {};
  1791. this._needsManuallyCompositing = false;
  1792. this.type = "canvas";
  1793. var singleCanvas = !root.nodeName || root.nodeName.toUpperCase() === "CANVAS";
  1794. this._opts = opts = extend({}, opts || {});
  1795. this.dpr = opts.devicePixelRatio || devicePixelRatio;
  1796. this._singleCanvas = singleCanvas;
  1797. this.root = root;
  1798. var rootStyle = root.style;
  1799. if (rootStyle) {
  1800. disableUserSelect(root);
  1801. root.innerHTML = "";
  1802. }
  1803. this.storage = storage;
  1804. var zlevelList = this._zlevelList;
  1805. this._prevDisplayList = [];
  1806. var layers = this._layers;
  1807. if (!singleCanvas) {
  1808. this._width = getSize(root, 0, opts);
  1809. this._height = getSize(root, 1, opts);
  1810. var domRoot = this._domRoot = createRoot(this._width, this._height);
  1811. root.appendChild(domRoot);
  1812. } else {
  1813. var rootCanvas = root;
  1814. var width = rootCanvas.width;
  1815. var height = rootCanvas.height;
  1816. if (opts.width != null) {
  1817. width = opts.width;
  1818. }
  1819. if (opts.height != null) {
  1820. height = opts.height;
  1821. }
  1822. this.dpr = opts.devicePixelRatio || 1;
  1823. rootCanvas.width = width * this.dpr;
  1824. rootCanvas.height = height * this.dpr;
  1825. this._width = width;
  1826. this._height = height;
  1827. var mainLayer = new Layer_default(rootCanvas, this, this.dpr);
  1828. mainLayer.__builtin__ = true;
  1829. mainLayer.initContext();
  1830. layers[CANVAS_ZLEVEL] = mainLayer;
  1831. mainLayer.zlevel = CANVAS_ZLEVEL;
  1832. zlevelList.push(CANVAS_ZLEVEL);
  1833. this._domRoot = root;
  1834. }
  1835. }
  1836. CanvasPainter2.prototype.getType = function() {
  1837. return "canvas";
  1838. };
  1839. CanvasPainter2.prototype.isSingleCanvas = function() {
  1840. return this._singleCanvas;
  1841. };
  1842. CanvasPainter2.prototype.getViewportRoot = function() {
  1843. return this._domRoot;
  1844. };
  1845. CanvasPainter2.prototype.getViewportRootOffset = function() {
  1846. var viewportRoot = this.getViewportRoot();
  1847. if (viewportRoot) {
  1848. return {
  1849. offsetLeft: viewportRoot.offsetLeft || 0,
  1850. offsetTop: viewportRoot.offsetTop || 0
  1851. };
  1852. }
  1853. };
  1854. CanvasPainter2.prototype.refresh = function(paintAll) {
  1855. var list = this.storage.getDisplayList(true);
  1856. var prevList = this._prevDisplayList;
  1857. var zlevelList = this._zlevelList;
  1858. this._redrawId = Math.random();
  1859. this._paintList(list, prevList, paintAll, this._redrawId);
  1860. for (var i = 0; i < zlevelList.length; i++) {
  1861. var z = zlevelList[i];
  1862. var layer = this._layers[z];
  1863. if (!layer.__builtin__ && layer.refresh) {
  1864. var clearColor = i === 0 ? this._backgroundColor : null;
  1865. layer.refresh(clearColor);
  1866. }
  1867. }
  1868. if (this._opts.useDirtyRect) {
  1869. this._prevDisplayList = list.slice();
  1870. }
  1871. return this;
  1872. };
  1873. CanvasPainter2.prototype.refreshHover = function() {
  1874. this._paintHoverList(this.storage.getDisplayList(false));
  1875. };
  1876. CanvasPainter2.prototype._paintHoverList = function(list) {
  1877. var len = list.length;
  1878. var hoverLayer = this._hoverlayer;
  1879. hoverLayer && hoverLayer.clear();
  1880. if (!len) {
  1881. return;
  1882. }
  1883. var scope = {
  1884. inHover: true,
  1885. viewWidth: this._width,
  1886. viewHeight: this._height
  1887. };
  1888. var ctx;
  1889. for (var i = 0; i < len; i++) {
  1890. var el = list[i];
  1891. if (el.__inHover) {
  1892. if (!hoverLayer) {
  1893. hoverLayer = this._hoverlayer = this.getLayer(HOVER_LAYER_ZLEVEL);
  1894. }
  1895. if (!ctx) {
  1896. ctx = hoverLayer.ctx;
  1897. ctx.save();
  1898. }
  1899. brush(ctx, el, scope, i === len - 1);
  1900. }
  1901. }
  1902. if (ctx) {
  1903. ctx.restore();
  1904. }
  1905. };
  1906. CanvasPainter2.prototype.getHoverLayer = function() {
  1907. return this.getLayer(HOVER_LAYER_ZLEVEL);
  1908. };
  1909. CanvasPainter2.prototype.paintOne = function(ctx, el) {
  1910. brushSingle(ctx, el);
  1911. };
  1912. CanvasPainter2.prototype._paintList = function(list, prevList, paintAll, redrawId) {
  1913. if (this._redrawId !== redrawId) {
  1914. return;
  1915. }
  1916. paintAll = paintAll || false;
  1917. this._updateLayerStatus(list);
  1918. var _a = this._doPaintList(list, prevList, paintAll), finished = _a.finished, needsRefreshHover = _a.needsRefreshHover;
  1919. if (this._needsManuallyCompositing) {
  1920. this._compositeManually();
  1921. }
  1922. if (needsRefreshHover) {
  1923. this._paintHoverList(list);
  1924. }
  1925. if (!finished) {
  1926. var self_1 = this;
  1927. requestAnimationFrame_default(function() {
  1928. self_1._paintList(list, prevList, paintAll, redrawId);
  1929. });
  1930. } else {
  1931. this.eachLayer(function(layer) {
  1932. layer.afterBrush && layer.afterBrush();
  1933. });
  1934. }
  1935. };
  1936. CanvasPainter2.prototype._compositeManually = function() {
  1937. var ctx = this.getLayer(CANVAS_ZLEVEL).ctx;
  1938. var width = this._domRoot.width;
  1939. var height = this._domRoot.height;
  1940. ctx.clearRect(0, 0, width, height);
  1941. this.eachBuiltinLayer(function(layer) {
  1942. if (layer.virtual) {
  1943. ctx.drawImage(layer.dom, 0, 0, width, height);
  1944. }
  1945. });
  1946. };
  1947. CanvasPainter2.prototype._doPaintList = function(list, prevList, paintAll) {
  1948. var _this = this;
  1949. var layerList = [];
  1950. var useDirtyRect = this._opts.useDirtyRect;
  1951. for (var zi = 0; zi < this._zlevelList.length; zi++) {
  1952. var zlevel = this._zlevelList[zi];
  1953. var layer = this._layers[zlevel];
  1954. if (layer.__builtin__ && layer !== this._hoverlayer && (layer.__dirty || paintAll)) {
  1955. layerList.push(layer);
  1956. }
  1957. }
  1958. var finished = true;
  1959. var needsRefreshHover = false;
  1960. var _loop_1 = function(k2) {
  1961. var layer2 = layerList[k2];
  1962. var ctx = layer2.ctx;
  1963. var repaintRects = useDirtyRect && layer2.createRepaintRects(list, prevList, this_1._width, this_1._height);
  1964. var start = paintAll ? layer2.__startIndex : layer2.__drawIndex;
  1965. var useTimer = !paintAll && layer2.incremental && Date.now;
  1966. var startTime = useTimer && Date.now();
  1967. var clearColor = layer2.zlevel === this_1._zlevelList[0] ? this_1._backgroundColor : null;
  1968. if (layer2.__startIndex === layer2.__endIndex) {
  1969. layer2.clear(false, clearColor, repaintRects);
  1970. } else if (start === layer2.__startIndex) {
  1971. var firstEl = list[start];
  1972. if (!firstEl.incremental || !firstEl.notClear || paintAll) {
  1973. layer2.clear(false, clearColor, repaintRects);
  1974. }
  1975. }
  1976. if (start === -1) {
  1977. console.error("For some unknown reason. drawIndex is -1");
  1978. start = layer2.__startIndex;
  1979. }
  1980. var i;
  1981. var repaint = function(repaintRect) {
  1982. var scope = {
  1983. inHover: false,
  1984. allClipped: false,
  1985. prevEl: null,
  1986. viewWidth: _this._width,
  1987. viewHeight: _this._height
  1988. };
  1989. for (i = start; i < layer2.__endIndex; i++) {
  1990. var el = list[i];
  1991. if (el.__inHover) {
  1992. needsRefreshHover = true;
  1993. }
  1994. _this._doPaintEl(el, layer2, useDirtyRect, repaintRect, scope, i === layer2.__endIndex - 1);
  1995. if (useTimer) {
  1996. var dTime = Date.now() - startTime;
  1997. if (dTime > 15) {
  1998. break;
  1999. }
  2000. }
  2001. }
  2002. if (scope.prevElClipPaths) {
  2003. ctx.restore();
  2004. }
  2005. };
  2006. if (repaintRects) {
  2007. if (repaintRects.length === 0) {
  2008. i = layer2.__endIndex;
  2009. } else {
  2010. var dpr = this_1.dpr;
  2011. for (var r = 0; r < repaintRects.length; ++r) {
  2012. var rect = repaintRects[r];
  2013. ctx.save();
  2014. ctx.beginPath();
  2015. ctx.rect(rect.x * dpr, rect.y * dpr, rect.width * dpr, rect.height * dpr);
  2016. ctx.clip();
  2017. repaint(rect);
  2018. ctx.restore();
  2019. }
  2020. }
  2021. } else {
  2022. ctx.save();
  2023. repaint();
  2024. ctx.restore();
  2025. }
  2026. layer2.__drawIndex = i;
  2027. if (layer2.__drawIndex < layer2.__endIndex) {
  2028. finished = false;
  2029. }
  2030. };
  2031. var this_1 = this;
  2032. for (var k = 0; k < layerList.length; k++) {
  2033. _loop_1(k);
  2034. }
  2035. if (env_default.wxa) {
  2036. each(this._layers, function(layer2) {
  2037. if (layer2 && layer2.ctx && layer2.ctx.draw) {
  2038. layer2.ctx.draw();
  2039. }
  2040. });
  2041. }
  2042. return {
  2043. finished,
  2044. needsRefreshHover
  2045. };
  2046. };
  2047. CanvasPainter2.prototype._doPaintEl = function(el, currentLayer, useDirtyRect, repaintRect, scope, isLast) {
  2048. var ctx = currentLayer.ctx;
  2049. if (useDirtyRect) {
  2050. var paintRect = el.getPaintRect();
  2051. if (!repaintRect || paintRect && paintRect.intersect(repaintRect)) {
  2052. brush(ctx, el, scope, isLast);
  2053. el.setPrevPaintRect(paintRect);
  2054. }
  2055. } else {
  2056. brush(ctx, el, scope, isLast);
  2057. }
  2058. };
  2059. CanvasPainter2.prototype.getLayer = function(zlevel, virtual) {
  2060. if (this._singleCanvas && !this._needsManuallyCompositing) {
  2061. zlevel = CANVAS_ZLEVEL;
  2062. }
  2063. var layer = this._layers[zlevel];
  2064. if (!layer) {
  2065. layer = new Layer_default("zr_" + zlevel, this, this.dpr);
  2066. layer.zlevel = zlevel;
  2067. layer.__builtin__ = true;
  2068. if (this._layerConfig[zlevel]) {
  2069. merge(layer, this._layerConfig[zlevel], true);
  2070. } else if (this._layerConfig[zlevel - EL_AFTER_INCREMENTAL_INC]) {
  2071. merge(layer, this._layerConfig[zlevel - EL_AFTER_INCREMENTAL_INC], true);
  2072. }
  2073. if (virtual) {
  2074. layer.virtual = virtual;
  2075. }
  2076. this.insertLayer(zlevel, layer);
  2077. layer.initContext();
  2078. }
  2079. return layer;
  2080. };
  2081. CanvasPainter2.prototype.insertLayer = function(zlevel, layer) {
  2082. var layersMap = this._layers;
  2083. var zlevelList = this._zlevelList;
  2084. var len = zlevelList.length;
  2085. var domRoot = this._domRoot;
  2086. var prevLayer = null;
  2087. var i = -1;
  2088. if (layersMap[zlevel]) {
  2089. if (true) {
  2090. logError("ZLevel " + zlevel + " has been used already");
  2091. }
  2092. return;
  2093. }
  2094. if (!isLayerValid(layer)) {
  2095. if (true) {
  2096. logError("Layer of zlevel " + zlevel + " is not valid");
  2097. }
  2098. return;
  2099. }
  2100. if (len > 0 && zlevel > zlevelList[0]) {
  2101. for (i = 0; i < len - 1; i++) {
  2102. if (zlevelList[i] < zlevel && zlevelList[i + 1] > zlevel) {
  2103. break;
  2104. }
  2105. }
  2106. prevLayer = layersMap[zlevelList[i]];
  2107. }
  2108. zlevelList.splice(i + 1, 0, zlevel);
  2109. layersMap[zlevel] = layer;
  2110. if (!layer.virtual) {
  2111. if (prevLayer) {
  2112. var prevDom = prevLayer.dom;
  2113. if (prevDom.nextSibling) {
  2114. domRoot.insertBefore(layer.dom, prevDom.nextSibling);
  2115. } else {
  2116. domRoot.appendChild(layer.dom);
  2117. }
  2118. } else {
  2119. if (domRoot.firstChild) {
  2120. domRoot.insertBefore(layer.dom, domRoot.firstChild);
  2121. } else {
  2122. domRoot.appendChild(layer.dom);
  2123. }
  2124. }
  2125. }
  2126. layer.__painter = this;
  2127. };
  2128. CanvasPainter2.prototype.eachLayer = function(cb, context) {
  2129. var zlevelList = this._zlevelList;
  2130. for (var i = 0; i < zlevelList.length; i++) {
  2131. var z = zlevelList[i];
  2132. cb.call(context, this._layers[z], z);
  2133. }
  2134. };
  2135. CanvasPainter2.prototype.eachBuiltinLayer = function(cb, context) {
  2136. var zlevelList = this._zlevelList;
  2137. for (var i = 0; i < zlevelList.length; i++) {
  2138. var z = zlevelList[i];
  2139. var layer = this._layers[z];
  2140. if (layer.__builtin__) {
  2141. cb.call(context, layer, z);
  2142. }
  2143. }
  2144. };
  2145. CanvasPainter2.prototype.eachOtherLayer = function(cb, context) {
  2146. var zlevelList = this._zlevelList;
  2147. for (var i = 0; i < zlevelList.length; i++) {
  2148. var z = zlevelList[i];
  2149. var layer = this._layers[z];
  2150. if (!layer.__builtin__) {
  2151. cb.call(context, layer, z);
  2152. }
  2153. }
  2154. };
  2155. CanvasPainter2.prototype.getLayers = function() {
  2156. return this._layers;
  2157. };
  2158. CanvasPainter2.prototype._updateLayerStatus = function(list) {
  2159. this.eachBuiltinLayer(function(layer2, z) {
  2160. layer2.__dirty = layer2.__used = false;
  2161. });
  2162. function updatePrevLayer(idx) {
  2163. if (prevLayer) {
  2164. if (prevLayer.__endIndex !== idx) {
  2165. prevLayer.__dirty = true;
  2166. }
  2167. prevLayer.__endIndex = idx;
  2168. }
  2169. }
  2170. if (this._singleCanvas) {
  2171. for (var i_1 = 1; i_1 < list.length; i_1++) {
  2172. var el = list[i_1];
  2173. if (el.zlevel !== list[i_1 - 1].zlevel || el.incremental) {
  2174. this._needsManuallyCompositing = true;
  2175. break;
  2176. }
  2177. }
  2178. }
  2179. var prevLayer = null;
  2180. var incrementalLayerCount = 0;
  2181. var prevZlevel;
  2182. var i;
  2183. for (i = 0; i < list.length; i++) {
  2184. var el = list[i];
  2185. var zlevel = el.zlevel;
  2186. var layer = void 0;
  2187. if (prevZlevel !== zlevel) {
  2188. prevZlevel = zlevel;
  2189. incrementalLayerCount = 0;
  2190. }
  2191. if (el.incremental) {
  2192. layer = this.getLayer(zlevel + INCREMENTAL_INC, this._needsManuallyCompositing);
  2193. layer.incremental = true;
  2194. incrementalLayerCount = 1;
  2195. } else {
  2196. layer = this.getLayer(zlevel + (incrementalLayerCount > 0 ? EL_AFTER_INCREMENTAL_INC : 0), this._needsManuallyCompositing);
  2197. }
  2198. if (!layer.__builtin__) {
  2199. logError("ZLevel " + zlevel + " has been used by unkown layer " + layer.id);
  2200. }
  2201. if (layer !== prevLayer) {
  2202. layer.__used = true;
  2203. if (layer.__startIndex !== i) {
  2204. layer.__dirty = true;
  2205. }
  2206. layer.__startIndex = i;
  2207. if (!layer.incremental) {
  2208. layer.__drawIndex = i;
  2209. } else {
  2210. layer.__drawIndex = -1;
  2211. }
  2212. updatePrevLayer(i);
  2213. prevLayer = layer;
  2214. }
  2215. if (el.__dirty & REDRAW_BIT && !el.__inHover) {
  2216. layer.__dirty = true;
  2217. if (layer.incremental && layer.__drawIndex < 0) {
  2218. layer.__drawIndex = i;
  2219. }
  2220. }
  2221. }
  2222. updatePrevLayer(i);
  2223. this.eachBuiltinLayer(function(layer2, z) {
  2224. if (!layer2.__used && layer2.getElementCount() > 0) {
  2225. layer2.__dirty = true;
  2226. layer2.__startIndex = layer2.__endIndex = layer2.__drawIndex = 0;
  2227. }
  2228. if (layer2.__dirty && layer2.__drawIndex < 0) {
  2229. layer2.__drawIndex = layer2.__startIndex;
  2230. }
  2231. });
  2232. };
  2233. CanvasPainter2.prototype.clear = function() {
  2234. this.eachBuiltinLayer(this._clearLayer);
  2235. return this;
  2236. };
  2237. CanvasPainter2.prototype._clearLayer = function(layer) {
  2238. layer.clear();
  2239. };
  2240. CanvasPainter2.prototype.setBackgroundColor = function(backgroundColor) {
  2241. this._backgroundColor = backgroundColor;
  2242. each(this._layers, function(layer) {
  2243. layer.setUnpainted();
  2244. });
  2245. };
  2246. CanvasPainter2.prototype.configLayer = function(zlevel, config) {
  2247. if (config) {
  2248. var layerConfig = this._layerConfig;
  2249. if (!layerConfig[zlevel]) {
  2250. layerConfig[zlevel] = config;
  2251. } else {
  2252. merge(layerConfig[zlevel], config, true);
  2253. }
  2254. for (var i = 0; i < this._zlevelList.length; i++) {
  2255. var _zlevel = this._zlevelList[i];
  2256. if (_zlevel === zlevel || _zlevel === zlevel + EL_AFTER_INCREMENTAL_INC) {
  2257. var layer = this._layers[_zlevel];
  2258. merge(layer, layerConfig[zlevel], true);
  2259. }
  2260. }
  2261. }
  2262. };
  2263. CanvasPainter2.prototype.delLayer = function(zlevel) {
  2264. var layers = this._layers;
  2265. var zlevelList = this._zlevelList;
  2266. var layer = layers[zlevel];
  2267. if (!layer) {
  2268. return;
  2269. }
  2270. layer.dom.parentNode.removeChild(layer.dom);
  2271. delete layers[zlevel];
  2272. zlevelList.splice(indexOf(zlevelList, zlevel), 1);
  2273. };
  2274. CanvasPainter2.prototype.resize = function(width, height) {
  2275. if (!this._domRoot.style) {
  2276. if (width == null || height == null) {
  2277. return;
  2278. }
  2279. this._width = width;
  2280. this._height = height;
  2281. this.getLayer(CANVAS_ZLEVEL).resize(width, height);
  2282. } else {
  2283. var domRoot = this._domRoot;
  2284. domRoot.style.display = "none";
  2285. var opts = this._opts;
  2286. var root = this.root;
  2287. width != null && (opts.width = width);
  2288. height != null && (opts.height = height);
  2289. width = getSize(root, 0, opts);
  2290. height = getSize(root, 1, opts);
  2291. domRoot.style.display = "";
  2292. if (this._width !== width || height !== this._height) {
  2293. domRoot.style.width = width + "px";
  2294. domRoot.style.height = height + "px";
  2295. for (var id in this._layers) {
  2296. if (this._layers.hasOwnProperty(id)) {
  2297. this._layers[id].resize(width, height);
  2298. }
  2299. }
  2300. this.refresh(true);
  2301. }
  2302. this._width = width;
  2303. this._height = height;
  2304. }
  2305. return this;
  2306. };
  2307. CanvasPainter2.prototype.clearLayer = function(zlevel) {
  2308. var layer = this._layers[zlevel];
  2309. if (layer) {
  2310. layer.clear();
  2311. }
  2312. };
  2313. CanvasPainter2.prototype.dispose = function() {
  2314. this.root.innerHTML = "";
  2315. this.root = this.storage = this._domRoot = this._layers = null;
  2316. };
  2317. CanvasPainter2.prototype.getRenderedCanvas = function(opts) {
  2318. opts = opts || {};
  2319. if (this._singleCanvas && !this._compositeManually) {
  2320. return this._layers[CANVAS_ZLEVEL].dom;
  2321. }
  2322. var imageLayer = new Layer_default("image", this, opts.pixelRatio || this.dpr);
  2323. imageLayer.initContext();
  2324. imageLayer.clear(false, opts.backgroundColor || this._backgroundColor);
  2325. var ctx = imageLayer.ctx;
  2326. if (opts.pixelRatio <= this.dpr) {
  2327. this.refresh();
  2328. var width_1 = imageLayer.dom.width;
  2329. var height_1 = imageLayer.dom.height;
  2330. this.eachLayer(function(layer) {
  2331. if (layer.__builtin__) {
  2332. ctx.drawImage(layer.dom, 0, 0, width_1, height_1);
  2333. } else if (layer.renderToCanvas) {
  2334. ctx.save();
  2335. layer.renderToCanvas(ctx);
  2336. ctx.restore();
  2337. }
  2338. });
  2339. } else {
  2340. var scope = {
  2341. inHover: false,
  2342. viewWidth: this._width,
  2343. viewHeight: this._height
  2344. };
  2345. var displayList = this.storage.getDisplayList(true);
  2346. for (var i = 0, len = displayList.length; i < len; i++) {
  2347. var el = displayList[i];
  2348. brush(ctx, el, scope, i === len - 1);
  2349. }
  2350. }
  2351. return imageLayer.dom;
  2352. };
  2353. CanvasPainter2.prototype.getWidth = function() {
  2354. return this._width;
  2355. };
  2356. CanvasPainter2.prototype.getHeight = function() {
  2357. return this._height;
  2358. };
  2359. return CanvasPainter2;
  2360. }();
  2361. var Painter_default2 = CanvasPainter;
  2362. // node_modules/echarts/lib/renderer/installCanvasRenderer.js
  2363. function install2(registers) {
  2364. registers.registerPainter("canvas", Painter_default2);
  2365. }
  2366. export {
  2367. install2 as CanvasRenderer,
  2368. install as SVGRenderer
  2369. };
  2370. //# sourceMappingURL=echarts_renderers.js.map