MapPointSeries.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /**
  2. * (c) 2010-2019 Torstein Honsi
  3. *
  4. * License: www.highcharts.com/license
  5. */
  6. 'use strict';
  7. import H from '../parts/Globals.js';
  8. import '../parts/Utilities.js';
  9. import '../parts/Options.js';
  10. import '../parts/Point.js';
  11. import '../parts/ScatterSeries.js';
  12. var merge = H.merge,
  13. Point = H.Point,
  14. seriesType = H.seriesType;
  15. /**
  16. * @private
  17. * @class
  18. * @name Highcharts.seriesTypes.mappoint
  19. *
  20. * @augments Highcharts.Series
  21. */
  22. seriesType(
  23. 'mappoint',
  24. 'scatter',
  25. /**
  26. * A mappoint series is a special form of scatter series where the points
  27. * can be laid out in map coordinates on top of a map.
  28. *
  29. * @sample maps/demo/mapline-mappoint/
  30. * Map-line and map-point series.
  31. *
  32. * @extends plotOptions.scatter
  33. * @product highmaps
  34. * @optionparent plotOptions.mappoint
  35. */
  36. {
  37. dataLabels: {
  38. /**
  39. * @default {point.name}
  40. * @apioption plotOptions.mappoint.dataLabels.format
  41. */
  42. enabled: true,
  43. formatter: function () { // #2945
  44. return this.point.name;
  45. },
  46. crop: false,
  47. defer: false,
  48. overflow: false,
  49. style: {
  50. color: '#000000'
  51. }
  52. }
  53. // Prototype members
  54. }, {
  55. type: 'mappoint',
  56. forceDL: true
  57. // Point class
  58. }, {
  59. applyOptions: function (options, x) {
  60. var mergedOptions = (
  61. options.lat !== undefined &&
  62. options.lon !== undefined ?
  63. merge(
  64. options, this.series.chart.fromLatLonToPoint(options)
  65. ) :
  66. options
  67. );
  68. return Point.prototype.applyOptions.call(this, mergedOptions, x);
  69. }
  70. }
  71. );
  72. /**
  73. * A `mappoint` series. If the [type](#series.mappoint.type) option
  74. * is not specified, it is inherited from [chart.type](#chart.type).
  75. *
  76. *
  77. * @extends series,plotOptions.mappoint
  78. * @excluding dataParser, dataURL
  79. * @product highmaps
  80. * @apioption series.mappoint
  81. */
  82. /**
  83. * An array of data points for the series. For the `mappoint` series
  84. * type, points can be given in the following ways:
  85. *
  86. * 1. An array of numerical values. In this case, the numerical values
  87. * will be interpreted as `y` options. The `x` values will be automatically
  88. * calculated, either starting at 0 and incremented by 1, or from `pointStart`
  89. * and `pointInterval` given in the series options. If the axis has
  90. * categories, these will be used. Example:
  91. *
  92. * ```js
  93. * data: [0, 5, 3, 5]
  94. * ```
  95. *
  96. * 2. An array of arrays with 2 values. In this case, the values correspond
  97. * to `x,y`. If the first value is a string, it is applied as the name
  98. * of the point, and the `x` value is inferred.
  99. *
  100. * ```js
  101. * data: [
  102. * [0, 1],
  103. * [1, 8],
  104. * [2, 7]
  105. * ]
  106. * ```
  107. *
  108. * 3. An array of objects with named values. The following snippet shows only a
  109. * few settings, see the complete options set below. If the total number of data
  110. * points exceeds the series' [turboThreshold](#series.mappoint.turboThreshold),
  111. * this option is not available.
  112. *
  113. * ```js
  114. * data: [{
  115. * x: 1,
  116. * y: 7,
  117. * name: "Point2",
  118. * color: "#00FF00"
  119. * }, {
  120. * x: 1,
  121. * y: 4,
  122. * name: "Point1",
  123. * color: "#FF00FF"
  124. * }]
  125. * ```
  126. *
  127. * @type {Array<number|Array<number,number>|*>}
  128. * @extends series.map.data
  129. * @excluding labelrank, middleX, middleY, path, value
  130. * @product highmaps
  131. * @apioption series.mappoint.data
  132. */
  133. /**
  134. * The latitude of the point. Must be combined with the `lon` option
  135. * to work. Overrides `x` and `y` values.
  136. *
  137. * @sample {highmaps} maps/demo/mappoint-latlon/
  138. * Point position by lat/lon
  139. *
  140. * @type {number}
  141. * @since 1.1.0
  142. * @product highmaps
  143. * @apioption series.mappoint.data.lat
  144. */
  145. /**
  146. * The longitude of the point. Must be combined with the `lon` option
  147. * to work. Overrides `x` and `y` values.
  148. *
  149. * @sample {highmaps} maps/demo/mappoint-latlon/
  150. * Point position by lat/lon
  151. *
  152. * @type {number}
  153. * @since 1.1.0
  154. * @product highmaps
  155. * @apioption series.mappoint.data.lon
  156. */
  157. /**
  158. * The x coordinate of the point in terms of the map path coordinates.
  159. *
  160. * @sample {highmaps} maps/demo/mapline-mappoint/
  161. * Map point demo
  162. *
  163. * @type {number}
  164. * @product highmaps
  165. * @apioption series.mappoint.data.x
  166. */
  167. /**
  168. * The x coordinate of the point in terms of the map path coordinates.
  169. *
  170. * @sample {highmaps} maps/demo/mapline-mappoint/
  171. * Map point demo
  172. *
  173. * @type {number}
  174. * @product highmaps
  175. * @apioption series.mappoint.data.y
  176. */