MapBubbleSeries.js 8.1 KB

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