oldie.src.js 61 KB

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