vector.src.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. /**
  2. * @license Highcharts JS v8.2.2 (2020-10-22)
  3. *
  4. * Vector plot series module
  5. *
  6. * (c) 2010-2019 Torstein Honsi
  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/vector', ['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, 'Series/VectorSeries.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Series/Series.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (A, BaseSeries, H, U) {
  32. /* *
  33. *
  34. * Vector plot series module
  35. *
  36. * (c) 2010-2020 Torstein Honsi
  37. *
  38. * License: www.highcharts.com/license
  39. *
  40. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  41. *
  42. * */
  43. var animObject = A.animObject;
  44. var arrayMax = U.arrayMax,
  45. pick = U.pick;
  46. /**
  47. * The vector series class.
  48. *
  49. * @private
  50. * @class
  51. * @name Highcharts.seriesTypes.vector
  52. *
  53. * @augments Highcharts.seriesTypes.scatter
  54. */
  55. BaseSeries.seriesType('vector', 'scatter'
  56. /**
  57. * A vector plot is a type of cartesian chart where each point has an X and
  58. * Y position, a length and a direction. Vectors are drawn as arrows.
  59. *
  60. * @sample {highcharts|highstock} highcharts/demo/vector-plot/
  61. * Vector pot
  62. *
  63. * @since 6.0.0
  64. * @extends plotOptions.scatter
  65. * @excluding boostThreshold, marker, connectEnds, connectNulls,
  66. * cropThreshold, dashStyle, dragDrop, gapSize, gapUnit,
  67. * dataGrouping, linecap, shadow, stacking, step, jitter,
  68. * boostBlending
  69. * @product highcharts highstock
  70. * @requires modules/vector
  71. * @optionparent plotOptions.vector
  72. */
  73. , {
  74. /**
  75. * The line width for each vector arrow.
  76. */
  77. lineWidth: 2,
  78. /**
  79. * @ignore
  80. */
  81. marker: null,
  82. /**
  83. * What part of the vector it should be rotated around. Can be one of
  84. * `start`, `center` and `end`. When `start`, the vectors will start
  85. * from the given [x, y] position, and when `end` the vectors will end
  86. * in the [x, y] position.
  87. *
  88. * @sample highcharts/plotoptions/vector-rotationorigin-start/
  89. * Rotate from start
  90. *
  91. * @validvalue ["start", "center", "end"]
  92. */
  93. rotationOrigin: 'center',
  94. states: {
  95. hover: {
  96. /**
  97. * Additonal line width for the vector errors when they are
  98. * hovered.
  99. */
  100. lineWidthPlus: 1
  101. }
  102. },
  103. tooltip: {
  104. /**
  105. * @default [{point.x}, {point.y}] Length: {point.length} Direction: {point.direction}°
  106. */
  107. pointFormat: '<b>[{point.x}, {point.y}]</b><br/>Length: <b>{point.length}</b><br/>Direction: <b>{point.direction}\u00B0</b><br/>'
  108. },
  109. /**
  110. * Maximum length of the arrows in the vector plot. The individual arrow
  111. * length is computed between 0 and this value.
  112. */
  113. vectorLength: 20
  114. }, {
  115. pointArrayMap: ['y', 'length', 'direction'],
  116. parallelArrays: ['x', 'y', 'length', 'direction'],
  117. /* eslint-disable valid-jsdoc */
  118. /**
  119. * Get presentational attributes.
  120. *
  121. * @private
  122. * @function Highcharts.seriesTypes.vector#pointAttribs
  123. *
  124. * @param {Highcharts.Point} point
  125. *
  126. * @param {string} [state]
  127. *
  128. * @return {Highcharts.SVGAttributes}
  129. */
  130. pointAttribs: function (point, state) {
  131. var options = this.options,
  132. stroke = point.color || this.color,
  133. strokeWidth = this.options.lineWidth;
  134. if (state) {
  135. stroke = options.states[state].color || stroke;
  136. strokeWidth =
  137. (options.states[state].lineWidth || strokeWidth) +
  138. (options.states[state].lineWidthPlus || 0);
  139. }
  140. return {
  141. 'stroke': stroke,
  142. 'stroke-width': strokeWidth
  143. };
  144. },
  145. /**
  146. * @ignore
  147. * @deprecated
  148. * @function Highcharts.seriesTypes.vector#markerAttribs
  149. */
  150. markerAttribs: H.noop,
  151. /**
  152. * @ignore
  153. * @deprecated
  154. * @function Highcharts.seriesTypes.vector#getSymbol
  155. */
  156. getSymbol: H.noop,
  157. /**
  158. * Create a single arrow. It is later rotated around the zero
  159. * centerpoint.
  160. *
  161. * @private
  162. * @function Highcharts.seriesTypes.vector#arrow
  163. *
  164. * @param {Highcharts.Point} point
  165. *
  166. * @return {Highcharts.SVGPathArray}
  167. */
  168. arrow: function (point) {
  169. var path,
  170. fraction = point.length / this.lengthMax,
  171. u = fraction * this.options.vectorLength / 20,
  172. o = {
  173. start: 10 * u,
  174. center: 0,
  175. end: -10 * u
  176. }[this.options.rotationOrigin] || 0;
  177. // The stem and the arrow head. Draw the arrow first with rotation
  178. // 0, which is the arrow pointing down (vector from north to south).
  179. path = [
  180. ['M', 0, 7 * u + o],
  181. ['L', -1.5 * u, 7 * u + o],
  182. ['L', 0, 10 * u + o],
  183. ['L', 1.5 * u, 7 * u + o],
  184. ['L', 0, 7 * u + o],
  185. ['L', 0, -10 * u + o] // top
  186. ];
  187. return path;
  188. },
  189. /**
  190. * @private
  191. * @function Highcharts.seriesTypes.vector#translate
  192. */
  193. translate: function () {
  194. H.Series.prototype.translate.call(this);
  195. this.lengthMax = arrayMax(this.lengthData);
  196. },
  197. /**
  198. * @private
  199. * @function Highcharts.seriesTypes.vector#drawPoints
  200. */
  201. drawPoints: function () {
  202. var chart = this.chart;
  203. this.points.forEach(function (point) {
  204. var plotX = point.plotX,
  205. plotY = point.plotY;
  206. if (this.options.clip === false ||
  207. chart.isInsidePlot(plotX, plotY, chart.inverted)) {
  208. if (!point.graphic) {
  209. point.graphic = this.chart.renderer
  210. .path()
  211. .add(this.markerGroup)
  212. .addClass('highcharts-point ' +
  213. 'highcharts-color-' +
  214. pick(point.colorIndex, point.series.colorIndex));
  215. }
  216. point.graphic
  217. .attr({
  218. d: this.arrow(point),
  219. translateX: plotX,
  220. translateY: plotY,
  221. rotation: point.direction
  222. });
  223. if (!this.chart.styledMode) {
  224. point.graphic
  225. .attr(this.pointAttribs(point));
  226. }
  227. }
  228. else if (point.graphic) {
  229. point.graphic = point.graphic.destroy();
  230. }
  231. }, this);
  232. },
  233. /**
  234. * @ignore
  235. * @deprecated
  236. * @function Highcharts.seriesTypes.vector#drawGraph
  237. */
  238. drawGraph: H.noop,
  239. /*
  240. drawLegendSymbol: function (legend, item) {
  241. var options = legend.options,
  242. symbolHeight = legend.symbolHeight,
  243. square = options.squareSymbol,
  244. symbolWidth = square ? symbolHeight : legend.symbolWidth,
  245. path = this.arrow.call({
  246. lengthMax: 1,
  247. options: {
  248. vectorLength: symbolWidth
  249. }
  250. }, {
  251. length: 1
  252. });
  253. item.legendLine = this.chart.renderer.path(path)
  254. .addClass('highcharts-point')
  255. .attr({
  256. zIndex: 3,
  257. translateY: symbolWidth / 2,
  258. rotation: 270,
  259. 'stroke-width': 1,
  260. 'stroke': 'black'
  261. }).add(item.legendGroup);
  262. },
  263. */
  264. /**
  265. * Fade in the arrows on initializing series.
  266. *
  267. * @private
  268. * @function Highcharts.seriesTypes.vector#animate
  269. *
  270. * @param {boolean} [init]
  271. */
  272. animate: function (init) {
  273. if (init) {
  274. this.markerGroup.attr({
  275. opacity: 0.01
  276. });
  277. }
  278. else {
  279. this.markerGroup.animate({
  280. opacity: 1
  281. }, animObject(this.options.animation));
  282. }
  283. }
  284. /* eslint-enable valid-jsdoc */
  285. });
  286. /**
  287. * A `vector` series. If the [type](#series.vector.type) option is not
  288. * specified, it is inherited from [chart.type](#chart.type).
  289. *
  290. * @extends series,plotOptions.vector
  291. * @excluding dataParser, dataURL, boostThreshold, boostBlending
  292. * @product highcharts highstock
  293. * @requires modules/vector
  294. * @apioption series.vector
  295. */
  296. /**
  297. * An array of data points for the series. For the `vector` series type,
  298. * points can be given in the following ways:
  299. *
  300. * 1. An array of arrays with 4 values. In this case, the values correspond to
  301. * to `x,y,length,direction`. If the first value is a string, it is applied
  302. * as the name of the point, and the `x` value is inferred.
  303. * ```js
  304. * data: [
  305. * [0, 0, 10, 90],
  306. * [0, 1, 5, 180],
  307. * [1, 1, 2, 270]
  308. * ]
  309. * ```
  310. *
  311. * 2. An array of objects with named values. The following snippet shows only a
  312. * few settings, see the complete options set below. If the total number of
  313. * data points exceeds the series'
  314. * [turboThreshold](#series.area.turboThreshold), this option is not
  315. * available.
  316. * ```js
  317. * data: [{
  318. * x: 0,
  319. * y: 0,
  320. * name: "Point2",
  321. * length: 10,
  322. * direction: 90
  323. * }, {
  324. * x: 1,
  325. * y: 1,
  326. * name: "Point1",
  327. * direction: 270
  328. * }]
  329. * ```
  330. *
  331. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  332. * Arrays of numeric x and y
  333. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  334. * Arrays of datetime x and y
  335. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  336. * Arrays of point.name and y
  337. * @sample {highcharts} highcharts/series/data-array-of-objects/
  338. * Config objects
  339. *
  340. * @type {Array<Array<(number|string),number,number,number>|*>}
  341. * @extends series.line.data
  342. * @product highcharts highstock
  343. * @apioption series.vector.data
  344. */
  345. /**
  346. * The length of the vector. The rendered length will relate to the
  347. * `vectorLength` setting.
  348. *
  349. * @type {number}
  350. * @product highcharts highstock
  351. * @apioption series.vector.data.length
  352. */
  353. /**
  354. * The vector direction in degrees, where 0 is north (pointing towards south).
  355. *
  356. * @type {number}
  357. * @product highcharts highstock
  358. * @apioption series.vector.data.direction
  359. */
  360. ''; // adds doclets above to the transpiled file
  361. });
  362. _registerModule(_modules, 'masters/modules/vector.src.js', [], function () {
  363. });
  364. }));