MapBubbleSeries.js 8.3 KB

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