forked from highcharts/highcharts-dist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhighcharts-more.src.js
12004 lines (11966 loc) · 509 KB
/
highcharts-more.src.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @license Highcharts JS v9.3.2 (2021-11-29)
*
* (c) 2009-2021 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function (factory) {
if (typeof module === 'object' && module.exports) {
factory['default'] = factory;
module.exports = factory;
} else if (typeof define === 'function' && define.amd) {
define('highcharts/highcharts-more', ['highcharts'], function (Highcharts) {
factory(Highcharts);
factory.Highcharts = Highcharts;
return factory;
});
} else {
factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
}
}(function (Highcharts) {
var _modules = Highcharts ? Highcharts._modules : {};
function _registerModule(obj, path, args, fn) {
if (!obj.hasOwnProperty(path)) {
obj[path] = fn.apply(null, args);
}
}
_registerModule(_modules, 'Extensions/Pane.js', [_modules['Core/Chart/Chart.js'], _modules['Series/CenteredUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Pointer.js'], _modules['Core/Utilities.js']], function (Chart, CU, H, Pointer, U) {
/* *
*
* (c) 2010-2021 Torstein Honsi
*
* License: www.highcharts.com/license
*
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
*
* */
var addEvent = U.addEvent,
extend = U.extend,
merge = U.merge,
pick = U.pick,
splat = U.splat;
/**
* @typedef {"arc"|"circle"|"solid"} Highcharts.PaneBackgroundShapeValue
*/
/* eslint-disable no-invalid-this, valid-jsdoc */
Chart.prototype.collectionsWithUpdate.push('pane');
/**
* The Pane object allows options that are common to a set of X and Y axes.
*
* In the future, this can be extended to basic Highcharts and Highcharts Stock.
*
* @private
* @class
* @name Highcharts.Pane
* @param {Highcharts.PaneOptions} options
* @param {Highcharts.Chart} chart
*/
var Pane = /** @class */ (function () {
function Pane(options, chart) {
this.background = void 0;
this.center = void 0;
this.chart = void 0;
this.options = void 0;
this.coll = 'pane'; // Member of chart.pane
/**
* The pane serves as a container for axes and backgrounds for circular
* gauges and polar charts.
*
* @since 2.3.0
* @product highcharts
* @requires highcharts-more
* @optionparent pane
*/
this.defaultOptions = {
/**
* The end angle of the polar X axis or gauge value axis, given in
* degrees where 0 is north. Defaults to [startAngle](#pane.startAngle)
* + 360.
*
* @sample {highcharts} highcharts/demo/gauge-vu-meter/
* VU-meter with custom start and end angle
*
* @type {number}
* @since 2.3.0
* @product highcharts
* @apioption pane.endAngle
*/
/**
* The center of a polar chart or angular gauge, given as an array
* of [x, y] positions. Positions can be given as integers that
* transform to pixels, or as percentages of the plot area size.
*
* @sample {highcharts} highcharts/demo/gauge-vu-meter/
* Two gauges with different center
*
* @type {Array<string|number>}
* @default ["50%", "50%"]
* @since 2.3.0
* @product highcharts
*/
center: ['50%', '50%'],
/**
* The size of the pane, either as a number defining pixels, or a
* percentage defining a percentage of the available plot area (the
* smallest of the plot height or plot width).
*
* @sample {highcharts} highcharts/demo/gauge-vu-meter/
* Smaller size
*
* @type {number|string}
* @product highcharts
*/
size: '85%',
/**
* The inner size of the pane, either as a number defining pixels, or a
* percentage defining a percentage of the pane's size.
*
* @sample {highcharts} highcharts/series-polar/column-inverted-inner
* The inner size set to 20%
*
* @type {number|string}
* @product highcharts
*/
innerSize: '0%',
/**
* The start angle of the polar X axis or gauge axis, given in degrees
* where 0 is north. Defaults to 0.
*
* @sample {highcharts} highcharts/demo/gauge-vu-meter/
* VU-meter with custom start and end angle
*
* @since 2.3.0
* @product highcharts
*/
startAngle: 0
};
/**
* An array of background items for the pane.
*
* @sample {highcharts} highcharts/demo/gauge-speedometer/
* Speedometer gauge with multiple backgrounds
*
* @type {Array<*>}
* @optionparent pane.background
*/
this.defaultBackgroundOptions = {
/**
* The class name for this background.
*
* @sample {highcharts} highcharts/css/pane/
* Panes styled by CSS
* @sample {highstock} highcharts/css/pane/
* Panes styled by CSS
* @sample {highmaps} highcharts/css/pane/
* Panes styled by CSS
*
* @type {string}
* @default highcharts-pane
* @since 5.0.0
* @apioption pane.background.className
*/
/**
* The shape of the pane background. When `solid`, the background
* is circular. When `arc`, the background extends only from the min
* to the max of the value axis.
*
* @type {Highcharts.PaneBackgroundShapeValue}
* @since 2.3.0
* @product highcharts
*/
shape: 'circle',
/**
* The pixel border width of the pane background.
*
* @since 2.3.0
* @product highcharts
*/
borderWidth: 1,
/**
* The pane background border color.
*
* @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
* @since 2.3.0
* @product highcharts
*/
borderColor: "#cccccc" /* neutralColor20 */,
/**
* The background color or gradient for the pane.
*
* @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
* @default { linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 }, stops: [[0, #ffffff], [1, #e6e6e6]] }
* @since 2.3.0
* @product highcharts
*/
backgroundColor: {
/** @ignore-option */
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
/** @ignore-option */
stops: [
[0, "#ffffff" /* backgroundColor */],
[1, "#e6e6e6" /* neutralColor10 */]
]
},
/** @ignore-option */
from: -Number.MAX_VALUE,
/**
* The inner radius of the pane background. Can be either numeric
* (pixels) or a percentage string.
*
* @type {number|string}
* @since 2.3.0
* @product highcharts
*/
innerRadius: 0,
/** @ignore-option */
to: Number.MAX_VALUE,
/**
* The outer radius of the circular pane background. Can be either
* numeric (pixels) or a percentage string.
*
* @type {number|string}
* @since 2.3.0
* @product highcharts
*/
outerRadius: '105%'
};
this.init(options, chart);
}
/**
* Initialize the Pane object
*
* @private
* @function Highcharts.Pane#init
*
* @param {Highcharts.PaneOptions} options
*
* @param {Highcharts.Chart} chart
*/
Pane.prototype.init = function (options, chart) {
this.chart = chart;
this.background = [];
chart.pane.push(this);
this.setOptions(options);
};
/**
* @private
* @function Highcharts.Pane#setOptions
*
* @param {Highcharts.PaneOptions} options
*/
Pane.prototype.setOptions = function (options) {
// Set options. Angular charts have a default background (#3318)
this.options = options = merge(this.defaultOptions, this.chart.angular ? { background: {} } : void 0, options);
};
/**
* Render the pane with its backgrounds.
*
* @private
* @function Highcharts.Pane#render
*/
Pane.prototype.render = function () {
var options = this.options,
backgroundOption = this.options.background,
renderer = this.chart.renderer,
len,
i;
if (!this.group) {
this.group = renderer.g('pane-group')
.attr({ zIndex: options.zIndex || 0 })
.add();
}
this.updateCenter();
// Render the backgrounds
if (backgroundOption) {
backgroundOption = splat(backgroundOption);
len = Math.max(backgroundOption.length, this.background.length || 0);
for (i = 0; i < len; i++) {
// #6641 - if axis exists, chart is circular and apply
// background
if (backgroundOption[i] && this.axis) {
this.renderBackground(merge(this.defaultBackgroundOptions, backgroundOption[i]), i);
}
else if (this.background[i]) {
this.background[i] = this.background[i].destroy();
this.background.splice(i, 1);
}
}
}
};
/**
* Render an individual pane background.
*
* @private
* @function Highcharts.Pane#renderBackground
*
* @param {Highcharts.PaneBackgroundOptions} backgroundOptions
* Background options
*
* @param {number} i
* The index of the background in this.backgrounds
*/
Pane.prototype.renderBackground = function (backgroundOptions, i) {
var method = 'animate',
attribs = {
'class': 'highcharts-pane ' + (backgroundOptions.className || '')
};
if (!this.chart.styledMode) {
extend(attribs, {
'fill': backgroundOptions.backgroundColor,
'stroke': backgroundOptions.borderColor,
'stroke-width': backgroundOptions.borderWidth
});
}
if (!this.background[i]) {
this.background[i] = this.chart.renderer
.path()
.add(this.group);
method = 'attr';
}
this.background[i][method]({
'd': this.axis.getPlotBandPath(backgroundOptions.from, backgroundOptions.to, backgroundOptions)
}).attr(attribs);
};
/**
* Gets the center for the pane and its axis.
*
* @private
* @function Highcharts.Pane#updateCenter
* @param {Highcharts.Axis} [axis]
*/
Pane.prototype.updateCenter = function (axis) {
this.center = (axis ||
this.axis ||
{}).center = CU.getCenter.call(this);
};
/**
* Destroy the pane item
*
* @ignore
* @private
* @function Highcharts.Pane#destroy
* /
destroy: function () {
erase(this.chart.pane, this);
this.background.forEach(function (background) {
background.destroy();
});
this.background.length = 0;
this.group = this.group.destroy();
},
*/
/**
* Update the pane item with new options
*
* @private
* @function Highcharts.Pane#update
* @param {Highcharts.PaneOptions} options
* New pane options
* @param {boolean} [redraw]
*/
Pane.prototype.update = function (options, redraw) {
merge(true, this.options, options);
this.setOptions(this.options);
this.render();
this.chart.axes.forEach(function (axis) {
if (axis.pane === this) {
axis.pane = null;
axis.update({}, redraw);
}
}, this);
};
return Pane;
}());
/**
* Check whether element is inside or outside pane.
* @private
* @param {number} x
* Element's x coordinate
* @param {number} y
* Element's y coordinate
* @param {Array<number>} center
* Pane's center (x, y) and diameter
*/
function isInsidePane(x, y, center) {
return Math.sqrt(Math.pow(x - center[0], 2) + Math.pow(y - center[1], 2)) <= center[2] / 2;
}
Chart.prototype.getHoverPane = function (eventArgs) {
var chart = this;
var hoverPane;
if (eventArgs) {
chart.pane.forEach(function (pane) {
var plotX = eventArgs.chartX - chart.plotLeft,
plotY = eventArgs.chartY - chart.plotTop,
x = chart.inverted ? plotY : plotX,
y = chart.inverted ? plotX : plotY;
if (isInsidePane(x, y, pane.center)) {
hoverPane = pane;
}
});
}
return hoverPane;
};
addEvent(Chart, 'afterIsInsidePlot', function (e) {
var chart = this;
if (chart.polar) {
e.isInsidePlot = chart.pane.some(function (pane) { return isInsidePane(e.x, e.y, pane.center); });
}
});
addEvent(Pointer, 'beforeGetHoverData', function (eventArgs) {
var chart = this.chart;
if (chart.polar) {
// Find pane we are currently hovering over.
chart.hoverPane = chart.getHoverPane(eventArgs);
// Edit filter method to handle polar
eventArgs.filter = function (s) {
return (s.visible &&
!(!eventArgs.shared && s.directTouch) && // #3821
pick(s.options.enableMouseTracking, true) &&
(!chart.hoverPane || s.xAxis.pane === chart.hoverPane));
};
}
else {
chart.hoverPane = void 0;
}
});
addEvent(Pointer, 'afterGetHoverData', function (eventArgs) {
var chart = this.chart;
if (eventArgs.hoverPoint &&
eventArgs.hoverPoint.plotX &&
eventArgs.hoverPoint.plotY &&
chart.hoverPane &&
!isInsidePane(eventArgs.hoverPoint.plotX, eventArgs.hoverPoint.plotY, chart.hoverPane.center)) {
eventArgs.hoverPoint = void 0;
}
});
H.Pane = Pane;
return H.Pane;
});
_registerModule(_modules, 'Core/Axis/RadialAxis.js', [_modules['Core/Axis/AxisDefaults.js'], _modules['Core/DefaultOptions.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (AxisDefaults, D, H, U) {
/* *
*
* (c) 2010-2021 Torstein Honsi
*
* License: www.highcharts.com/license
*
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
*
* */
var defaultOptions = D.defaultOptions;
var noop = H.noop;
var addEvent = U.addEvent,
correctFloat = U.correctFloat,
defined = U.defined,
extend = U.extend,
fireEvent = U.fireEvent,
merge = U.merge,
pick = U.pick,
relativeLength = U.relativeLength,
wrap = U.wrap;
/* *
*
* Composition
*
* */
var RadialAxis;
(function (RadialAxis) {
/* *
*
* Declarations
*
* */
/* *
*
* Constants
*
* */
var composedClasses = [];
/**
* Circular axis around the perimeter of a polar chart.
* @private
*/
var defaultCircularOptions = {
gridLineWidth: 1,
labels: {
align: void 0,
distance: 15,
x: 0,
y: void 0,
style: {
textOverflow: 'none' // wrap lines by default (#7248)
}
},
maxPadding: 0,
minPadding: 0,
showLastLabel: false,
tickLength: 0
};
/**
* The default options extend defaultYAxisOptions.
* @private
*/
var defaultRadialGaugeOptions = {
labels: {
align: 'center',
x: 0,
y: void 0 // auto
},
minorGridLineWidth: 0,
minorTickInterval: 'auto',
minorTickLength: 10,
minorTickPosition: 'inside',
minorTickWidth: 1,
tickLength: 10,
tickPosition: 'inside',
tickWidth: 2,
title: {
rotation: 0
},
zIndex: 2 // behind dials, points in the series group
};
/**
* Radial axis, like a spoke in a polar chart.
* @private
*/
var defaultRadialOptions = {
/**
* In a polar chart, this is the angle of the Y axis in degrees, where
* 0 is up and 90 is right. The angle determines the position of the
* axis line and the labels, though the coordinate system is unaffected.
* Since v8.0.0 this option is also applicable for X axis (inverted
* polar).
*
* @sample {highcharts} highcharts/xaxis/angle/
* Custom X axis' angle on inverted polar chart
* @sample {highcharts} highcharts/yaxis/angle/
* Dual axis polar chart
*
* @type {number}
* @default 0
* @since 4.2.7
* @product highcharts
* @apioption xAxis.angle
*/
/**
* Polar charts only. Whether the grid lines should draw as a polygon
* with straight lines between categories, or as circles. Can be either
* `circle` or `polygon`. Since v8.0.0 this option is also applicable
* for X axis (inverted polar).
*
* @sample {highcharts} highcharts/demo/polar-spider/
* Polygon grid lines
* @sample {highcharts} highcharts/xaxis/gridlineinterpolation/
* Circle and polygon on inverted polar
* @sample {highcharts} highcharts/yaxis/gridlineinterpolation/
* Circle and polygon
*
* @type {string}
* @product highcharts
* @validvalue ["circle", "polygon"]
* @apioption xAxis.gridLineInterpolation
*/
gridLineInterpolation: 'circle',
gridLineWidth: 1,
labels: {
align: 'right',
x: -3,
y: -2
},
showLastLabel: false,
title: {
x: 4,
text: null,
rotation: 90
}
};
/* *
*
* Functions
*
* */
/* eslint-disable valid-jsdoc */
/**
* In case of auto connect, add one closestPointRange to the max value
* right before tickPositions are computed, so that ticks will extend
* passed the real max.
* @private
*/
function beforeSetTickPositions() {
// If autoConnect is true, polygonal grid lines are connected, and
// one closestPointRange is added to the X axis to prevent the last
// point from overlapping the first.
this.autoConnect = (this.isCircular &&
typeof pick(this.userMax, this.options.max) === 'undefined' &&
correctFloat(this.endAngleRad - this.startAngleRad) ===
correctFloat(2 * Math.PI));
// This will lead to add an extra tick to xAxis in order to display
// a correct range on inverted polar
if (!this.isCircular && this.chart.inverted) {
this.max++;
}
if (this.autoConnect) {
this.max += ((this.categories && 1) ||
this.pointRange ||
this.closestPointRange ||
0); // #1197, #2260
}
}
/**
* Augments methods for the value axis.
*
* @private
*
* @param {Highcharts.Axis} AxisClass
* Axis class to extend.
*
* @param {Highcharts.Tick} TickClass
* Tick class to use.
*
* @return {Highcharts.Axis}
* Axis composition.
*/
function compose(AxisClass, TickClass) {
if (composedClasses.indexOf(AxisClass) === -1) {
composedClasses.push(AxisClass);
addEvent(AxisClass, 'afterInit', onAxisAfterInit);
addEvent(AxisClass, 'autoLabelAlign', onAxisAutoLabelAlign);
addEvent(AxisClass, 'destroy', onAxisDestroy);
addEvent(AxisClass, 'init', onAxisInit);
addEvent(AxisClass, 'initialAxisTranslation', onAxisInitialAxisTranslation);
}
if (composedClasses.indexOf(TickClass) === -1) {
composedClasses.push(TickClass);
addEvent(TickClass, 'afterGetLabelPosition', onTickAfterGetLabelPosition);
addEvent(TickClass, 'afterGetPosition', onTickAfterGetPosition);
wrap(TickClass.prototype, 'getMarkPath', wrapTickGetMarkPath);
}
return AxisClass;
}
RadialAxis.compose = compose;
/**
* Attach and return collecting function for labels in radial axis for
* anti-collision.
*
* @private
*/
function createLabelCollector() {
var _this = this;
return function () {
if (_this.isRadial &&
_this.tickPositions &&
// undocumented option for now, but working
_this.options.labels &&
_this.options.labels.allowOverlap !== true) {
return _this.tickPositions
.map(function (pos) {
return _this.ticks[pos] && _this.ticks[pos].label;
})
.filter(function (label) {
return Boolean(label);
});
}
};
}
/**
* Creates an empty collector function.
* @private
*/
function createLabelCollectorHidden() {
return noop;
}
/**
* Find the correct end values of crosshair in polar.
* @private
*/
function getCrosshairPosition(options, x1, y1) {
var center = this.pane.center;
var value = options.value,
shapeArgs,
end,
x2,
y2;
if (this.isCircular) {
if (!defined(value)) {
// When the snap is set to false
x2 = options.chartX || 0;
y2 = options.chartY || 0;
value = this.translate(Math.atan2(y2 - y1, x2 - x1) - this.startAngleRad, true);
}
else if (options.point) {
// When the snap is set to true
shapeArgs = options.point.shapeArgs || {};
if (shapeArgs.start) {
// Find a true value of the point based on the
// angle
value = this.chart.inverted ?
this.translate(options.point.rectPlotY, true) :
options.point.x;
}
}
end = this.getPosition(value);
x2 = end.x;
y2 = end.y;
}
else {
if (!defined(value)) {
x2 = options.chartX;
y2 = options.chartY;
}
if (defined(x2) && defined(y2)) {
// Calculate radius of non-circular axis' crosshair
y1 = center[1] + this.chart.plotTop;
value = this.translate(Math.min(Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)), center[2] / 2) - center[3] / 2, true);
}
}
return [value, x2 || 0, y2 || 0];
}
/**
* Get the path for the axis line. This method is also referenced in the
* getPlotLinePath method.
*
* @private
* @param {number} _lineWidth
* Line width is not used.
* @param {number} [radius]
* Radius of radial path.
* @param {number} [innerRadius]
* Inner radius of radial path.
*/
function getLinePath(_lineWidth, radius, innerRadius) {
var center = this.pane.center,
chart = this.chart,
left = this.left || 0,
top = this.top || 0;
var end,
r = pick(radius,
center[2] / 2 - this.offset),
path;
if (typeof innerRadius === 'undefined') {
innerRadius = this.horiz ? 0 : this.center && -this.center[3] / 2;
}
// In case when innerSize of pane is set, it must be included
if (innerRadius) {
r += innerRadius;
}
if (this.isCircular || typeof radius !== 'undefined') {
path = this.chart.renderer.symbols.arc(left + center[0], top + center[1], r, r, {
start: this.startAngleRad,
end: this.endAngleRad,
open: true,
innerR: 0
});
// Bounds used to position the plotLine label next to the line
// (#7117)
path.xBounds = [left + center[0]];
path.yBounds = [top + center[1] - r];
}
else {
end = this.postTranslate(this.angleRad, r);
path = [
[
'M',
this.center[0] + chart.plotLeft,
this.center[1] + chart.plotTop
],
['L', end.x, end.y]
];
}
return path;
}
/**
* Wrap the getOffset method to return zero offset for title or labels
* in a radial axis.
*/
function getOffset() {
var axisProto = this.constructor.prototype;
// Call the Axis prototype method (the method we're in now is on the
// instance)
axisProto.getOffset.call(this);
// Title or label offsets are not counted
this.chart.axisOffset[this.side] = 0;
}
/**
* Find the path for plot bands along the radial axis.
*
* @private
*/
function getPlotBandPath(from, to, options) {
var chart = this.chart,
radiusToPixels = function (radius) {
if (typeof radius === 'string') {
var r = parseInt(radius, 10);
if (percentRegex.test(radius)) {
r = (r * fullRadius) / 100;
}
return r;
}
return radius;
}, center = this.center, startAngleRad = this.startAngleRad, fullRadius = center[2] / 2, offset = Math.min(this.offset, 0), left = this.left || 0, top = this.top || 0, percentRegex = /%$/, isCircular = this.isCircular; // X axis in a polar chart
var start,
end,
angle,
xOnPerimeter,
open,
path,
outerRadius = pick(radiusToPixels(options.outerRadius),
fullRadius),
innerRadius = radiusToPixels(options.innerRadius),
thickness = pick(radiusToPixels(options.thickness), 10);
// Polygonal plot bands
if (this.options.gridLineInterpolation === 'polygon') {
path = this.getPlotLinePath({ value: from }).concat(this.getPlotLinePath({ value: to, reverse: true }));
// Circular grid bands
}
else {
// Keep within bounds
from = Math.max(from, this.min);
to = Math.min(to, this.max);
var transFrom = this.translate(from),
transTo = this.translate(to);
// Plot bands on Y axis (radial axis) - inner and outer
// radius depend on to and from
if (!isCircular) {
outerRadius = transFrom || 0;
innerRadius = transTo || 0;
}
// Handle full circle
if (options.shape === 'circle' || !isCircular) {
start = -Math.PI / 2;
end = Math.PI * 1.5;
open = true;
}
else {
start = startAngleRad + (transFrom || 0);
end = startAngleRad + (transTo || 0);
}
outerRadius -= offset; // #5283
thickness -= offset; // #5283
path = chart.renderer.symbols.arc(left + center[0], top + center[1], outerRadius, outerRadius, {
// Math is for reversed yAxis (#3606)
start: Math.min(start, end),
end: Math.max(start, end),
innerR: pick(innerRadius, outerRadius - thickness),
open: open
});
// Provide positioning boxes for the label (#6406)
if (isCircular) {
angle = (end + start) / 2;
xOnPerimeter = (left +
center[0] +
(center[2] / 2) * Math.cos(angle));
path.xBounds = angle > -Math.PI / 2 && angle < Math.PI / 2 ?
// Right hemisphere
[xOnPerimeter, chart.plotWidth] :
// Left hemisphere
[0, xOnPerimeter];
path.yBounds = [
top + center[1] + (center[2] / 2) * Math.sin(angle)
];
// Shift up or down to get the label clear of the perimeter
path.yBounds[0] += ((angle > -Math.PI && angle < 0) ||
(angle > Math.PI)) ? -10 : 10;
}
}
return path;
}
/**
* Find the path for plot lines perpendicular to the radial axis.
*/
function getPlotLinePath(options) {
var _this = this;
var center = this.pane.center, chart = this.chart, inverted = chart.inverted, reverse = options.reverse, background = this.pane.options.background ?
(this.pane.options.background[0] ||
this.pane.options.background) :
{}, innerRadius = background.innerRadius || '0%', outerRadius = background.outerRadius || '100%', x1 = center[0] + chart.plotLeft, y1 = center[1] + chart.plotTop, height = this.height, isCrosshair = options.isCrosshair, paneInnerR = center[3] / 2;
var value = options.value,
innerRatio,
distance,
a,
b,
otherAxis,
xy,
tickPositions,
crossPos,
path;
var end = this.getPosition(value);
var x2 = end.x,
y2 = end.y;
// Crosshair logic
if (isCrosshair) {
// Find crosshair's position and perform destructuring
// assignment
crossPos = this.getCrosshairPosition(options, x1, y1);
value = crossPos[0];
x2 = crossPos[1];
y2 = crossPos[2];
}
// Spokes
if (this.isCircular) {
distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
a = (typeof innerRadius === 'string') ?
relativeLength(innerRadius, 1) :
(innerRadius / distance);
b = (typeof outerRadius === 'string') ?
relativeLength(outerRadius, 1) :
(outerRadius / distance);
// To ensure that gridlines won't be displayed in area
// defined by innerSize in case of custom radiuses of pane's
// background
if (center && paneInnerR) {
innerRatio = paneInnerR / distance;
if (a < innerRatio) {
a = innerRatio;
}
if (b < innerRatio) {
b = innerRatio;
}
}
path = [
['M', x1 + a * (x2 - x1), y1 - a * (y1 - y2)],
['L', x2 - (1 - b) * (x2 - x1), y2 + (1 - b) * (y1 - y2)]
];
// Concentric circles
}
else {
// Pick the right values depending if it is grid line or
// crosshair
value = this.translate(value);
// This is required in case when xAxis is non-circular to
// prevent grid lines (or crosshairs, if enabled) from
// rendering above the center after they supposed to be
// displayed below the center point
if (value) {
if (value < 0 || value > height) {
value = 0;
}
}
if (this.options.gridLineInterpolation === 'circle') {
// A value of 0 is in the center, so it won't be
// visible, but draw it anyway for update and animation
// (#2366)
path = this.getLinePath(0, value, paneInnerR);
// Concentric polygons
}
else {
path = [];
// Find the other axis (a circular one) in the same pane
chart[inverted ? 'yAxis' : 'xAxis'].forEach(function (a) {
if (a.pane === _this.pane) {
otherAxis = a;
}
});
if (otherAxis) {
tickPositions = otherAxis.tickPositions;
if (otherAxis.autoConnect) {
tickPositions =
tickPositions.concat([tickPositions[0]]);
}
// Reverse the positions for concatenation of polygonal
// plot bands
if (reverse) {
tickPositions = tickPositions.slice().reverse();
}
if (value) {
value += paneInnerR;
}
for (var i = 0; i < tickPositions.length; i++) {
xy = otherAxis.getPosition(tickPositions[i], value);
path.push(i ? ['L', xy.x, xy.y] : ['M', xy.x, xy.y]);
}
}
}
}
return path;
}
/**
* Returns the x, y coordinate of a point given by a value and a pixel
* distance from center.
*
* @private
* @param {number} value
* Point value.
* @param {number} [length]
* Distance from center.
*/
function getPosition(value, length) {
var translatedVal = this.translate(value);
return this.postTranslate(this.isCircular ? translatedVal : this.angleRad, // #2848
// In case when translatedVal is negative, the 0 value must be
// used instead, in order to deal with lines and labels that
// fall out of the visible range near the center of a pane
pick(this.isCircular ?
length :
(translatedVal < 0 ? 0 : translatedVal), this.center[2] / 2) - this.offset);
}
/**
* Find the position for the axis title, by default inside the gauge.
*/