map.d.ts 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*!*
  2. *
  3. * Copyright (c) Highsoft AS. All rights reserved.
  4. *
  5. *!*/
  6. import * as globals from "../globals";
  7. import * as _Highcharts from "../highcharts";
  8. /**
  9. * Adds the module to the imported Highcharts namespace.
  10. *
  11. * @param highcharts
  12. * The imported Highcharts namespace to extend.
  13. */
  14. export function factory(highcharts: typeof Highcharts): void;
  15. declare module "../highcharts" {
  16. interface Chart {
  17. /**
  18. * Highmaps only. Get chart coordinates from latitude/longitude. Returns
  19. * an object with x and y values corresponding to the `xAxis` and
  20. * `yAxis`.
  21. *
  22. * @param latLon
  23. * Coordinates.
  24. *
  25. * @return X and Y coordinates in terms of chart axis values.
  26. */
  27. fromLatLonToPoint(latLon: MapLatLonObject): MapCoordinateObject;
  28. /**
  29. * Highmaps only. Calculate latitude/longitude values for a point.
  30. * Returns an object with the numeric properties `lat` and `lon`.
  31. *
  32. * @param point
  33. * A `Point` instance or anything containing `x` and `y`
  34. * properties with numeric values.
  35. *
  36. * @return An object with `lat` and `lon` properties.
  37. */
  38. fromPointToLatLon(point: (MapCoordinateObject|Point)): (MapLatLonObject|undefined);
  39. /**
  40. * Highmaps only. Zoom in or out of the map. See also Point#zoomTo. See
  41. * Chart#fromLatLonToPoint for how to get the `centerX` and `centerY`
  42. * parameters for a geographic location.
  43. *
  44. * @param howMuch
  45. * How much to zoom the map. Values less than 1 zooms in. 0.5
  46. * zooms in to half the current view. 2 zooms to twice the
  47. * current view. If omitted, the zoom is reset.
  48. *
  49. * @param centerX
  50. * The X axis position to center around if available space.
  51. *
  52. * @param centerY
  53. * The Y axis position to center around if available space.
  54. *
  55. * @param mouseX
  56. * Fix the zoom to this position if possible. This is used for
  57. * example in mousewheel events, where the area under the mouse
  58. * should be fixed as we zoom in.
  59. *
  60. * @param mouseY
  61. * Fix the zoom to this position if possible.
  62. */
  63. mapZoom(howMuch?: number, centerX?: number, centerY?: number, mouseX?: number, mouseY?: number): void;
  64. /**
  65. * Highmaps only. Get point from latitude and longitude using specified
  66. * transform definition.
  67. *
  68. * @param latLon
  69. * A latitude/longitude object.
  70. *
  71. * @param transform
  72. * The transform definition to use as explained in the
  73. * documentation.
  74. *
  75. * @return An object with `x` and `y` properties.
  76. */
  77. transformFromLatLon(latLon: MapLatLonObject, transform: any): MapCoordinateObject;
  78. /**
  79. * Highmaps only. Get latLon from point using specified transform
  80. * definition. The method returns an object with the numeric properties
  81. * `lat` and `lon`.
  82. *
  83. * @param point
  84. * A `Point` instance, or any object containing the properties
  85. * `x` and `y` with numeric values.
  86. *
  87. * @param transform
  88. * The transform definition to use as explained in the
  89. * documentation.
  90. *
  91. * @return An object with `lat` and `lon` properties.
  92. */
  93. transformToLatLon(point: (MapCoordinateObject|Point), transform: any): (MapLatLonObject|undefined);
  94. }
  95. /**
  96. * Result object of a map transformation.
  97. */
  98. interface MapCoordinateObject {
  99. /**
  100. * X coordinate on the map.
  101. */
  102. x: number;
  103. /**
  104. * Y coordinate on the map.
  105. */
  106. y: (number|null);
  107. }
  108. /**
  109. * A latitude/longitude object.
  110. */
  111. interface MapLatLonObject {
  112. /**
  113. * The latitude.
  114. */
  115. lat: number;
  116. /**
  117. * The longitude.
  118. */
  119. lon: number;
  120. }
  121. interface Point {
  122. pointPadding?: number;
  123. /**
  124. * In Highmaps, when data is loaded from GeoJSON, the GeoJSON item's
  125. * properies are copied over here.
  126. */
  127. properties: any;
  128. value?: (number|null);
  129. /**
  130. * Highmaps only. Zoom in on the point using the global animation.
  131. */
  132. zoomTo(): void;
  133. }
  134. interface PointOptionsObject {
  135. pointPadding?: number;
  136. value?: (number|null);
  137. }
  138. /**
  139. * Map-optimized chart. Use Chart for common charts.
  140. */
  141. class MapChart extends Chart {
  142. /**
  143. * Initializes the chart. The constructor's arguments are passed on
  144. * directly.
  145. *
  146. * @param userOptions
  147. * Custom options.
  148. *
  149. * @param callback
  150. * Function to run when the chart has loaded and and all external
  151. * images are loaded.
  152. *
  153. * @fires Highcharts.MapChart#init
  154. * @fires Highcharts.MapChart#afterInit
  155. */
  156. init(userOptions: Options, callback?: Function): void;
  157. }
  158. /**
  159. * Contains all loaded map data for Highmaps.
  160. */
  161. let maps: Record<string, any>;
  162. /**
  163. * Highmaps only. Restructure a GeoJSON object in preparation to be read
  164. * directly by the series.mapData option. The GeoJSON will be broken down to
  165. * fit a specific Highcharts type, either `map`, `mapline` or `mappoint`.
  166. * Meta data in GeoJSON's properties object will be copied directly over to
  167. * Point.properties in Highmaps.
  168. *
  169. * @param geojson
  170. * The GeoJSON structure to parse, represented as a JavaScript object
  171. * rather than a JSON string.
  172. *
  173. * @param hType
  174. * The Highmaps series type to prepare for. Setting "map" will return
  175. * GeoJSON polygons and multipolygons. Setting "mapline" will return
  176. * GeoJSON linestrings and multilinestrings. Setting "mappoint" will
  177. * return GeoJSON points and multipoints.
  178. *
  179. * @return An object ready for the `mapData` option.
  180. */
  181. function geojson(geojson: GeoJSON, hType?: string): Array<any>;
  182. /**
  183. * The factory function for creating new map charts. Creates a new MapChart
  184. * object with different default options than the basic Chart.
  185. *
  186. * @param options
  187. * The chart options structure as described in the options reference.
  188. *
  189. * @param callback
  190. * A function to execute when the chart object is finished loading
  191. * and rendering. In most cases the chart is built in one thread, but
  192. * in Internet Explorer version 8 or less the chart is sometimes
  193. * initialized before the document is ready, and in these cases the
  194. * chart object will not be finished synchronously. As a consequence,
  195. * code that relies on the newly built Chart object should always run
  196. * in the callback. Defining a chart.events.load handler is
  197. * equivalent.
  198. *
  199. * @return The chart object.
  200. */
  201. function mapChart(options: Options, callback?: ChartCallbackFunction): MapChart;
  202. /**
  203. * The factory function for creating new map charts. Creates a new MapChart
  204. * object with different default options than the basic Chart.
  205. *
  206. * @param renderTo
  207. * The DOM element to render to, or its id.
  208. *
  209. * @param options
  210. * The chart options structure as described in the options reference.
  211. *
  212. * @param callback
  213. * A function to execute when the chart object is finished loading
  214. * and rendering. In most cases the chart is built in one thread, but
  215. * in Internet Explorer version 8 or less the chart is sometimes
  216. * initialized before the document is ready, and in these cases the
  217. * chart object will not be finished synchronously. As a consequence,
  218. * code that relies on the newly built Chart object should always run
  219. * in the callback. Defining a chart.events.load handler is
  220. * equivalent.
  221. *
  222. * @return The chart object.
  223. */
  224. function mapChart(renderTo: (string|HTMLDOMElement), options: Options, callback?: ChartCallbackFunction): MapChart;
  225. /**
  226. * Utility for reading SVG paths directly.
  227. */
  228. function splitPath(path: (string|Array<(string|number)>)): SVGPathArray;
  229. }
  230. export default factory;
  231. export let Highcharts: typeof _Highcharts;