ts-maps 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +284 -0
  2. package/dist/apply-transform.d.ts +47 -0
  3. package/dist/base-element.d.ts +5 -0
  4. package/dist/base.d.ts +19 -0
  5. package/dist/brasil.d.ts +1 -0
  6. package/dist/canada.d.ts +1 -0
  7. package/dist/canvas-element.d.ts +8 -0
  8. package/dist/coords-to-point.d.ts +26 -0
  9. package/dist/create-lines.d.ts +39 -0
  10. package/dist/create-markers.d.ts +51 -0
  11. package/dist/create-regions.d.ts +19 -0
  12. package/dist/create-series.d.ts +20 -0
  13. package/dist/data-visualization.d.ts +99 -0
  14. package/dist/deep-merge.d.ts +44 -0
  15. package/dist/event-handler.d.ts +12 -0
  16. package/dist/events.d.ts +14 -0
  17. package/dist/get-inset-for-point.d.ts +24 -0
  18. package/dist/get-marker-position.d.ts +15 -0
  19. package/dist/image-element.d.ts +7 -0
  20. package/dist/index.d.ts +12 -0
  21. package/dist/index.js +2027 -0
  22. package/dist/interactable.d.ts +7 -0
  23. package/dist/italy.d.ts +1 -0
  24. package/dist/legend.d.ts +6 -0
  25. package/dist/line.d.ts +29 -0
  26. package/dist/map.d.ts +422 -0
  27. package/dist/marker.d.ts +31 -0
  28. package/dist/options.d.ts +5 -0
  29. package/dist/ordinal-scale.d.ts +32 -0
  30. package/dist/projection.d.ts +18 -0
  31. package/dist/region.d.ts +21 -0
  32. package/dist/reposition-labels.d.ts +27 -0
  33. package/dist/reposition-lines.d.ts +32 -0
  34. package/dist/reposition-markers.d.ts +26 -0
  35. package/dist/resize.d.ts +5 -0
  36. package/dist/series.d.ts +4 -0
  37. package/dist/set-focus.d.ts +58 -0
  38. package/dist/set-scale.d.ts +80 -0
  39. package/dist/setup-container-events.d.ts +48 -0
  40. package/dist/setup-container-touch-events.d.ts +68 -0
  41. package/dist/setup-element-events.d.ts +125 -0
  42. package/dist/setup-zoom-buttons.d.ts +21 -0
  43. package/dist/shape-element.d.ts +10 -0
  44. package/dist/spain.d.ts +1 -0
  45. package/dist/text-element.d.ts +1 -0
  46. package/dist/tooltip.d.ts +80 -0
  47. package/dist/types.d.ts +398 -0
  48. package/dist/update-size.d.ts +6 -0
  49. package/dist/us-aea-en.d.ts +266 -0
  50. package/dist/us-lcc-en.d.ts +266 -0
  51. package/dist/us-merc-en.d.ts +266 -0
  52. package/dist/us-mill-en.d.ts +266 -0
  53. package/dist/utils.d.ts +21 -0
  54. package/dist/vector-map.d.ts +15 -0
  55. package/dist/world-merc.d.ts +1 -0
  56. package/dist/world.d.ts +1 -0
  57. package/package.json +57 -0
@@ -0,0 +1,7 @@
1
+ declare interface Label {
2
+ render?: (...args: any[]) => string
3
+ offsets?: ((key: string) => [number, number]) | Array<[number, number]>
4
+ }
5
+ declare const params: any[];
6
+
7
+ export default Interactable;
@@ -0,0 +1 @@
1
+ export default italy;
@@ -0,0 +1,6 @@
1
+ declare const ticks: unknown;
2
+ declare const legendTitle: unknown;
3
+ declare const tick: unknown;
4
+ declare const tickText: unknown;
5
+
6
+ export default Legend;
package/dist/line.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ declare const LINE_CLASS: 'jvm-line';
2
+ declare interface LineOptions {
3
+ index: string
4
+ group: SVGElement
5
+ map: any
6
+ animate?: boolean
7
+ x1: number
8
+ y1: number
9
+ x2: number
10
+ y2: number
11
+ curvature?: number
12
+ config?: any
13
+ }
14
+ declare interface LineStyle {
15
+ initial?: Record<string, string | number>
16
+ hover?: Record<string, string | number>
17
+ selected?: Record<string, string | number>
18
+ }
19
+ declare const config: {
20
+ d: unknown;
21
+ fill: 'none';
22
+ dataIndex: unknown
23
+ };
24
+ const { x1, y1, x2, y2 } = this._options
25
+ return `M${x1},${y1}${this._getQCommand(x1, y1, x2, y2)}${x2},${y2}`
26
+ }
27
+ declare const curvature: unknown;
28
+
29
+ export default Line;
package/dist/map.d.ts ADDED
@@ -0,0 +1,422 @@
1
+ declare const JVM_PREFIX: 'jvm-' const CONTAINER_CLASS = `${JVM_PREFIX}container` const MARKERS_GROUP_ID = `${JVM_PREFIX}markers-group` const MARKERS_LABELS_GROUP_ID = `${JVM_PREFIX}markers-labels-group` const LINES_GROUP_ID = `${JVM_PREFIX}lines-group` const SERIES_CONTAINER_CLASS = `${JVM_PREFIX}series-container` const SERIES_CONTAINER_H_CLASS = `${SERIES_CONTAINER_CLASS} ${JVM_PREFIX}series-h` const SERIES_CONTAINER_V_CLASS = `${SERIES_CONTAINER_CLASS} ${JVM_PREFIX}series-v`;
2
+ export declare class Map implements MapInterface {
3
+ static maps: { [key: string]: MapData & { [key: string]: any } } = {}
4
+ static defaults: MapOptions = Defaults
5
+
6
+ params: MapOptions
7
+ regions: Record<string, Region> = {}
8
+ scale: number = 1
9
+ transX: number = 0
10
+ transY: number = 0
11
+ container!: HTMLElement
12
+ canvas!: SVGCanvasElementInterface
13
+ dataVisualization?: DataVisualization
14
+ legendHorizontal?: HTMLElement
15
+ legendVertical?: HTMLElement
16
+ series: { markers: any[], regions: any[], [key: string]: any[] } = { markers: [], regions: [] }
17
+
18
+ _mapData: MapData
19
+ _markers: Record<string, Marker> = {}
20
+ _lines: Record<string, Line> = {}
21
+ _defaultWidth: number
22
+ _defaultHeight: number
23
+ _height: number = 0
24
+ _width: number = 0
25
+ _baseScale: number = 1
26
+ _baseTransX: number = 0
27
+ _baseTransY: number = 0
28
+ _tooltip?: Tooltip
29
+ _linesGroup?: SVGGElement
30
+ _markersGroup?: SVGGElement
31
+ _markerLabelsGroup?: SVGGElement
32
+ _canvasImpl!: SVGCanvasElement
33
+
34
+ constructor(options: MapOptions = {} as MapOptions) {
35
+ this.params = merge(Map.defaults, options, true) as MapOptions
36
+
37
+ const mapParam = this.params.map
38
+ const mapName = typeof mapParam === 'string' ? mapParam : mapParam.name
39
+ const mapData = Map.maps[mapName]
40
+ if (!mapData) {
41
+ throw new Error(`Attempt to use map which was not loaded: ${mapName}`)
42
+ }
43
+
44
+ this._mapData = mapData
45
+ this._defaultWidth = this._mapData.width
46
+ this._defaultHeight = this._mapData.height
47
+
48
+ if (document.readyState !== 'loading') {
49
+ this._init()
50
+ }
51
+ else {
52
+ window.addEventListener('DOMContentLoaded', () => this._init())
53
+ }
54
+ }
55
+
56
+ _init(): void {
57
+ const options = this.params
58
+
59
+ const element = getElement(options.selector)
60
+ if (!element) {
61
+ throw new Error(`Element not found: ${options.selector}`)
62
+ }
63
+ this.container = element as HTMLElement
64
+ this.container.classList.add(CONTAINER_CLASS)
65
+
66
+ this._canvasImpl = new SVGCanvasElement(this.container)
67
+ this.canvas = this._canvasImpl as unknown as SVGCanvasElementInterface
68
+
69
+ this.setBackgroundColor(options.backgroundColor || '')
70
+
71
+ this._createRegions()
72
+
73
+ this.updateSize()
74
+
75
+ if (options.lines?.elements) {
76
+ const group = this._canvasImpl.createGroup(LINES_GROUP_ID)
77
+ if (!group) {
78
+ throw new TypeError('Failed to create lines group')
79
+ }
80
+ this._linesGroup = group.node
81
+ }
82
+
83
+ if (options.markers) {
84
+ const markersGroup = this._canvasImpl.createGroup(MARKERS_GROUP_ID)
85
+ const labelsGroup = this._canvasImpl.createGroup(MARKERS_LABELS_GROUP_ID)
86
+ if (!markersGroup || !labelsGroup) {
87
+ throw new TypeError('Failed to create markers groups')
88
+ }
89
+ this._markersGroup = markersGroup.node
90
+ this._markerLabelsGroup = labelsGroup.node
91
+ }
92
+
93
+ this._createMarkers(options.markers || [])
94
+
95
+ this._createLines(options.lines?.elements || [])
96
+
97
+ this._repositionLabels()
98
+
99
+ this._setupContainerEvents()
100
+
101
+ this._setupElementEvents()
102
+
103
+ if (options.zoomButtons) {
104
+ this._setupZoomButtons()
105
+ }
106
+
107
+ if (options.showTooltip) {
108
+ this._tooltip = new Tooltip(this)
109
+ }
110
+
111
+ if (options.selectedRegions) {
112
+ this._setSelected('regions', options.selectedRegions)
113
+ }
114
+
115
+ if (options.selectedMarkers) {
116
+ this._setSelected('_markers', options.selectedMarkers)
117
+ }
118
+
119
+ if (options.focusOn) {
120
+ this.setFocus(options.focusOn)
121
+ }
122
+
123
+ if (options.visualizeData) {
124
+ this.dataVisualization = new DataVisualization(options.visualizeData, this)
125
+ }
126
+
127
+ if (options.bindTouchEvents) {
128
+ if ('ontouchstart' in window) {
129
+ this._setupContainerTouchEvents()
130
+ }
131
+ }
132
+
133
+ if (options.series) {
134
+ this.container.appendChild(this.legendHorizontal = createElement(
135
+ 'div',
136
+ SERIES_CONTAINER_H_CLASS,
137
+ ))
138
+
139
+ this.container.appendChild(this.legendVertical = createElement(
140
+ 'div',
141
+ SERIES_CONTAINER_V_CLASS,
142
+ ))
143
+
144
+ this._createSeries()
145
+ }
146
+
147
+ this._emit(Events.onLoaded, [this])
148
+ }
149
+
150
+
151
+ setBackgroundColor(color: string): void {
152
+ this.container.style.backgroundColor = color
153
+ }
154
+
155
+
156
+ getSelectedRegions(): string[] {
157
+ return this._getSelected('regions')
158
+ }
159
+
160
+ clearSelectedRegions(regions?: string[]): void {
161
+ const regionsToProcess = this._normalizeRegions(regions) || this._getSelected('regions')
162
+ regionsToProcess.forEach((key) => {
163
+ this.regions[key].element.select(false)
164
+ })
165
+ }
166
+
167
+ setSelectedRegions(regions: string | string[]): void {
168
+ this.clearSelectedRegions()
169
+ const normalizedRegions = this._normalizeRegions(regions)
170
+ if (normalizedRegions) {
171
+ this._setSelected('regions', normalizedRegions)
172
+ }
173
+ }
174
+
175
+
176
+ getSelectedMarkers(): string[] {
177
+ return this._getSelected('_markers')
178
+ }
179
+
180
+ clearSelectedMarkers(): void {
181
+ this._clearSelected('_markers')
182
+ }
183
+
184
+ setSelectedMarkers(markers: string | string[]): void {
185
+ const normalizedMarkers = this._normalizeRegions(markers)
186
+ if (normalizedMarkers) {
187
+ this._setSelected('_markers', normalizedMarkers)
188
+ }
189
+ }
190
+
191
+ addMarkers(config: MarkerConfig | MarkerConfig[]): void {
192
+ const configs = Array.isArray(config) ? config : [config]
193
+ this._createMarkers(configs)
194
+ }
195
+
196
+ removeMarkers(markers?: string[]): void {
197
+ const toRemove = markers || Object.keys(this._markers)
198
+ toRemove.forEach((index) => {
199
+ const marker = this._markers[index] as any
200
+ if (marker) {
201
+ if (typeof marker.remove === 'function') {
202
+ marker.remove()
203
+ }
204
+ else if (marker.shape) {
205
+ marker.shape.remove()
206
+ if (marker.label) {
207
+ marker.label.remove()
208
+ }
209
+ }
210
+ delete this._markers[index]
211
+ }
212
+ })
213
+ }
214
+
215
+
216
+ addLine(from: string, to: string, style: Record<string, any> = {}): void {
217
+ console.warn('`addLine` method is deprecated, please use `addLines` instead.')
218
+ this._createLines([{ from, to, style }])
219
+ }
220
+
221
+ addLines(config: LineConfig | LineConfig[]): void {
222
+ const uids = this._getLinesAsUids()
223
+ const configs = Array.isArray(config) ? config : [config]
224
+
225
+ this._createLines(configs.filter((line) => {
226
+ return !(uids.includes(getLineUid(line.from, line.to)))
227
+ }))
228
+ }
229
+
230
+ removeLines(lines: LineConfig[] | string[]): void {
231
+ if (Array.isArray(lines) && typeof lines[0] !== 'string') {
232
+ lines = (lines as LineConfig[]).map(line => getLineUid(line.from, line.to))
233
+ }
234
+ else if (!Array.isArray(lines)) {
235
+ lines = this._getLinesAsUids()
236
+ }
237
+
238
+ (lines as string[]).forEach((uid) => {
239
+ this._lines[uid].dispose()
240
+ delete this._lines[uid]
241
+ })
242
+ }
243
+
244
+ removeLine(from: string, to: string): void {
245
+ console.warn('`removeLine` method is deprecated, please use `removeLines` instead.')
246
+ const uid = getLineUid(from, to)
247
+
248
+ if (Object.prototype.hasOwnProperty.call(this._lines, uid)) {
249
+ this._lines[uid].element.remove()
250
+ delete this._lines[uid]
251
+ }
252
+ }
253
+
254
+ reset(): void {
255
+ for (const key in this.series || {}) {
256
+ for (let i = 0; i < (this.series?.[key]?.length || 0); i++) {
257
+ this.series?.[key][i]?.clear()
258
+ }
259
+ }
260
+
261
+ if (this.legendHorizontal) {
262
+ removeElement(this.legendHorizontal)
263
+ this.legendHorizontal = undefined
264
+ }
265
+
266
+ if (this.legendVertical) {
267
+ removeElement(this.legendVertical)
268
+ this.legendVertical = undefined
269
+ }
270
+
271
+ this.scale = this._baseScale
272
+ this.transX = this._baseTransX
273
+ this.transY = this._baseTransY
274
+
275
+ this._applyTransform()
276
+ this.clearSelectedMarkers()
277
+ this.clearSelectedRegions()
278
+ this.removeMarkers()
279
+ }
280
+
281
+ destroy(destroyInstance = true): void {
282
+ EventHandler.flush()
283
+
284
+ this._tooltip?.dispose()
285
+
286
+ this._emit(Events.onDestroyed, [])
287
+
288
+ if (destroyInstance) {
289
+ Object.keys(this).forEach((key) => {
290
+ try {
291
+ delete (this as any)[key]
292
+ }
293
+ catch {
294
+ }
295
+ })
296
+ }
297
+ }
298
+
299
+ extend(name: string, callback: (...args: any[]) => void): void {
300
+ if (typeof (this as any)[name] === 'function') {
301
+ throw new TypeError(`The method [${name}] does already exist, please use another name.`)
302
+ }
303
+
304
+ (Map.prototype as any)[name] = callback
305
+ }
306
+
307
+ mercator = {
308
+ convert: (lat: number, lng: number): false | { x: number, y: number } => {
309
+ return { x: lng, y: lat }
310
+ },
311
+ }
312
+
313
+ miller = {
314
+ convert: (lat: number, lng: number): false | { x: number, y: number } => {
315
+ return { x: lng, y: lat }
316
+ },
317
+ }
318
+
319
+ getInsetForPoint(_x: number, _y: number): boolean {
320
+ return false
321
+ }
322
+
323
+ getMarkerPosition(_config: MarkerConfig): false | { x: number, y: number } {
324
+ return { x: 0, y: 0 }
325
+ }
326
+
327
+ coordsToPoint(_lat: number, _lng: number): false | { x: number, y: number } {
328
+ return { x: 0, y: 0 }
329
+ }
330
+
331
+ _repositionMarkers(): void {
332
+ }
333
+
334
+ _repositionLines(): void {
335
+ }
336
+
337
+ _setScale(_scale: number): void {
338
+ }
339
+
340
+
341
+ _emit(eventName: string, args: any[]): void {
342
+ for (const event in Events) {
343
+ if (Events[event as keyof typeof Events] === eventName && typeof this.params[event as keyof MapOptions] === 'function') {
344
+ this.params[event as keyof MapOptions]?.apply(this, args)
345
+ }
346
+ }
347
+ }
348
+
349
+ _getSelected(type: string): string[] {
350
+ const selected: string[] = []
351
+
352
+ for (const key in (this as any)[type]) {
353
+ if ((this as any)[type][key].element.isSelected) {
354
+ selected.push(key)
355
+ }
356
+ }
357
+
358
+ return selected
359
+ }
360
+
361
+ _setSelected(type: string, keys: string[]): void {
362
+ keys.forEach((key) => {
363
+ if ((this as any)[type][key]) {
364
+ (this as any)[type][key].element.select(true)
365
+ }
366
+ })
367
+ }
368
+
369
+ _clearSelected(type: string): void {
370
+ this._getSelected(type).forEach((key) => {
371
+ (this as any)[type][key].element.select(false)
372
+ })
373
+ }
374
+
375
+ _getLinesAsUids(): string[] {
376
+ return Object.keys(this._lines)
377
+ }
378
+
379
+ _normalizeRegions(regions: string | string[] | undefined): string[] | undefined {
380
+ if (!regions)
381
+ return undefined
382
+ return typeof regions === 'string' ? [regions] : regions
383
+ }
384
+
385
+ _createRegions(): void {
386
+ }
387
+
388
+ _createMarkers(_markers: MarkerConfig[]): void {
389
+ }
390
+
391
+ _createLines(_lines: LineConfig[]): void {
392
+ }
393
+
394
+ _createSeries(): void {
395
+ }
396
+
397
+ _repositionLabels(): void {
398
+ }
399
+
400
+ _setupContainerEvents(): void {
401
+ }
402
+
403
+ _setupElementEvents(): void {
404
+ }
405
+
406
+ _setupZoomButtons(): void {
407
+ }
408
+
409
+ _setupContainerTouchEvents(): void {
410
+ }
411
+
412
+ _applyTransform(): void {
413
+ }
414
+
415
+ updateSize(): void {
416
+ }
417
+
418
+ setFocus(_config: FocusOnOptions): void {
419
+ }
420
+ }
421
+
422
+ export default Map;
@@ -0,0 +1,31 @@
1
+ declare const NAME: 'marker' const JVM_PREFIX = 'jvm-' const MARKER_CLASS = `${JVM_PREFIX}element ${JVM_PREFIX}marker` const MARKER_LABEL_CLASS = `${JVM_PREFIX}element ${JVM_PREFIX}label`;
2
+ declare interface MarkerOptions {
3
+ index: string
4
+ map: any
5
+ group: SVGElement
6
+ labelsGroup: SVGElement
7
+ cx: number
8
+ cy: number
9
+ label?: {
10
+ render?: (config: any, key: string) => string
11
+ offsets?: ((key: string) => [number, number]) | Array<[number, number]>
12
+ }
13
+ config?: {
14
+ offsets?: [number, number]
15
+ [key: string]: any
16
+ }
17
+ isRecentlyCreated?: boolean
18
+ }
19
+ declare interface MarkerStyle {
20
+ initial: {
21
+ image?: string
22
+ [key: string]: any
23
+ }
24
+ hover?: Record<string, any>
25
+ selected?: Record<string, any>
26
+ }
27
+ declare const map: unknown;
28
+ declare const shapeType: unknown;
29
+ declare const labelText: unknown;
30
+
31
+ export default Marker;
@@ -0,0 +1,5 @@
1
+ import type { MapOptions } from '../types';
2
+
3
+ declare const defaultOptions: MapOptions;
4
+
5
+ export default defaultOptions;
@@ -0,0 +1,32 @@
1
+ import type { ScaleOptions } from '../types';
2
+
3
+ declare interface Tick {
4
+ value: string
5
+ label: string
6
+ }
7
+ export declare class OrdinalScale {
8
+ private _scale: Record<string, string>
9
+
10
+ constructor(options: ScaleOptions) {
11
+ this._scale = options.scale
12
+ }
13
+
14
+ getValue(value: string | number): string {
15
+ return this._scale[String(value)]
16
+ }
17
+
18
+ getTicks(): Tick[] {
19
+ const ticks: Tick[] = []
20
+
21
+ for (const key in this._scale) {
22
+ ticks.push({
23
+ value: this._scale[key],
24
+ label: key,
25
+ })
26
+ }
27
+
28
+ return ticks
29
+ }
30
+ }
31
+
32
+ export default OrdinalScale;
@@ -0,0 +1,18 @@
1
+ declare interface Point {
2
+ x: number
3
+ y: number
4
+ }
5
+ declare interface Projection {
6
+ mill: (lat: number, lng: number, c: number) => Point
7
+ merc: (lat: number, lng: number, c: number) => Point
8
+ aea: (lat: number, lng: number, c: number) => Point
9
+ lcc: (lat: number, lng: number, c: number) => Point
10
+ degRad: number
11
+ radDeg: number
12
+ radius: number
13
+ }
14
+ declare const Proj: Projection;
15
+ declare const fi0: unknown;
16
+ declare const fi0: unknown;
17
+
18
+ export default Proj;
@@ -0,0 +1,21 @@
1
+ declare interface RegionOptions {
2
+ map: any
3
+ code: string
4
+ path: string
5
+ style: RegionStyle
6
+ label?: {
7
+ render?: (key: string) => string
8
+ offsets?: ((key: string) => [number, number]) | Array<[number, number]>
9
+ }
10
+ labelStyle?: Record<string, any>
11
+ labelsGroup?: SVGElement
12
+ }
13
+ declare interface RegionStyle {
14
+ initial: Record<string, any>
15
+ hover?: Record<string, any>
16
+ selected?: Record<string, any>
17
+ }
18
+ declare const text: unknown;
19
+ declare const regionPath: unknown;
20
+
21
+ export default Region;
@@ -0,0 +1,27 @@
1
+ export default function repositionLabels(this: MapInterface): void {
2
+ const labels = this.params.labels || {}
3
+
4
+ if (labels.regions) {
5
+ for (const code in this.regions) {
6
+ const region = this.regions[code] as any
7
+ if (region.label) {
8
+ const x = region.labelX * this.scale + this.transX * this.scale
9
+ const y = region.labelY * this.scale + this.transY * this.scale
10
+
11
+ region.label.set({
12
+ x: Number.isNaN(x) ? 0 : x,
13
+ y: Number.isNaN(y) ? 0 : y,
14
+ })
15
+ }
16
+ }
17
+ }
18
+
19
+ if (labels.markers) {
20
+ for (const index in this._markers) {
21
+ const marker = this._markers[index] as any
22
+ if (marker && typeof marker.updateLabelPosition === 'function') {
23
+ marker.updateLabelPosition()
24
+ }
25
+ }
26
+ }
27
+ };
@@ -0,0 +1,32 @@
1
+ export default function repositionLines(this: MapInterface): void {
2
+ const curvature = (this.params.lines?.curvature as number) || 0.5
3
+
4
+ Object.values(this._lines || {}).forEach((line: Line) => {
5
+ const startMarker = Object.values(this._markers || {}).find(
6
+ ({ config }) => config.name === line.getConfig().from,
7
+ )
8
+
9
+ const endMarker = Object.values(this._markers || {}).find(
10
+ ({ config }) => config.name === line.getConfig().to,
11
+ )
12
+
13
+ if (startMarker && endMarker) {
14
+ const point1 = this.getMarkerPosition(startMarker.config)
15
+ const point2 = this.getMarkerPosition(endMarker.config)
16
+
17
+ if (point1 && point2) {
18
+ const { x: x1, y: y1 } = point1
19
+ const { x: x2, y: y2 } = point2
20
+
21
+ const midX = (x1 + x2) / 2
22
+ const midY = (y1 + y2) / 2
23
+ const curveX = midX + curvature * (y2 - y1)
24
+ const curveY = midY - curvature * (x2 - x1)
25
+
26
+ line.setStyle({
27
+ d: `M${x1},${y1} Q${curveX},${curveY} ${x2},${y2}`,
28
+ })
29
+ }
30
+ }
31
+ })
32
+ };
@@ -0,0 +1,26 @@
1
+ export default function repositionMarkers(this: MapInterface): void {
2
+ if (!this._markers)
3
+ return
4
+
5
+ for (const index in this._markers) {
6
+ const marker = this._markers[index] as any
7
+ if (!marker || !marker.shape)
8
+ continue
9
+
10
+ const point = this.getMarkerPosition(marker.config)
11
+
12
+ if (point !== false) {
13
+ const cx = Number.isNaN(point.x) ? 0 : point.x
14
+ const cy = Number.isNaN(point.y) ? 0 : point.y
15
+
16
+ marker.shape.set({
17
+ cx,
18
+ cy,
19
+ })
20
+
21
+ if (marker.label) {
22
+ marker.updateLabelPosition()
23
+ }
24
+ }
25
+ }
26
+ };
@@ -0,0 +1,5 @@
1
+ import type { MapInterface } from '../types';
2
+
3
+ export declare function resize(this: MapInterface): void;
4
+
5
+ export default resize;
@@ -0,0 +1,4 @@
1
+ declare const attrs: Record<string, string>;
2
+ declare const attrs: Record<string, string>;
3
+
4
+ export default Series;