ArrowSymbols.js 3.7 KB

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