MapBubbleSeries.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /* *
  2. *
  3. * (c) 2010-2020 Torstein Honsi
  4. *
  5. * License: www.highcharts.com/license
  6. *
  7. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8. *
  9. * */
  10. 'use strict';
  11. import H from '../Core/Globals.js';
  12. import Point from '../Core/Series/Point.js';
  13. import U from '../Core/Utilities.js';
  14. var merge = U.merge, seriesType = U.seriesType;
  15. import '../Core/Options.js';
  16. import '../Series/Bubble/BubbleSeries.js';
  17. var seriesTypes = H.seriesTypes;
  18. // The mapbubble series type
  19. if (seriesTypes.bubble) {
  20. /**
  21. * @private
  22. * @class
  23. * @name Highcharts.seriesTypes.mapbubble
  24. *
  25. * @augments Highcharts.Series
  26. */
  27. seriesType('mapbubble', 'bubble'
  28. /**
  29. * A map bubble series is a bubble series laid out on top of a map
  30. * series, where each bubble is tied to a specific map area.
  31. *
  32. * @sample maps/demo/map-bubble/
  33. * Map bubble chart
  34. *
  35. * @extends plotOptions.bubble
  36. * @product highmaps
  37. * @optionparent plotOptions.mapbubble
  38. */
  39. , {
  40. /**
  41. * The main color of the series. This color affects both the fill
  42. * and the stroke of the bubble. For enhanced control, use `marker`
  43. * options.
  44. *
  45. * @sample {highmaps} maps/plotoptions/mapbubble-color/
  46. * Pink bubbles
  47. *
  48. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  49. * @apioption plotOptions.mapbubble.color
  50. */
  51. /**
  52. * Whether to display negative sized bubbles. The threshold is
  53. * given by the [zThreshold](#plotOptions.mapbubble.zThreshold)
  54. * option, and negative bubbles can be visualized by setting
  55. * [negativeColor](#plotOptions.bubble.negativeColor).
  56. *
  57. * @type {boolean}
  58. * @default true
  59. * @apioption plotOptions.mapbubble.displayNegative
  60. */
  61. /**
  62. * @sample {highmaps} maps/demo/map-bubble/
  63. * Bubble size
  64. *
  65. * @apioption plotOptions.mapbubble.maxSize
  66. */
  67. /**
  68. * @sample {highmaps} maps/demo/map-bubble/
  69. * Bubble size
  70. *
  71. * @apioption plotOptions.mapbubble.minSize
  72. */
  73. /**
  74. * When a point's Z value is below the
  75. * [zThreshold](#plotOptions.mapbubble.zThreshold) setting, this
  76. * color is used.
  77. *
  78. * @sample {highmaps} maps/plotoptions/mapbubble-negativecolor/
  79. * Negative color below a threshold
  80. *
  81. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  82. * @apioption plotOptions.mapbubble.negativeColor
  83. */
  84. /**
  85. * Whether the bubble's value should be represented by the area or
  86. * the width of the bubble. The default, `area`, corresponds best to
  87. * the human perception of the size of each bubble.
  88. *
  89. * @type {Highcharts.BubbleSizeByValue}
  90. * @default area
  91. * @apioption plotOptions.mapbubble.sizeBy
  92. */
  93. /**
  94. * When this is true, the absolute value of z determines the size
  95. * of the bubble. This means that with the default `zThreshold` of
  96. * 0, a bubble of value -1 will have the same size as a bubble of
  97. * value 1, while a bubble of value 0 will have a smaller size
  98. * according to `minSize`.
  99. *
  100. * @sample {highmaps} highcharts/plotoptions/bubble-sizebyabsolutevalue/
  101. * Size by absolute value, various thresholds
  102. *
  103. * @type {boolean}
  104. * @default false
  105. * @since 1.1.9
  106. * @apioption plotOptions.mapbubble.sizeByAbsoluteValue
  107. */
  108. /**
  109. * The minimum for the Z value range. Defaults to the highest Z
  110. * value in the data.
  111. *
  112. * @see [zMax](#plotOptions.mapbubble.zMin)
  113. *
  114. * @sample {highmaps} highcharts/plotoptions/bubble-zmin-zmax/
  115. * Z has a possible range of 0-100
  116. *
  117. * @type {number}
  118. * @since 1.0.3
  119. * @apioption plotOptions.mapbubble.zMax
  120. */
  121. /**
  122. * The minimum for the Z value range. Defaults to the lowest Z value
  123. * in the data.
  124. *
  125. * @see [zMax](#plotOptions.mapbubble.zMax)
  126. *
  127. * @sample {highmaps} highcharts/plotoptions/bubble-zmin-zmax/
  128. * Z has a possible range of 0-100
  129. *
  130. * @type {number}
  131. * @since 1.0.3
  132. * @apioption plotOptions.mapbubble.zMin
  133. */
  134. /**
  135. * When [displayNegative](#plotOptions.mapbubble.displayNegative)
  136. * is `false`, bubbles with lower Z values are skipped. When
  137. * `displayNegative` is `true` and a
  138. * [negativeColor](#plotOptions.mapbubble.negativeColor) is given,
  139. * points with lower Z is colored.
  140. *
  141. * @sample {highmaps} maps/plotoptions/mapbubble-negativecolor/
  142. * Negative color below a threshold
  143. *
  144. * @type {number}
  145. * @default 0
  146. * @apioption plotOptions.mapbubble.zThreshold
  147. */
  148. animationLimit: 500,
  149. tooltip: {
  150. pointFormat: '{point.name}: {point.z}'
  151. }
  152. // Prototype members
  153. }, {
  154. xyFromShape: true,
  155. type: 'mapbubble',
  156. // If one single value is passed, it is interpreted as z
  157. pointArrayMap: ['z'],
  158. // Return the map area identified by the dataJoinBy option
  159. getMapData: seriesTypes.map.prototype.getMapData,
  160. getBox: seriesTypes.map.prototype.getBox,
  161. setData: seriesTypes.map.prototype.setData,
  162. setOptions: seriesTypes.map.prototype.setOptions
  163. // Point class
  164. }, {
  165. applyOptions: function (options, x) {
  166. var point;
  167. if (options &&
  168. typeof options.lat !== 'undefined' &&
  169. typeof options.lon !== 'undefined') {
  170. point = Point.prototype.applyOptions.call(this, merge(options, this.series.chart.fromLatLonToPoint(options)), x);
  171. }
  172. else {
  173. point = seriesTypes.map.prototype.pointClass.prototype
  174. .applyOptions.call(this, options, x);
  175. }
  176. return point;
  177. },
  178. isValid: function () {
  179. return typeof this.z === 'number';
  180. },
  181. ttBelow: false
  182. });
  183. }
  184. /**
  185. * A `mapbubble` series. If the [type](#series.mapbubble.type) option
  186. * is not specified, it is inherited from [chart.type](#chart.type).
  187. *
  188. * @extends series,plotOptions.mapbubble
  189. * @excluding dataParser, dataURL
  190. * @product highmaps
  191. * @apioption series.mapbubble
  192. */
  193. /**
  194. * An array of data points for the series. For the `mapbubble` series
  195. * type, points can be given in the following ways:
  196. *
  197. * 1. An array of numerical values. In this case, the numerical values
  198. * will be interpreted as `z` options. Example:
  199. *
  200. * ```js
  201. * data: [0, 5, 3, 5]
  202. * ```
  203. *
  204. * 2. An array of objects with named values. The following snippet shows only a
  205. * few settings, see the complete options set below. If the total number of
  206. * data points exceeds the series'
  207. * [turboThreshold](#series.mapbubble.turboThreshold),
  208. * this option is not available.
  209. *
  210. * ```js
  211. * data: [{
  212. * z: 9,
  213. * name: "Point2",
  214. * color: "#00FF00"
  215. * }, {
  216. * z: 10,
  217. * name: "Point1",
  218. * color: "#FF00FF"
  219. * }]
  220. * ```
  221. *
  222. * @type {Array<number|null|*>}
  223. * @extends series.mappoint.data
  224. * @excluding labelrank, middleX, middleY, path, value, x, y, lat, lon
  225. * @product highmaps
  226. * @apioption series.mapbubble.data
  227. */
  228. /**
  229. * While the `x` and `y` values of the bubble are determined by the
  230. * underlying map, the `z` indicates the actual value that gives the
  231. * size of the bubble.
  232. *
  233. * @sample {highmaps} maps/demo/map-bubble/
  234. * Bubble
  235. *
  236. * @type {number|null}
  237. * @product highmaps
  238. * @apioption series.mapbubble.data.z
  239. */
  240. /**
  241. * @excluding enabled, enabledThreshold, height, radius, width
  242. * @apioption series.mapbubble.marker
  243. */
  244. ''; // adds doclets above to transpiled file