Oldie.js 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239
  1. /* *
  2. *
  3. * (c) 2010-2020 Torstein Honsi
  4. *
  5. * License: www.highcharts.com/license
  6. *
  7. * Support for old IE browsers (6, 7 and 8) in Highcharts v6+.
  8. *
  9. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  10. *
  11. * */
  12. 'use strict';
  13. import Chart from '../Core/Chart/Chart.js';
  14. import Color from '../Core/Color.js';
  15. var color = Color.parse;
  16. import H from '../Core/Globals.js';
  17. var deg2rad = H.deg2rad, doc = H.doc, noop = H.noop, svg = H.svg, win = H.win;
  18. import Pointer from '../Core/Pointer.js';
  19. import SVGElement from '../Core/Renderer/SVG/SVGElement.js';
  20. import SVGRenderer from '../Core/Renderer/SVG/SVGRenderer.js';
  21. import U from '../Core/Utilities.js';
  22. var addEvent = U.addEvent, createElement = U.createElement, css = U.css, defined = U.defined, discardElement = U.discardElement, erase = U.erase, extend = U.extend, extendClass = U.extendClass, getOptions = U.getOptions, isArray = U.isArray, isNumber = U.isNumber, isObject = U.isObject, merge = U.merge, offset = U.offset, pick = U.pick, pInt = U.pInt, uniqueKey = U.uniqueKey;
  23. var VMLRenderer, VMLRendererExtension, VMLElement;
  24. /**
  25. * Path to the pattern image required by VML browsers in order to
  26. * draw radial gradients.
  27. *
  28. * @type {string}
  29. * @default http://code.highcharts.com/{version}/gfx/vml-radial-gradient.png
  30. * @since 2.3.0
  31. * @requires modules/oldie
  32. * @apioption global.VMLRadialGradientURL
  33. */
  34. getOptions().global.VMLRadialGradientURL =
  35. 'http://code.highcharts.com/8.2.0/gfx/vml-radial-gradient.png';
  36. // Utilites
  37. if (doc && !doc.defaultView) {
  38. H.getStyle = U.getStyle = function (el, prop) {
  39. var val, alias = {
  40. width: 'clientWidth',
  41. height: 'clientHeight'
  42. }[prop];
  43. if (el.style[prop]) {
  44. return pInt(el.style[prop]);
  45. }
  46. if (prop === 'opacity') {
  47. prop = 'filter';
  48. }
  49. // Getting the rendered width and height
  50. if (alias) {
  51. el.style.zoom = 1;
  52. return Math.max(el[alias] - 2 * U.getStyle(el, 'padding'), 0);
  53. }
  54. val = el.currentStyle[prop.replace(/\-(\w)/g, function (a, b) {
  55. return b.toUpperCase();
  56. })];
  57. if (prop === 'filter') {
  58. val = val.replace(/alpha\(opacity=([0-9]+)\)/, function (a, b) {
  59. return (b / 100);
  60. });
  61. }
  62. return val === '' ? 1 : pInt(val);
  63. };
  64. }
  65. /* eslint-disable no-invalid-this, valid-jsdoc */
  66. if (!svg) {
  67. // Prevent wrapping from creating false offsetWidths in export in legacy IE.
  68. // This applies only to charts for export, where IE runs the SVGRenderer
  69. // instead of the VMLRenderer
  70. // (#1079, #1063)
  71. addEvent(SVGElement, 'afterInit', function () {
  72. if (this.element.nodeName === 'text') {
  73. this.css({
  74. position: 'absolute'
  75. });
  76. }
  77. });
  78. /**
  79. * Old IE override for pointer normalize, adds chartX and chartY to event
  80. * arguments.
  81. *
  82. * @ignore
  83. * @function Highcharts.Pointer#normalize
  84. * @param {global.PointerEvent} e
  85. * @param {boolean} [chartPosition=false]
  86. * @return {Highcharts.PointerEventObject}
  87. */
  88. Pointer.prototype.normalize = function (e, chartPosition) {
  89. e = e || win.event;
  90. if (!e.target) {
  91. e.target = e.srcElement;
  92. }
  93. // Get mouse position
  94. if (!chartPosition) {
  95. this.chartPosition = chartPosition = offset(this.chart.container);
  96. }
  97. return extend(e, {
  98. // #2005, #2129: the second case is for IE10 quirks mode within
  99. // framesets
  100. chartX: Math.round(Math.max(e.x, e.clientX - chartPosition.left)),
  101. chartY: Math.round(e.y)
  102. });
  103. };
  104. /**
  105. * Further sanitize the mock-SVG that is generated when exporting charts in
  106. * oldIE.
  107. *
  108. * @private
  109. * @function Highcharts.Chart#ieSanitizeSVG
  110. */
  111. Chart.prototype.ieSanitizeSVG = function (svg) {
  112. svg = svg
  113. .replace(/<IMG /g, '<image ')
  114. .replace(/<(\/?)TITLE>/g, '<$1title>')
  115. .replace(/height=([^" ]+)/g, 'height="$1"')
  116. .replace(/width=([^" ]+)/g, 'width="$1"')
  117. .replace(/hc-svg-href="([^"]+)">/g, 'xlink:href="$1"/>')
  118. .replace(/ id=([^" >]+)/g, ' id="$1"') // #4003
  119. .replace(/class=([^" >]+)/g, 'class="$1"')
  120. .replace(/ transform /g, ' ')
  121. .replace(/:(path|rect)/g, '$1')
  122. .replace(/style="([^"]+)"/g, function (s) {
  123. return s.toLowerCase();
  124. });
  125. return svg;
  126. };
  127. /**
  128. * VML namespaces can't be added until after complete. Listening
  129. * for Perini's doScroll hack is not enough.
  130. *
  131. * @private
  132. * @function Highcharts.Chart#isReadyToRender
  133. */
  134. Chart.prototype.isReadyToRender = function () {
  135. var chart = this;
  136. // Note: win == win.top is required
  137. if (!svg &&
  138. (win == win.top && // eslint-disable-line eqeqeq
  139. doc.readyState !== 'complete')) {
  140. doc.attachEvent('onreadystatechange', function () {
  141. doc.detachEvent('onreadystatechange', chart.firstRender);
  142. if (doc.readyState === 'complete') {
  143. chart.firstRender();
  144. }
  145. });
  146. return false;
  147. }
  148. return true;
  149. };
  150. // IE compatibility hack for generating SVG content that it doesn't really
  151. // understand. Used by the exporting module.
  152. if (!doc.createElementNS) {
  153. doc.createElementNS = function (ns, tagName) {
  154. return doc.createElement(tagName);
  155. };
  156. }
  157. /**
  158. * Old IE polyfill for addEventListener, called from inside the addEvent
  159. * function.
  160. *
  161. * @private
  162. * @function Highcharts.addEventListenerPolyfill<T>
  163. * @param {string} type
  164. * @param {Highcharts.EventCallbackFunction<T>} fn
  165. * @return {void}
  166. */
  167. H.addEventListenerPolyfill = function (type, fn) {
  168. var el = this;
  169. /**
  170. * @private
  171. */
  172. function wrappedFn(e) {
  173. e.target = e.srcElement || win; // #2820
  174. fn.call(el, e);
  175. }
  176. if (el.attachEvent) {
  177. if (!el.hcEventsIE) {
  178. el.hcEventsIE = {};
  179. }
  180. // unique function string (#6746)
  181. if (!fn.hcKey) {
  182. fn.hcKey = uniqueKey();
  183. }
  184. // Link wrapped fn with original fn, so we can get this in
  185. // removeEvent
  186. el.hcEventsIE[fn.hcKey] = wrappedFn;
  187. el.attachEvent('on' + type, wrappedFn);
  188. }
  189. };
  190. /**
  191. * @private
  192. * @function Highcharts.removeEventListenerPolyfill<T>
  193. * @param {string} type
  194. * @param {Highcharts.EventCallbackFunction<T>} fn
  195. * @return {void}
  196. */
  197. H.removeEventListenerPolyfill = function (type, fn) {
  198. if (this.detachEvent) {
  199. fn = this.hcEventsIE[fn.hcKey];
  200. this.detachEvent('on' + type, fn);
  201. }
  202. };
  203. /**
  204. * The VML element wrapper.
  205. *
  206. * @private
  207. * @class
  208. * @name Highcharts.VMLElement
  209. *
  210. * @augments Highcharts.SVGElement
  211. */
  212. VMLElement = {
  213. docMode8: doc && doc.documentMode === 8,
  214. /**
  215. * Initialize a new VML element wrapper. It builds the markup as a
  216. * string to minimize DOM traffic.
  217. *
  218. * @function Highcharts.VMLElement#init
  219. * @param {Highcharts.VMLRenderer} renderer
  220. * @param {string} nodeName
  221. */
  222. init: function (renderer, nodeName) {
  223. var wrapper = this, markup = ['<', nodeName, ' filled="f" stroked="f"'], style = ['position: ', 'absolute', ';'], isDiv = nodeName === 'div';
  224. // divs and shapes need size
  225. if (nodeName === 'shape' || isDiv) {
  226. style.push('left:0;top:0;width:1px;height:1px;');
  227. }
  228. style.push('visibility: ', isDiv ? 'hidden' : 'visible');
  229. markup.push(' style="', style.join(''), '"/>');
  230. // create element with default attributes and style
  231. if (nodeName) {
  232. markup = isDiv || nodeName === 'span' || nodeName === 'img' ?
  233. markup.join('') :
  234. renderer.prepVML(markup);
  235. wrapper.element = createElement(markup);
  236. }
  237. wrapper.renderer = renderer;
  238. },
  239. /**
  240. * Add the node to the given parent
  241. *
  242. * @function Highcharts.VMLElement
  243. * @param {Highcharts.VMLElement} parent
  244. * @return {Highcharts.VMLElement}
  245. */
  246. add: function (parent) {
  247. var wrapper = this, renderer = wrapper.renderer, element = wrapper.element, box = renderer.box, inverted = parent && parent.inverted,
  248. // get the parent node
  249. parentNode = parent ?
  250. parent.element || parent :
  251. box;
  252. if (parent) {
  253. this.parentGroup = parent;
  254. }
  255. // if the parent group is inverted, apply inversion on all children
  256. if (inverted) { // only on groups
  257. renderer.invertChild(element, parentNode);
  258. }
  259. // append it
  260. parentNode.appendChild(element);
  261. // align text after adding to be able to read offset
  262. wrapper.added = true;
  263. if (wrapper.alignOnAdd && !wrapper.deferUpdateTransform) {
  264. wrapper.updateTransform();
  265. }
  266. // fire an event for internal hooks
  267. if (wrapper.onAdd) {
  268. wrapper.onAdd();
  269. }
  270. // IE8 Standards can't set the class name before the element is
  271. // appended
  272. if (this.className) {
  273. this.attr('class', this.className);
  274. }
  275. return wrapper;
  276. },
  277. /**
  278. * VML always uses htmlUpdateTransform
  279. *
  280. * @function Highcharts.VMLElement#updateTransform
  281. */
  282. updateTransform: SVGElement.prototype.htmlUpdateTransform,
  283. /**
  284. * Set the rotation of a span with oldIE's filter
  285. *
  286. * @function Highcharts.VMLElement#setSpanRotation
  287. * @return {void}
  288. */
  289. setSpanRotation: function () {
  290. // Adjust for alignment and rotation. Rotation of useHTML content is
  291. // not yet implemented but it can probably be implemented for
  292. // Firefox 3.5+ on user request. FF3.5+ has support for CSS3
  293. // transform. The getBBox method also needs to be updated to
  294. // compensate for the rotation, like it currently does for SVG.
  295. // Test case: https://jsfiddle.net/highcharts/Ybt44/
  296. var rotation = this.rotation, costheta = Math.cos(rotation * deg2rad), sintheta = Math.sin(rotation * deg2rad);
  297. css(this.element, {
  298. filter: rotation ? [
  299. 'progid:DXImageTransform.Microsoft.Matrix(M11=', costheta,
  300. ', M12=', -sintheta, ', M21=', sintheta, ', M22=', costheta,
  301. ', sizingMethod=\'auto expand\')'
  302. ].join('') : 'none'
  303. });
  304. },
  305. /**
  306. * Get the positioning correction for the span after rotating.
  307. *
  308. * @function Highcharts.VMLElement#getSpanCorrection
  309. */
  310. getSpanCorrection: function (width, baseline, alignCorrection, rotation, align) {
  311. var costheta = rotation ? Math.cos(rotation * deg2rad) : 1, sintheta = rotation ? Math.sin(rotation * deg2rad) : 0, height = pick(this.elemHeight, this.element.offsetHeight), quad, nonLeft = align && align !== 'left';
  312. // correct x and y
  313. this.xCorr = (costheta < 0 && -width);
  314. this.yCorr = (sintheta < 0 && -height);
  315. // correct for baseline and corners spilling out after rotation
  316. quad = costheta * sintheta < 0;
  317. this.xCorr += (sintheta *
  318. baseline *
  319. (quad ? 1 - alignCorrection : alignCorrection));
  320. this.yCorr -= (costheta *
  321. baseline *
  322. (rotation ? (quad ? alignCorrection : 1 - alignCorrection) : 1));
  323. // correct for the length/height of the text
  324. if (nonLeft) {
  325. this.xCorr -=
  326. width * alignCorrection * (costheta < 0 ? -1 : 1);
  327. if (rotation) {
  328. this.yCorr -= (height *
  329. alignCorrection *
  330. (sintheta < 0 ? -1 : 1));
  331. }
  332. css(this.element, {
  333. textAlign: align
  334. });
  335. }
  336. },
  337. /**
  338. * Converts a subset of an SVG path definition to its VML counterpart.
  339. * Takes an array as the parameter and returns a string.
  340. *
  341. * @function Highcharts.VMLElement#pathToVML
  342. */
  343. pathToVML: function (value) {
  344. // convert paths
  345. var i = value.length, path = [];
  346. while (i--) {
  347. // Multiply by 10 to allow subpixel precision.
  348. // Substracting half a pixel seems to make the coordinates
  349. // align with SVG, but this hasn't been tested thoroughly
  350. if (isNumber(value[i])) {
  351. path[i] = Math.round(value[i] * 10) - 5;
  352. }
  353. else if (value[i] === 'Z') { // close the path
  354. path[i] = 'x';
  355. }
  356. else {
  357. path[i] = value[i];
  358. // When the start X and end X coordinates of an arc are too
  359. // close, they are rounded to the same value above. In this
  360. // case, substract or add 1 from the end X and Y positions.
  361. // #186, #760, #1371, #1410.
  362. if (value.isArc &&
  363. (value[i] === 'wa' || value[i] === 'at')) {
  364. // Start and end X
  365. if (path[i + 5] === path[i + 7]) {
  366. path[i + 7] +=
  367. value[i + 7] > value[i + 5] ? 1 : -1;
  368. }
  369. // Start and end Y
  370. if (path[i + 6] === path[i + 8]) {
  371. path[i + 8] +=
  372. value[i + 8] > value[i + 6] ? 1 : -1;
  373. }
  374. }
  375. }
  376. }
  377. return path.join(' ') || 'x';
  378. },
  379. /**
  380. * Set the element's clipping to a predefined rectangle
  381. *
  382. * @function Highcharts.VMLElement#clip
  383. * @param {Highcharts.VMLClipRectObject} clipRect
  384. * @return {Highcharts.VMLElement}
  385. */
  386. clip: function (clipRect) {
  387. var wrapper = this, clipMembers, cssRet;
  388. if (clipRect) {
  389. clipMembers = clipRect.members;
  390. // Ensure unique list of elements (#1258)
  391. erase(clipMembers, wrapper);
  392. clipMembers.push(wrapper);
  393. wrapper.destroyClip = function () {
  394. erase(clipMembers, wrapper);
  395. };
  396. cssRet = clipRect.getCSS(wrapper);
  397. }
  398. else {
  399. if (wrapper.destroyClip) {
  400. wrapper.destroyClip();
  401. }
  402. cssRet = {
  403. clip: wrapper.docMode8 ? 'inherit' : 'rect(auto)'
  404. }; // #1214
  405. }
  406. return wrapper.css(cssRet);
  407. },
  408. /**
  409. * Set styles for the element
  410. *
  411. * @function Highcharts.VMLElement#css
  412. * @param {Highcharts.CSSObject} styles
  413. * @return {Highcharts.VMLElement}
  414. */
  415. css: SVGElement.prototype.htmlCss,
  416. /**
  417. * Removes a child either by removeChild or move to garbageBin.
  418. * Issue 490; in VML removeChild results in Orphaned nodes according to
  419. * sIEve, discardElement does not.
  420. *
  421. * @function Highcharts.VMLElement#safeRemoveChild
  422. * @param {Highcharts.HTMLDOMElement} element
  423. * @return {void}
  424. */
  425. safeRemoveChild: function (element) {
  426. // discardElement will detach the node from its parent before
  427. // attaching it to the garbage bin. Therefore it is important that
  428. // the node is attached and have parent.
  429. if (element.parentNode) {
  430. discardElement(element);
  431. }
  432. },
  433. /**
  434. * Extend element.destroy by removing it from the clip members array
  435. *
  436. * @function Highcharts.VMLElement#destroy
  437. */
  438. destroy: function () {
  439. if (this.destroyClip) {
  440. this.destroyClip();
  441. }
  442. return SVGElement.prototype.destroy.apply(this);
  443. },
  444. /**
  445. * Add an event listener. VML override for normalizing event parameters.
  446. *
  447. * @function Highcharts.VMLElement#on
  448. * @param {string} eventType
  449. * @param {Function} handler
  450. * @return {Highcharts.VMLElement}
  451. */
  452. on: function (eventType, handler) {
  453. // simplest possible event model for internal use
  454. this.element['on' + eventType] = function () {
  455. var e = win.event;
  456. e.target = e.srcElement;
  457. handler(e);
  458. };
  459. return this;
  460. },
  461. /**
  462. * In stacked columns, cut off the shadows so that they don't overlap
  463. *
  464. * @function Highcharts.VMLElement#cutOffPath
  465. * @param {string} path
  466. * @param {number} length
  467. * @return {string}
  468. */
  469. cutOffPath: function (path, length) {
  470. var len;
  471. // The extra comma tricks the trailing comma remover in
  472. // "gulp scripts" task
  473. path = path.split(/[ ,]/);
  474. len = path.length;
  475. if (len === 9 || len === 11) {
  476. path[len - 4] = path[len - 2] =
  477. pInt(path[len - 2]) - 10 * length;
  478. }
  479. return path.join(' ');
  480. },
  481. /**
  482. * Apply a drop shadow by copying elements and giving them different
  483. * strokes.
  484. *
  485. * @function Highcharts.VMLElement#shadow
  486. * @param {Highcharts.ShadowOptionsObject} shadowOptions
  487. * @param {Highcharts.VMLElement} group
  488. * @param {boolean} cutOff
  489. * @return {Highcharts.VMLElement}
  490. */
  491. shadow: function (shadowOptions, group, cutOff) {
  492. var shadows = [], i, element = this.element, renderer = this.renderer, shadow, elemStyle = element.style, markup, path = element.path, strokeWidth, modifiedPath, shadowWidth, shadowElementOpacity;
  493. // some times empty paths are not strings
  494. if (path && typeof path.value !== 'string') {
  495. path = 'x';
  496. }
  497. modifiedPath = path;
  498. if (shadowOptions) {
  499. shadowWidth = pick(shadowOptions.width, 3);
  500. shadowElementOpacity =
  501. (shadowOptions.opacity || 0.15) / shadowWidth;
  502. for (i = 1; i <= 3; i++) {
  503. strokeWidth = (shadowWidth * 2) + 1 - (2 * i);
  504. // Cut off shadows for stacked column items
  505. if (cutOff) {
  506. modifiedPath = this.cutOffPath(path.value, strokeWidth + 0.5);
  507. }
  508. markup = [
  509. '<shape isShadow="true" strokeweight="', strokeWidth,
  510. '" filled="false" path="', modifiedPath,
  511. '" coordsize="10 10" style="', element.style.cssText,
  512. '" />'
  513. ];
  514. shadow = createElement(renderer.prepVML(markup), null, {
  515. left: pInt(elemStyle.left) +
  516. pick(shadowOptions.offsetX, 1),
  517. top: pInt(elemStyle.top) +
  518. pick(shadowOptions.offsetY, 1)
  519. });
  520. if (cutOff) {
  521. shadow.cutOff = strokeWidth + 1;
  522. }
  523. // apply the opacity
  524. markup = [
  525. '<stroke color="',
  526. shadowOptions.color || '#000000',
  527. '" opacity="', shadowElementOpacity * i, '"/>'
  528. ];
  529. createElement(renderer.prepVML(markup), null, null, shadow);
  530. // insert it
  531. if (group) {
  532. group.element.appendChild(shadow);
  533. }
  534. else {
  535. element.parentNode
  536. .insertBefore(shadow, element);
  537. }
  538. // record it
  539. shadows.push(shadow);
  540. }
  541. this.shadows = shadows;
  542. }
  543. return this;
  544. },
  545. updateShadows: noop,
  546. setAttr: function (key, value) {
  547. if (this.docMode8) { // IE8 setAttribute bug
  548. this.element[key] = value;
  549. }
  550. else {
  551. this.element.setAttribute(key, value);
  552. }
  553. },
  554. getAttr: function (key) {
  555. if (this.docMode8) { // IE8 setAttribute bug
  556. return this.element[key];
  557. }
  558. return this.element.getAttribute(key);
  559. },
  560. classSetter: function (value) {
  561. // IE8 Standards mode has problems retrieving the className unless
  562. // set like this. IE8 Standards can't set the class name before the
  563. // element is appended.
  564. (this.added ? this.element : this).className = value;
  565. },
  566. dashstyleSetter: function (value, key, element) {
  567. var strokeElem = element.getElementsByTagName('stroke')[0] ||
  568. createElement(this.renderer.prepVML(['<stroke/>']), null, null, element);
  569. strokeElem[key] = value || 'solid';
  570. // Because changing stroke-width will change the dash length and
  571. // cause an epileptic effect
  572. this[key] = value;
  573. },
  574. dSetter: function (value, key, element) {
  575. var i, shadows = this.shadows;
  576. value = value || [];
  577. // Used in getter for animation
  578. this.d = value.join && value.join(' ');
  579. element.path = value = this.pathToVML(value);
  580. // update shadows
  581. if (shadows) {
  582. i = shadows.length;
  583. while (i--) {
  584. shadows[i].path = shadows[i].cutOff ?
  585. this.cutOffPath(value, shadows[i].cutOff) :
  586. value;
  587. }
  588. }
  589. this.setAttr(key, value);
  590. },
  591. fillSetter: function (value, key, element) {
  592. var nodeName = element.nodeName;
  593. if (nodeName === 'SPAN') { // text color
  594. element.style.color = value;
  595. }
  596. else if (nodeName !== 'IMG') { // #1336
  597. element.filled = value !== 'none';
  598. this.setAttr('fillcolor', this.renderer.color(value, element, key, this));
  599. }
  600. },
  601. 'fill-opacitySetter': function (value, key, element) {
  602. createElement(this.renderer.prepVML(['<', key.split('-')[0], ' opacity="', value, '"/>']), null, null, element);
  603. },
  604. // Don't bother - animation is too slow and filters introduce artifacts
  605. opacitySetter: noop,
  606. rotationSetter: function (value, key, element) {
  607. var style = element.style;
  608. // style is for #1873:
  609. this[key] = style[key] = value;
  610. // Correction for the 1x1 size of the shape container. Used in gauge
  611. // needles.
  612. style.left =
  613. -Math.round(Math.sin(value * deg2rad) + 1) + 'px';
  614. style.top =
  615. Math.round(Math.cos(value * deg2rad)) + 'px';
  616. },
  617. strokeSetter: function (value, key, element) {
  618. this.setAttr('strokecolor', this.renderer.color(value, element, key, this));
  619. },
  620. 'stroke-widthSetter': function (value, key, element) {
  621. element.stroked = !!value; // VML "stroked" attribute
  622. this[key] = value; // used in getter, issue #113
  623. if (isNumber(value)) {
  624. value += 'px';
  625. }
  626. this.setAttr('strokeweight', value);
  627. },
  628. titleSetter: function (value, key) {
  629. this.setAttr(key, value);
  630. },
  631. visibilitySetter: function (value, key, element) {
  632. // Handle inherited visibility
  633. if (value === 'inherit') {
  634. value = 'visible';
  635. }
  636. // Let the shadow follow the main element
  637. if (this.shadows) {
  638. this.shadows.forEach(function (shadow) {
  639. shadow.style[key] = value;
  640. });
  641. }
  642. // Instead of toggling the visibility CSS property, move the div out
  643. // of the viewport. This works around #61 and #586
  644. if (element.nodeName === 'DIV') {
  645. value = value === 'hidden' ? '-999em' : 0;
  646. // In order to redraw, IE7 needs the div to be visible when
  647. // tucked away outside the viewport. So the visibility is
  648. // actually opposite of the expected value. This applies to the
  649. // tooltip only.
  650. if (!this.docMode8) {
  651. element.style[key] = value ? 'visible' : 'hidden';
  652. }
  653. key = 'top';
  654. }
  655. element.style[key] = value;
  656. },
  657. xSetter: function (value, key, element) {
  658. this[key] = value; // used in getter
  659. if (key === 'x') {
  660. key = 'left';
  661. }
  662. else if (key === 'y') {
  663. key = 'top';
  664. }
  665. // clipping rectangle special
  666. if (this.updateClipping) {
  667. // the key is now 'left' or 'top' for 'x' and 'y'
  668. this[key] = value;
  669. this.updateClipping();
  670. }
  671. else {
  672. // normal
  673. element.style[key] = value;
  674. }
  675. },
  676. zIndexSetter: function (value, key, element) {
  677. element.style[key] = value;
  678. },
  679. fillGetter: function () {
  680. return this.getAttr('fillcolor') || '';
  681. },
  682. strokeGetter: function () {
  683. return this.getAttr('strokecolor') || '';
  684. },
  685. // #7850
  686. classGetter: function () {
  687. return this.getAttr('className') || '';
  688. }
  689. };
  690. VMLElement['stroke-opacitySetter'] =
  691. VMLElement['fill-opacitySetter'];
  692. H.VMLElement = VMLElement = extendClass(SVGElement, VMLElement);
  693. // Some shared setters
  694. VMLElement.prototype.ySetter =
  695. VMLElement.prototype.widthSetter =
  696. VMLElement.prototype.heightSetter =
  697. VMLElement.prototype.xSetter;
  698. /**
  699. * The VML renderer
  700. *
  701. * @private
  702. * @class
  703. * @name Highcharts.VMLRenderer
  704. *
  705. * @augments Highcharts.SVGRenderer
  706. */
  707. VMLRendererExtension = {
  708. Element: VMLElement,
  709. isIE8: win.navigator.userAgent.indexOf('MSIE 8.0') > -1,
  710. /**
  711. * Initialize the VMLRenderer.
  712. *
  713. * @function Highcharts.VMLRenderer#init
  714. * @param {Highcharts.HTMLDOMElement} container
  715. * @param {number} width
  716. * @param {number} height
  717. * @return {void}
  718. */
  719. init: function (container, width, height) {
  720. var renderer = this, boxWrapper, box, css;
  721. // Extended SVGRenderer member
  722. this.crispPolyLine = SVGRenderer.prototype.crispPolyLine;
  723. renderer.alignedObjects = [];
  724. boxWrapper = renderer.createElement('div')
  725. .css({ position: 'relative' });
  726. box = boxWrapper.element;
  727. container.appendChild(boxWrapper.element);
  728. // generate the containing box
  729. renderer.isVML = true;
  730. renderer.box = box;
  731. renderer.boxWrapper = boxWrapper;
  732. renderer.gradients = {};
  733. renderer.cache = {}; // Cache for numerical bounding boxes
  734. renderer.cacheKeys = [];
  735. renderer.imgCount = 0;
  736. renderer.setSize(width, height, false);
  737. // The only way to make IE6 and IE7 print is to use a global
  738. // namespace. However, with IE8 the only way to make the dynamic
  739. // shapes visible in screen and print mode seems to be to add the
  740. // xmlns attribute and the behaviour style inline.
  741. if (!doc.namespaces.hcv) {
  742. doc.namespaces.add('hcv', 'urn:schemas-microsoft-com:vml');
  743. // Setup default CSS (#2153, #2368, #2384)
  744. css = 'hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke' +
  745. '{ behavior:url(#default#VML); display: inline-block; } ';
  746. try {
  747. doc.createStyleSheet().cssText = css;
  748. }
  749. catch (e) {
  750. doc.styleSheets[0].cssText += css;
  751. }
  752. }
  753. },
  754. /**
  755. * Detect whether the renderer is hidden. This happens when one of the
  756. * parent elements has display: none
  757. *
  758. * @function Highcharts.VMLRenderer#isHidden
  759. */
  760. isHidden: function () {
  761. return !this.box.offsetWidth;
  762. },
  763. /**
  764. * Define a clipping rectangle. In VML it is accomplished by storing the
  765. * values for setting the CSS style to all associated members.
  766. *
  767. * @function Highcharts.VMLRenderer#clipRect
  768. * @param {number|Highcharts.SizeObject} x
  769. * @param {number} y
  770. * @param {number} width
  771. * @param {number} height
  772. * @return {Highcharts.VMLElement}
  773. */
  774. clipRect: function (x, y, width, height) {
  775. // create a dummy element
  776. var clipRect = this.createElement(), isObj = isObject(x);
  777. // mimic a rectangle with its style object for automatic updating in
  778. // attr
  779. return extend(clipRect, {
  780. members: [],
  781. count: 0,
  782. left: (isObj ? x.x : x) + 1,
  783. top: (isObj ? x.y : y) + 1,
  784. width: (isObj ? x.width : width) - 1,
  785. height: (isObj ? x.height : height) - 1,
  786. getCSS: function (wrapper) {
  787. var element = wrapper.element, nodeName = element.nodeName, isShape = nodeName === 'shape', inverted = wrapper.inverted, rect = this, top = rect.top - (isShape ? element.offsetTop : 0), left = rect.left, right = left + rect.width, bottom = top + rect.height, ret = {
  788. clip: 'rect(' +
  789. Math.round(inverted ? left : top) + 'px,' +
  790. Math.round(inverted ? bottom : right) + 'px,' +
  791. Math.round(inverted ? right : bottom) + 'px,' +
  792. Math.round(inverted ? top : left) + 'px)'
  793. };
  794. // issue 74 workaround
  795. if (!inverted && wrapper.docMode8 && nodeName === 'DIV') {
  796. extend(ret, {
  797. width: right + 'px',
  798. height: bottom + 'px'
  799. });
  800. }
  801. return ret;
  802. },
  803. // used in attr and animation to update the clipping of all
  804. // members
  805. updateClipping: function () {
  806. clipRect.members.forEach(function (member) {
  807. // Member.element is falsy on deleted series, like in
  808. // stock/members/series-remove demo. Should be removed
  809. // from members, but this will do.
  810. if (member.element) {
  811. member.css(clipRect.getCSS(member));
  812. }
  813. });
  814. }
  815. });
  816. },
  817. /**
  818. * Take a color and return it if it's a string, make it a gradient if
  819. * it's a gradient configuration object, and apply opacity.
  820. *
  821. * @function Highcharts.VMLRenderer#color<T>
  822. *
  823. * @param {T} color
  824. * The color or config object
  825. *
  826. * @return {T}
  827. */
  828. color: function (colorOption, elem, prop, wrapper) {
  829. var renderer = this, colorObject, regexRgba = /^rgba/, markup, fillType, ret = 'none';
  830. // Check for linear or radial gradient
  831. if (colorOption &&
  832. colorOption.linearGradient) {
  833. fillType = 'gradient';
  834. }
  835. else if (colorOption &&
  836. colorOption.radialGradient) {
  837. fillType = 'pattern';
  838. }
  839. if (fillType) {
  840. var stopColor, stopOpacity, gradient = (colorOption.linearGradient ||
  841. colorOption.radialGradient), x1, y1, x2, y2, opacity1, opacity2, color1, color2, fillAttr = '', stops = colorOption.stops, firstStop, lastStop, colors = [], addFillNode = function () {
  842. // Add the fill subnode. When colors attribute is used,
  843. // the meanings of opacity and o:opacity2 are reversed.
  844. markup = ['<fill colors="' + colors.join(',') +
  845. '" opacity="', opacity2, '" o:opacity2="',
  846. opacity1, '" type="', fillType, '" ', fillAttr,
  847. 'focus="100%" method="any" />'];
  848. createElement(renderer.prepVML(markup), null, null, elem);
  849. };
  850. // Extend from 0 to 1
  851. firstStop = stops[0];
  852. lastStop = stops[stops.length - 1];
  853. if (firstStop[0] > 0) {
  854. stops.unshift([
  855. 0,
  856. firstStop[1]
  857. ]);
  858. }
  859. if (lastStop[0] < 1) {
  860. stops.push([
  861. 1,
  862. lastStop[1]
  863. ]);
  864. }
  865. // Compute the stops
  866. stops.forEach(function (stop, i) {
  867. if (regexRgba.test(stop[1])) {
  868. colorObject = color(stop[1]);
  869. stopColor = colorObject.get('rgb');
  870. stopOpacity = colorObject.get('a');
  871. }
  872. else {
  873. stopColor = stop[1];
  874. stopOpacity = 1;
  875. }
  876. // Build the color attribute
  877. colors.push((stop[0] * 100) + '% ' + stopColor);
  878. // Only start and end opacities are allowed, so we use the
  879. // first and the last
  880. if (!i) {
  881. opacity1 = stopOpacity;
  882. color2 = stopColor;
  883. }
  884. else {
  885. opacity2 = stopOpacity;
  886. color1 = stopColor;
  887. }
  888. });
  889. // Apply the gradient to fills only.
  890. if (prop === 'fill') {
  891. // Handle linear gradient angle
  892. if (fillType === 'gradient') {
  893. x1 = gradient.x1 || gradient[0] || 0;
  894. y1 = gradient.y1 || gradient[1] || 0;
  895. x2 = gradient.x2 || gradient[2] || 0;
  896. y2 = gradient.y2 || gradient[3] || 0;
  897. fillAttr = 'angle="' + (90 - Math.atan((y2 - y1) / // y vector
  898. (x2 - x1) // x vector
  899. ) * 180 / Math.PI) + '"';
  900. addFillNode();
  901. // Radial (circular) gradient
  902. }
  903. else {
  904. var r = gradient.r, sizex = r * 2, sizey = r * 2, cx = gradient.cx, cy = gradient.cy, radialReference = elem.radialReference, bBox, applyRadialGradient = function () {
  905. if (radialReference) {
  906. bBox = wrapper.getBBox();
  907. cx += (radialReference[0] - bBox.x) /
  908. bBox.width - 0.5;
  909. cy += (radialReference[1] - bBox.y) /
  910. bBox.height - 0.5;
  911. sizex *= radialReference[2] / bBox.width;
  912. sizey *= radialReference[2] / bBox.height;
  913. }
  914. fillAttr =
  915. 'src="' + getOptions().global.VMLRadialGradientURL +
  916. '" ' +
  917. 'size="' + sizex + ',' + sizey + '" ' +
  918. 'origin="0.5,0.5" ' +
  919. 'position="' + cx + ',' + cy + '" ' +
  920. 'color2="' + color2 + '" ';
  921. addFillNode();
  922. };
  923. // Apply radial gradient
  924. if (wrapper.added) {
  925. applyRadialGradient();
  926. }
  927. else {
  928. // We need to know the bounding box to get the size
  929. // and position right
  930. wrapper.onAdd = applyRadialGradient;
  931. }
  932. // The fill element's color attribute is broken in IE8
  933. // standards mode, so we need to set the parent shape's
  934. // fillcolor attribute instead.
  935. ret = color1;
  936. }
  937. // Gradients are not supported for VML stroke, return the first
  938. // color. #722.
  939. }
  940. else {
  941. ret = stopColor;
  942. }
  943. // If the color is an rgba color, split it and add a fill node
  944. // to hold the opacity component
  945. }
  946. else if (regexRgba.test(colorOption) && elem.tagName !== 'IMG') {
  947. colorObject = color(colorOption);
  948. wrapper[prop + '-opacitySetter'](colorObject.get('a'), prop, elem);
  949. ret = colorObject.get('rgb');
  950. }
  951. else {
  952. // 'stroke' or 'fill' node
  953. var propNodes = elem.getElementsByTagName(prop);
  954. if (propNodes.length) {
  955. propNodes[0].opacity = 1;
  956. propNodes[0].type = 'solid';
  957. }
  958. ret = colorOption;
  959. }
  960. return ret;
  961. },
  962. /**
  963. * Take a VML string and prepare it for either IE8 or IE6/IE7.
  964. *
  965. * @function Highcharts.VMLRenderer#prepVML
  966. *
  967. * @param {Array<(number|string)>} markup
  968. * A string array of the VML markup to prepare
  969. *
  970. * @return {string}
  971. */
  972. prepVML: function (markup) {
  973. var vmlStyle = 'display:inline-block;behavior:url(#default#VML);', isIE8 = this.isIE8;
  974. markup = markup.join('');
  975. if (isIE8) { // add xmlns and style inline
  976. markup = markup.replace('/>', ' xmlns="urn:schemas-microsoft-com:vml" />');
  977. if (markup.indexOf('style="') === -1) {
  978. markup = markup.replace('/>', ' style="' + vmlStyle + '" />');
  979. }
  980. else {
  981. markup = markup.replace('style="', 'style="' + vmlStyle);
  982. }
  983. }
  984. else { // add namespace
  985. markup = markup.replace('<', '<hcv:');
  986. }
  987. return markup;
  988. },
  989. /**
  990. * Create rotated and aligned text
  991. *
  992. * @function Highcharts.VMLRenderer#text
  993. *
  994. * @param {string} str
  995. *
  996. * @param {number} x
  997. *
  998. * @param {number} y
  999. */
  1000. text: SVGRenderer.prototype.html,
  1001. /**
  1002. * Create and return a path element
  1003. *
  1004. * @function Highcharts.VMLRenderer#path
  1005. *
  1006. * @param {Highcharts.VMLAttributes|Highcharts.VMLPathArray} [path]
  1007. */
  1008. path: function (path) {
  1009. var attr = {
  1010. // subpixel precision down to 0.1 (width and height = 1px)
  1011. coordsize: '10 10'
  1012. };
  1013. if (isArray(path)) {
  1014. attr.d = path;
  1015. }
  1016. else if (isObject(path)) { // attributes
  1017. extend(attr, path);
  1018. }
  1019. // create the shape
  1020. return this.createElement('shape').attr(attr);
  1021. },
  1022. /**
  1023. * Create and return a circle element. In VML circles are implemented as
  1024. * shapes, which is faster than v:oval
  1025. *
  1026. * @function Highcharts.VMLRenderer#circle
  1027. * @param {number|Highcharts.Dictionary<number>} x
  1028. * @param {number} [y]
  1029. * @param {number} [r]
  1030. * @return {Highcharts.VMLElement}
  1031. */
  1032. circle: function (x, y, r) {
  1033. var circle = this.symbol('circle');
  1034. if (isObject(x)) {
  1035. r = x.r;
  1036. y = x.y;
  1037. x = x.x;
  1038. }
  1039. circle.isCircle = true; // Causes x and y to mean center (#1682)
  1040. circle.r = r;
  1041. return circle.attr({ x: x, y: y });
  1042. },
  1043. /**
  1044. * Create a group using an outer div and an inner v:group to allow
  1045. * rotating and flipping. A simple v:group would have problems with
  1046. * positioning child HTML elements and CSS clip.
  1047. *
  1048. * @function Highcharts.VMLRenderer#g
  1049. *
  1050. * @param {string} name
  1051. * The name of the group
  1052. *
  1053. * @return {Highcharts.VMLElement}
  1054. */
  1055. g: function (name) {
  1056. var wrapper, attribs;
  1057. // set the class name
  1058. if (name) {
  1059. attribs = {
  1060. 'className': 'highcharts-' + name,
  1061. 'class': 'highcharts-' + name
  1062. };
  1063. }
  1064. // the div to hold HTML and clipping
  1065. wrapper = this.createElement('div').attr(attribs);
  1066. return wrapper;
  1067. },
  1068. /**
  1069. * VML override to create a regular HTML image.
  1070. *
  1071. * @function Highcharts.VMLRenderer#image
  1072. *
  1073. * @param {string} src
  1074. *
  1075. * @param {number} x
  1076. *
  1077. * @param {number} y
  1078. *
  1079. * @param {number} width
  1080. *
  1081. * @param {number} height
  1082. * @return {Highcharts.VMLElement}
  1083. */
  1084. image: function (src, x, y, width, height) {
  1085. var obj = this.createElement('img').attr({ src: src });
  1086. if (arguments.length > 1) {
  1087. obj.attr({
  1088. x: x,
  1089. y: y,
  1090. width: width,
  1091. height: height
  1092. });
  1093. }
  1094. return obj;
  1095. },
  1096. /**
  1097. * For rectangles, VML uses a shape for rect to overcome bugs and
  1098. * rotation problems
  1099. *
  1100. * @function Highcharts.VMLRenderer#createElement
  1101. * @param {string} nodeName
  1102. * @return {Highcharts.VMLElement}
  1103. */
  1104. createElement: function (nodeName) {
  1105. return nodeName === 'rect' ?
  1106. this.symbol(nodeName) :
  1107. SVGRenderer.prototype.createElement.call(this, nodeName);
  1108. },
  1109. /**
  1110. * In the VML renderer, each child of an inverted div (group) is
  1111. * inverted
  1112. *
  1113. * @function Highcharts.VMLRenderer#invertChild
  1114. *
  1115. * @param {Highcharts.HTMLDOMElement} element
  1116. *
  1117. * @param {Highcharts.HTMLDOMElement} parentNode
  1118. */
  1119. invertChild: function (element, parentNode) {
  1120. var ren = this, parentStyle = parentNode.style, imgStyle = element.tagName === 'IMG' && element.style; // #1111
  1121. css(element, {
  1122. flip: 'x',
  1123. left: pInt(parentStyle.width) -
  1124. (imgStyle ? pInt(imgStyle.top) : 1),
  1125. top: pInt(parentStyle.height) -
  1126. (imgStyle ? pInt(imgStyle.left) : 1),
  1127. rotation: -90
  1128. });
  1129. // Recursively invert child elements, needed for nested composite
  1130. // shapes like box plots and error bars. #1680, #1806.
  1131. [].forEach.call(element.childNodes, function (child) {
  1132. ren.invertChild(child, element);
  1133. });
  1134. },
  1135. /**
  1136. * Symbol definitions that override the parent SVG renderer's symbols
  1137. *
  1138. * @name Highcharts.VMLRenderer#symbols
  1139. * @type {Highcharts.Dictionary<Function>}
  1140. */
  1141. symbols: {
  1142. // VML specific arc function
  1143. arc: function (x, y, w, h, options) {
  1144. var start = options.start, end = options.end, radius = options.r || w || h, innerRadius = options.innerR, cosStart = Math.cos(start), sinStart = Math.sin(start), cosEnd = Math.cos(end), sinEnd = Math.sin(end), ret;
  1145. if (end - start === 0) { // no angle, don't show it.
  1146. return ['x'];
  1147. }
  1148. ret = [
  1149. 'wa',
  1150. x - radius,
  1151. y - radius,
  1152. x + radius,
  1153. y + radius,
  1154. x + radius * cosStart,
  1155. y + radius * sinStart,
  1156. x + radius * cosEnd,
  1157. y + radius * sinEnd // end y
  1158. ];
  1159. if (options.open && !innerRadius) {
  1160. ret.push('e', 'M', x, // - innerRadius,
  1161. y // - innerRadius
  1162. );
  1163. }
  1164. ret.push('at', // anti clockwise arc to
  1165. x - innerRadius, // left
  1166. y - innerRadius, // top
  1167. x + innerRadius, // right
  1168. y + innerRadius, // bottom
  1169. x + innerRadius * cosEnd, // start x
  1170. y + innerRadius * sinEnd, // start y
  1171. x + innerRadius * cosStart, // end x
  1172. y + innerRadius * sinStart, // end y
  1173. 'x', // finish path
  1174. 'e' // close
  1175. );
  1176. ret.isArc = true;
  1177. return ret;
  1178. },
  1179. // Add circle symbol path. This performs significantly faster than
  1180. // v:oval.
  1181. circle: function (x, y, w, h, wrapper) {
  1182. if (wrapper && defined(wrapper.r)) {
  1183. w = h = 2 * wrapper.r;
  1184. }
  1185. // Center correction, #1682
  1186. if (wrapper && wrapper.isCircle) {
  1187. x -= w / 2;
  1188. y -= h / 2;
  1189. }
  1190. // Return the path
  1191. return [
  1192. 'wa',
  1193. x,
  1194. y,
  1195. x + w,
  1196. y + h,
  1197. x + w,
  1198. y + h / 2,
  1199. x + w,
  1200. y + h / 2,
  1201. 'e' // close
  1202. ];
  1203. },
  1204. /**
  1205. * Add rectangle symbol path which eases rotation and omits arcsize
  1206. * problems compared to the built-in VML roundrect shape. When
  1207. * borders are not rounded, use the simpler square path, else use
  1208. * the callout path without the arrow.
  1209. */
  1210. rect: function (x, y, w, h, options) {
  1211. return SVGRenderer.prototype.symbols[!defined(options) || !options.r ? 'square' : 'callout'].call(0, x, y, w, h, options);
  1212. }
  1213. }
  1214. };
  1215. H.VMLRenderer = VMLRenderer = function () {
  1216. this.init.apply(this, arguments);
  1217. };
  1218. VMLRenderer.prototype = merge(SVGRenderer.prototype, VMLRendererExtension);
  1219. // general renderer
  1220. H.Renderer = VMLRenderer;
  1221. }
  1222. SVGRenderer.prototype.getSpanWidth = function (wrapper, tspan) {
  1223. var renderer = this, bBox = wrapper.getBBox(true), actualWidth = bBox.width;
  1224. // Old IE cannot measure the actualWidth for SVG elements (#2314)
  1225. if (!svg && renderer.forExport) {
  1226. actualWidth = renderer.measureSpanWidth(tspan.firstChild.data, wrapper.styles);
  1227. }
  1228. return actualWidth;
  1229. };
  1230. // This method is used with exporting in old IE, when emulating SVG (see #2314)
  1231. SVGRenderer.prototype.measureSpanWidth = function (text, styles) {
  1232. var measuringSpan = doc.createElement('span'), offsetWidth, textNode = doc.createTextNode(text);
  1233. measuringSpan.appendChild(textNode);
  1234. css(measuringSpan, styles);
  1235. this.box.appendChild(measuringSpan);
  1236. offsetWidth = measuringSpan.offsetWidth;
  1237. discardElement(measuringSpan); // #2463
  1238. return offsetWidth;
  1239. };