oldie.src.js 59 KB

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