arrow-symbols.src.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /**
  2. * @license Highcharts JS v9.1.1 (2021-06-04)
  3. *
  4. * Arrow Symbols
  5. *
  6. * (c) 2017-2021 Lars A. V. Cabrera
  7. *
  8. * License: www.highcharts.com/license
  9. */
  10. 'use strict';
  11. (function (factory) {
  12. if (typeof module === 'object' && module.exports) {
  13. factory['default'] = factory;
  14. module.exports = factory;
  15. } else if (typeof define === 'function' && define.amd) {
  16. define('highcharts/modules/arrow-symbols', ['highcharts'], function (Highcharts) {
  17. factory(Highcharts);
  18. factory.Highcharts = Highcharts;
  19. return factory;
  20. });
  21. } else {
  22. factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
  23. }
  24. }(function (Highcharts) {
  25. var _modules = Highcharts ? Highcharts._modules : {};
  26. function _registerModule(obj, path, args, fn) {
  27. if (!obj.hasOwnProperty(path)) {
  28. obj[path] = fn.apply(null, args);
  29. }
  30. }
  31. _registerModule(_modules, 'Extensions/ArrowSymbols.js', [_modules['Core/Renderer/SVG/SVGRenderer.js']], function (SVGRenderer) {
  32. /* *
  33. *
  34. * (c) 2017 Highsoft AS
  35. * Authors: Lars A. V. Cabrera
  36. *
  37. * License: www.highcharts.com/license
  38. *
  39. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40. *
  41. * */
  42. var symbols = SVGRenderer.prototype.symbols;
  43. /* *
  44. *
  45. * Functions
  46. *
  47. * */
  48. /**
  49. * Creates an arrow symbol. Like a triangle, except not filled.
  50. * ```
  51. * o
  52. * o
  53. * o
  54. * o
  55. * o
  56. * o
  57. * o
  58. * ```
  59. *
  60. * @private
  61. * @function
  62. *
  63. * @param {number} x
  64. * x position of the arrow
  65. *
  66. * @param {number} y
  67. * y position of the arrow
  68. *
  69. * @param {number} w
  70. * width of the arrow
  71. *
  72. * @param {number} h
  73. * height of the arrow
  74. *
  75. * @return {Highcharts.SVGPathArray}
  76. * Path array
  77. */
  78. function arrow(x, y, w, h) {
  79. return [
  80. ['M', x, y + h / 2],
  81. ['L', x + w, y],
  82. ['L', x, y + h / 2],
  83. ['L', x + w, y + h]
  84. ];
  85. }
  86. /**
  87. * Creates a half-width arrow symbol. Like a triangle, except not filled.
  88. * ```
  89. * o
  90. * o
  91. * o
  92. * o
  93. * o
  94. * ```
  95. *
  96. * @private
  97. * @function
  98. *
  99. * @param {number} x
  100. * x position of the arrow
  101. *
  102. * @param {number} y
  103. * y position of the arrow
  104. *
  105. * @param {number} w
  106. * width of the arrow
  107. *
  108. * @param {number} h
  109. * height of the arrow
  110. *
  111. * @return {Highcharts.SVGPathArray}
  112. * Path array
  113. */
  114. function arrowHalf(x, y, w, h) {
  115. return arrow(x, y, w / 2, h);
  116. }
  117. /**
  118. * Creates a left-oriented triangle.
  119. * ```
  120. * o
  121. * ooooooo
  122. * ooooooooooooo
  123. * ooooooo
  124. * o
  125. * ```
  126. *
  127. * @private
  128. * @function
  129. *
  130. * @param {number} x
  131. * x position of the triangle
  132. *
  133. * @param {number} y
  134. * y position of the triangle
  135. *
  136. * @param {number} w
  137. * width of the triangle
  138. *
  139. * @param {number} h
  140. * height of the triangle
  141. *
  142. * @return {Highcharts.SVGPathArray}
  143. * Path array
  144. */
  145. function triangleLeft(x, y, w, h) {
  146. return [
  147. ['M', x + w, y],
  148. ['L', x, y + h / 2],
  149. ['L', x + w, y + h],
  150. ['Z']
  151. ];
  152. }
  153. /**
  154. * Creates a half-width, left-oriented triangle.
  155. * ```
  156. * o
  157. * oooo
  158. * ooooooo
  159. * oooo
  160. * o
  161. * ```
  162. *
  163. * @private
  164. * @function
  165. *
  166. * @param {number} x
  167. * x position of the triangle
  168. *
  169. * @param {number} y
  170. * y position of the triangle
  171. *
  172. * @param {number} w
  173. * width of the triangle
  174. *
  175. * @param {number} h
  176. * height of the triangle
  177. *
  178. * @return {Highcharts.SVGPathArray}
  179. * Path array
  180. */
  181. function triangleLeftHalf(x, y, w, h) {
  182. return triangleLeft(x, y, w / 2, h);
  183. }
  184. symbols.arrow = arrow;
  185. symbols['arrow-filled'] = triangleLeft;
  186. symbols['arrow-filled-half'] = triangleLeftHalf;
  187. symbols['arrow-half'] = arrowHalf;
  188. symbols['triangle-left'] = triangleLeft;
  189. symbols['triangle-left-half'] = triangleLeftHalf;
  190. /* *
  191. *
  192. * Default Export
  193. *
  194. * */
  195. return symbols;
  196. });
  197. _registerModule(_modules, 'masters/modules/arrow-symbols.src.js', [], function () {
  198. });
  199. }));