-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
Series.ts
5311 lines (4703 loc) · 168 KB
/
Series.ts
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
/* *
*
* (c) 2010-2021 Torstein Honsi
*
* License: www.highcharts.com/license
*
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
*
* */
'use strict';
/* *
*
* Imports
*
* */
import type AnimationOptions from '../Animation/AnimationOptions';
import type Axis from '../Axis/Axis';
import type AxisType from '../Axis/AxisType';
import type BBoxObject from '../Renderer/BBoxObject';
import type Chart from '../Chart/Chart';
import type ColorType from '../Color/ColorType';
import type DataExtremesObject from './DataExtremesObject';
import type { EventCallback } from '../Callback';
import type MapSeries from '../../Series/Map/MapSeries';
import type PointerEvent from '../PointerEvent';
import type {
PointOptions,
PointShortOptions,
PointStateHoverOptions
} from './PointOptions';
import type RangeSelector from '../../Stock/RangeSelector/RangeSelector';
import type SeriesLike from './SeriesLike';
import type {
SeriesDataSortingOptions,
SeriesOptions,
SeriesStateHoverOptions,
SeriesZonesOptions
} from './SeriesOptions';
import type {
SeriesTypeOptions,
SeriesTypePlotOptions
} from './SeriesType';
import type StackItem from '../Axis/Stacking/StackItem';
import type { StatesOptionsKey } from './StatesOptions';
import type SVGAttributes from '../Renderer/SVG/SVGAttributes';
import type SVGPath from '../Renderer/SVG/SVGPath';
import type { SymbolKey } from '../Renderer/SVG/SymbolType';
import type TooltipOptions from '../TooltipOptions';
import A from '../Animation/AnimationUtilities.js';
const {
animObject,
setAnimation
} = A;
import D from '../Defaults.js';
const { defaultOptions } = D;
import F from '../Foundation.js';
const { registerEventOptions } = F;
import H from '../Globals.js';
const {
hasTouch,
svg,
win
} = H;
import LegendSymbol from '../Legend/LegendSymbol.js';
import { Palette } from '../Color/Palettes.js';
import Point from './Point.js';
import SeriesDefaults from './SeriesDefaults.js';
import SeriesRegistry from './SeriesRegistry.js';
const { seriesTypes } = SeriesRegistry;
import SVGElement from '../Renderer/SVG/SVGElement.js';
import U from '../Utilities.js';
const {
addEvent,
arrayMax,
arrayMin,
clamp,
cleanRecursively,
correctFloat,
defined,
erase,
error,
extend,
find,
fireEvent,
getNestedProperty,
isArray,
isNumber,
isString,
merge,
objectEach,
pick,
removeEvent,
splat,
syncTimeout
} = U;
/* *
*
* Declarations
*
* */
declare module '../Chart/ChartLike'{
interface ChartLike {
runTrackerClick?: boolean;
}
}
declare module '../Renderer/SVG/SVGElementLike' {
interface SVGElementLike {
survive?: boolean;
}
}
declare module './PointLike' {
interface PointLike {
plotX?: number;
plotY?: number;
}
}
declare module './SeriesLike' {
interface SeriesLike {
_hasPointMarkers?: boolean;
invertible?: boolean;
pointArrayMap?: Array<string>;
pointValKey?: string;
toYData?(point: Point): Array<number>;
}
}
interface KDNode {
[side: string]: (KDNode|Point|undefined);
left?: KDNode;
point: Point;
right?: KDNode;
}
interface KDPointSearchObject {
clientX: number;
plotY?: number;
}
/* *
*
* Class
*
* */
/**
* This is the base series prototype that all other series types inherit from.
* A new series is initialized either through the
* [series](https://api.highcharts.com/highcharts/series)
* option structure, or after the chart is initialized, through
* {@link Highcharts.Chart#addSeries}.
*
* The object can be accessed in a number of ways. All series and point event
* handlers give a reference to the `series` object. The chart object has a
* {@link Highcharts.Chart#series|series} property that is a collection of all
* the chart's series. The point objects and axis objects also have the same
* reference.
*
* Another way to reference the series programmatically is by `id`. Add an id
* in the series configuration options, and get the series object by
* {@link Highcharts.Chart#get}.
*
* Configuration options for the series are given in three levels. Options for
* all series in a chart are given in the
* [plotOptions.series](https://api.highcharts.com/highcharts/plotOptions.series)
* object. Then options for all series of a specific type
* are given in the plotOptions of that type, for example `plotOptions.line`.
* Next, options for one single series are given in the series array, or as
* arguments to `chart.addSeries`.
*
* The data in the series is stored in various arrays.
*
* - First, `series.options.data` contains all the original config options for
* each point whether added by options or methods like `series.addPoint`.
*
* - Next, `series.data` contains those values converted to points, but in case
* the series data length exceeds the `cropThreshold`, or if the data is
* grouped, `series.data` doesn't contain all the points. It only contains the
* points that have been created on demand.
*
* - Then there's `series.points` that contains all currently visible point
* objects. In case of cropping, the cropped-away points are not part of this
* array. The `series.points` array starts at `series.cropStart` compared to
* `series.data` and `series.options.data`. If however the series data is
* grouped, these can't be correlated one to one.
*
* - `series.xData` and `series.processedXData` contain clean x values,
* equivalent to `series.data` and `series.points`.
*
* - `series.yData` and `series.processedYData` contain clean y values,
* equivalent to `series.data` and `series.points`.
*
* @class
* @name Highcharts.Series
*
* @param {Highcharts.Chart} chart
* The chart instance.
*
* @param {Highcharts.SeriesOptionsType|object} options
* The series options.
*/
class Series {
/* *
*
* Static Properties
*
* */
public static readonly defaultOptions = SeriesDefaults;
/**
* Registry of all available series types.
*
* @name Highcharts.Series.types
* @type {Highcharts.Dictionary<typeof_Highcharts.Series>}
*/
public static readonly types = SeriesRegistry.seriesTypes;
/* *
*
* Static Functions
*
* */
/**
* Registers a series class to be accessible via `Series.types`.
*
* @function Highcharts.Series.registerType
*
* @param {string} seriesType
* The series type as an identifier string in lower case.
*
* @param {Function} SeriesClass
* The series class as a class pattern or a constructor function with
* prototype.
*/
public static readonly registerType = SeriesRegistry.registerSeriesType;
/* *
*
* Properties
*
* */
public _hasTracking?: boolean;
public _i: number = void 0 as any;
public animationTimeout?: number;
public area?: SVGElement;
public basePointRange?: number;
public buildingKdTree?: boolean;
public chart: Chart = void 0 as any;
public clips?: Array<SVGElement>;
public closestPointRange?: number;
public closestPointRangePx?: number;
public color?: (ColorType);
public colorIndex?: number;
public cropped?: boolean;
public data: Array<Point> = void 0 as any;
public dataMax?: number;
public dataMin?: number;
public enabledDataSorting?: boolean;
public fillColor?: ColorType;
public finishedAnimating?: boolean;
public getExtremesFromAll?: boolean;
public graph?: SVGElement;
public graphPath?: SVGPath;
public group?: SVGElement;
public eventOptions: Record<string, EventCallback<Series, Event>> = void 0 as any;
public eventsToUnbind: Array<Function> = void 0 as any;
public halo?: SVGElement;
public hasCartesianSeries?: Chart['hasCartesianSeries'];
public hasRendered?: boolean;
public id?: string;
public index: number = void 0 as any;
public initialType?: string;
public isDirty?: boolean;
public isDirtyData?: boolean;
public isRadialSeries?: boolean;
public kdTree?: KDNode;
public linkedParent?: Series;
public linkedSeries: Array<Series> = void 0 as any;
public options: SeriesOptions = void 0 as any;
public markerGroup?: SVGElement;
public opacity?: number;
public optionalAxis?: string;
public pointInterval?: number;
public points: Array<Point> = void 0 as any;
public pointValKey?: string;
public processedXData: Array<number> = void 0 as any;
public processedYData: (Array<(number|null)>|Array<Array<(number|null)>>) = void 0 as any;
public selected?: boolean;
public sharedClipKey?: string;
public stateMarkerGraphic?: SVGElement;
public stickyTracking?: boolean;
public symbol?: SymbolKey;
public tooltipOptions: TooltipOptions = void 0 as any;
public tracker?: SVGElement;
public trackerGroups?: Array<string>;
public userOptions: DeepPartial<SeriesTypeOptions> = void 0 as any;
public xAxis: AxisType = void 0 as any;
public xData?: Array<number>;
public xIncrement?: (number|null);
public yAxis: AxisType = void 0 as any;
public yData?: (
Array<(number|null)>|
Array<Array<(number|null)>>
);
public zoneAxis?: string;
public zones: Array<SeriesZonesOptions> = void 0 as any;
/* *
*
* Functions
*
* */
/* eslint-disable valid-jsdoc */
public init(
chart: Chart,
userOptions: DeepPartial<SeriesTypeOptions>
): void {
fireEvent(this, 'init', { options: userOptions });
const series = this,
chartSeries = chart.series;
// The 'eventsToUnbind' property moved from prototype into the
// Series init to avoid reference to the same array between
// the different series and charts. #12959, #13937
this.eventsToUnbind = [];
/**
* Read only. The chart that the series belongs to.
*
* @name Highcharts.Series#chart
* @type {Highcharts.Chart}
*/
series.chart = chart;
/**
* Read only. The series' type, like "line", "area", "column" etc.
* The type in the series options anc can be altered using
* {@link Series#update}.
*
* @name Highcharts.Series#type
* @type {string}
*/
/**
* Read only. The series' current options. To update, use
* {@link Series#update}.
*
* @name Highcharts.Series#options
* @type {Highcharts.SeriesOptionsType}
*/
series.options = series.setOptions(userOptions);
const options = series.options;
series.linkedSeries = [];
// bind the axes
series.bindAxes();
extend<Series>(series, {
/**
* The series name as given in the options. Defaults to
* "Series {n}".
*
* @name Highcharts.Series#name
* @type {string}
*/
name: options.name,
state: '',
/**
* Read only. The series' visibility state as set by {@link
* Series#show}, {@link Series#hide}, or in the initial
* configuration.
*
* @name Highcharts.Series#visible
* @type {boolean}
*/
visible: options.visible !== false, // true by default
/**
* Read only. The series' selected state as set by {@link
* Highcharts.Series#select}.
*
* @name Highcharts.Series#selected
* @type {boolean}
*/
selected: options.selected === true // false by default
});
registerEventOptions(this, options);
const events = options.events;
if (
(events && events.click) ||
(
options.point &&
options.point.events &&
options.point.events.click
) ||
options.allowPointSelect
) {
chart.runTrackerClick = true;
}
series.getColor();
series.getSymbol();
// Initialize the parallel data arrays
series.parallelArrays.forEach(function (key: string): void {
if (!(series as any)[key + 'Data']) {
(series as any)[key + 'Data'] = [];
}
});
// Mark cartesian
if (series.isCartesian) {
chart.hasCartesianSeries = true;
}
// Get the index and register the series in the chart. The index is
// one more than the current latest series index (#5960).
let lastSeries: Series|undefined;
if (chartSeries.length) {
lastSeries = chartSeries[chartSeries.length - 1];
}
series._i = pick(lastSeries && lastSeries._i, -1) + 1;
series.opacity = series.options.opacity;
// Insert the series and re-order all series above the insertion
// point.
chart.orderSeries(this.insert(chartSeries));
// Set options for series with sorting and set data later.
if (options.dataSorting && options.dataSorting.enabled) {
series.setDataSortingOptions();
} else if (!series.points && !series.data) {
series.setData(options.data as any, false);
}
fireEvent(this, 'afterInit');
}
/**
* Check whether the series item is itself or inherits from a certain
* series type.
*
* @function Highcharts.Series#is
* @param {string} type The type of series to check for, can be either
* featured or custom series types. For example `column`, `pie`,
* `ohlc` etc.
*
* @return {boolean}
* True if this item is or inherits from the given type.
*/
public is(type: string): boolean {
return seriesTypes[type] && this instanceof seriesTypes[type];
}
/**
* Insert the series in a collection with other series, either the chart
* series or yAxis series, in the correct order according to the index
* option. Used internally when adding series.
*
* @private
* @function Highcharts.Series#insert
* @param {Array<Highcharts.Series>} collection
* A collection of series, like `chart.series` or `xAxis.series`.
* @return {number}
* The index of the series in the collection.
*/
public insert(collection: Array<Series>): number {
const indexOption = this.options.index;
let i: any;
// Insert by index option
if (isNumber(indexOption)) {
i = collection.length;
while (i--) {
// Loop down until the interted element has higher index
if ((indexOption as any) >=
pick(collection[i].options.index, collection[i]._i)
) {
collection.splice(i + 1, 0, this);
break;
}
}
if (i === -1) {
collection.unshift(this);
}
i = i + 1;
// Or just push it to the end
} else {
collection.push(this);
}
return pick(i, collection.length - 1);
}
/**
* Set the xAxis and yAxis properties of cartesian series, and register
* the series in the `axis.series` array.
*
* @private
* @function Highcharts.Series#bindAxes
*/
public bindAxes(): void {
const series = this,
seriesOptions = series.options,
chart = series.chart;
let axisOptions;
fireEvent(this, 'bindAxes', null as any, function (): void {
// repeat for xAxis and yAxis
(series.axisTypes || []).forEach(function (AXIS: string): void {
let index = 0;
// loop through the chart's axis objects
(chart as any)[AXIS].forEach(function (axis: Axis): void {
axisOptions = axis.options;
// apply if the series xAxis or yAxis option mathches
// the number of the axis, or if undefined, use the
// first axis
if (
(
(seriesOptions as any)[AXIS] === index &&
!axisOptions.isInternal
) ||
(
typeof (seriesOptions as any)[AXIS] !==
'undefined' &&
(seriesOptions as any)[AXIS] === axisOptions.id
) ||
(
typeof (seriesOptions as any)[AXIS] ===
'undefined' &&
axisOptions.index === 0
)
) {
// register this series in the axis.series lookup
series.insert(axis.series);
// set this series.xAxis or series.yAxis reference
/**
* Read only. The unique xAxis object associated
* with the series.
*
* @name Highcharts.Series#xAxis
* @type {Highcharts.Axis}
*/
/**
* Read only. The unique yAxis object associated
* with the series.
*
* @name Highcharts.Series#yAxis
* @type {Highcharts.Axis}
*/
(series as any)[AXIS] = axis;
// mark dirty for redraw
axis.isDirty = true;
}
if (!axisOptions.isInternal) {
index++;
}
});
// The series needs an X and an Y axis
if (!(series as any)[AXIS] &&
series.optionalAxis !== AXIS
) {
error(18, true, chart);
}
});
});
fireEvent(this, 'afterBindAxes');
}
/**
* For simple series types like line and column, the data values are
* held in arrays like xData and yData for quick lookup to find extremes
* and more. For multidimensional series like bubble and map, this can
* be extended with arrays like zData and valueData by adding to the
* `series.parallelArrays` array.
*
* @private
* @function Highcharts.Series#updateParallelArrays
*/
public updateParallelArrays(
point: Point,
i: (number|string),
iArgs?: Array<any>
): void {
const series = point.series,
fn = isNumber(i) ?
// Insert the value in the given position
function (key: string): void {
const val = key === 'y' && series.toYData ?
series.toYData(point) :
(point as any)[key];
(series as any)[key + 'Data'][i] = val;
} :
// Apply the method specified in i with the following
// arguments as arguments
function (key: string): void {
(Array.prototype as any)[i].apply(
(series as any)[key + 'Data'],
iArgs
);
};
series.parallelArrays.forEach(fn);
}
/**
* Define hasData functions for series. These return true if there
* are data points on this series within the plot area.
*
* @private
* @function Highcharts.Series#hasData
*/
public hasData(): boolean {
return ((
this.visible &&
typeof this.dataMax !== 'undefined' &&
typeof this.dataMin !== 'undefined'
) || ( // #3703
this.visible &&
(this.yData as any) &&
(this.yData as any).length > 0) // #9758
);
}
/**
* Return an auto incremented x value based on the pointStart and
* pointInterval options. This is only used if an x value is not given
* for the point that calls autoIncrement.
*
* @private
* @function Highcharts.Series#autoIncrement
*/
public autoIncrement(x?: number): number {
const options = this.options,
pointIntervalUnit = options.pointIntervalUnit,
relativeXValue = options.relativeXValue,
time = this.chart.time;
let xIncrement = this.xIncrement,
date,
pointInterval: number;
xIncrement = pick(xIncrement, options.pointStart, 0);
this.pointInterval = pointInterval = pick(
this.pointInterval,
options.pointInterval,
1
);
if (relativeXValue && isNumber(x)) {
pointInterval *= x;
}
// Added code for pointInterval strings
if (pointIntervalUnit) {
date = new time.Date(xIncrement);
if (pointIntervalUnit === 'day') {
time.set(
'Date',
date,
time.get('Date', date) + pointInterval
);
} else if (pointIntervalUnit === 'month') {
time.set(
'Month',
date,
time.get('Month', date) + pointInterval
);
} else if (pointIntervalUnit === 'year') {
time.set(
'FullYear',
date,
time.get('FullYear', date) + pointInterval
);
}
pointInterval = date.getTime() - xIncrement;
}
if (relativeXValue && isNumber(x)) {
return xIncrement + pointInterval;
}
this.xIncrement = xIncrement + pointInterval;
return xIncrement;
}
/**
* Internal function to set properties for series if data sorting is
* enabled.
*
* @private
* @function Highcharts.Series#setDataSortingOptions
*/
public setDataSortingOptions(): void {
const options = this.options;
extend<Series>(this, {
requireSorting: false,
sorted: false,
enabledDataSorting: true,
allowDG: false
});
// To allow unsorted data for column series.
if (!defined(options.pointRange)) {
options.pointRange = 1;
}
}
/**
* Set the series options by merging from the options tree. Called
* internally on initializing and updating series. This function will
* not redraw the series. For API usage, use {@link Series#update}.
* @private
* @function Highcharts.Series#setOptions
* @param {Highcharts.SeriesOptionsType} itemOptions
* The series options.
* @emits Highcharts.Series#event:afterSetOptions
*/
public setOptions(itemOptions: DeepPartial<SeriesTypeOptions>): this['options'] {
const chart = this.chart,
chartOptions = chart.options,
plotOptions = chartOptions.plotOptions,
userOptions = chart.userOptions || {},
seriesUserOptions = merge(itemOptions),
styledMode = chart.styledMode,
e = {
plotOptions: plotOptions,
userOptions: seriesUserOptions
};
let zone;
fireEvent(this, 'setOptions', e);
// These may be modified by the event
const typeOptions = (e.plotOptions as any)[this.type],
userPlotOptions = (
userOptions.plotOptions || {} as SeriesTypePlotOptions
),
typeUserPlotOptions = userPlotOptions && userPlotOptions[this.type];
// use copy to prevent undetected changes (#9762)
/**
* Contains series options by the user without defaults.
* @name Highcharts.Series#userOptions
* @type {Highcharts.SeriesOptionsType}
*/
this.userOptions = e.userOptions;
const options: SeriesTypeOptions = merge(
typeOptions,
plotOptions && plotOptions.series,
// #3881, chart instance plotOptions[type] should trump
// plotOptions.series
typeUserPlotOptions,
seriesUserOptions
),
defaultTypePlotOptions = defaultOptions.plotOptions &&
defaultOptions.plotOptions[this.type],
typePlotOptions = plotOptions && plotOptions[this.type];
// The tooltip options are merged between global and series specific
// options. Importance order asscendingly:
// globals: (1)tooltip, (2)plotOptions.series,
// (3)plotOptions[this.type]
// init userOptions with possible later updates: 4-6 like 1-3 and
// (7)this series options
this.tooltipOptions = merge(
defaultOptions.tooltip, // 1
(
defaultOptions.plotOptions &&
defaultOptions.plotOptions.series &&
defaultOptions.plotOptions.series.tooltip
), // 2
defaultTypePlotOptions && defaultTypePlotOptions.tooltip, // 3
(
defaultOptions.tooltip &&
chartOptions.tooltip &&
cleanRecursively(chartOptions.tooltip, defaultOptions.tooltip)
), // 4 - #18876 take only "userOptions" (calculate them)
(
plotOptions &&
plotOptions.series &&
plotOptions.series.tooltip
), // 5
typePlotOptions && typePlotOptions.tooltip, // 6
seriesUserOptions.tooltip // 7
);
// When shared tooltip, stickyTracking is true by default,
// unless user says otherwise.
this.stickyTracking = pick(
seriesUserOptions.stickyTracking,
typeUserPlotOptions && typeUserPlotOptions.stickyTracking,
userPlotOptions.series && userPlotOptions.series.stickyTracking,
(
this.tooltipOptions.shared && !this.noSharedTooltip ?
true :
options.stickyTracking
)
);
// Delete marker object if not allowed (#1125)
if (typeOptions.marker === null) {
delete options.marker;
}
// Handle color zones
this.zoneAxis = options.zoneAxis;
const zones = this.zones = (options.zones || []).slice();
if (
(options.negativeColor || options.negativeFillColor) &&
!options.zones
) {
zone = {
value:
(options as any)[this.zoneAxis + 'Threshold'] ||
options.threshold ||
0,
className: 'highcharts-negative'
} as SeriesZonesOptions;
if (!styledMode) {
zone.color = options.negativeColor;
zone.fillColor = options.negativeFillColor;
}
zones.push(zone);
}
if (zones.length) { // Push one extra zone for the rest
if (defined(zones[zones.length - 1].value)) {
zones.push(styledMode ? {} : {
color: this.color,
fillColor: this.fillColor
});
}
}
fireEvent(this, 'afterSetOptions', { options: options });
return options;
}
/**
* Return series name in "Series {Number}" format or the one defined by
* a user. This method can be simply overridden as series name format
* can vary (e.g. technical indicators).
*
* @function Highcharts.Series#getName
*
* @return {string}
* The series name.
*/
public getName(): string {
// #4119
return pick(
this.options.name,
'Series ' + ((this.index as any) + 1)
);
}
/**
* @private
* @function Highcharts.Series#getCyclic
*/
public getCyclic(
prop: string,
value?: any,
defaults?: AnyRecord
): void {
const chart = this.chart,
userOptions = this.userOptions,
indexName = prop + 'Index',
counterName = prop + 'Counter',
len = defaults ? defaults.length : pick(
(chart.options.chart as any)[prop + 'Count'],
(chart as any)[prop + 'Count']
);
let i,
setting;
if (!value) {
// Pick up either the colorIndex option, or the _colorIndex
// after Series.update()
setting = pick(
(userOptions as any)[indexName],
(userOptions as any)['_' + indexName]
);
if (defined(setting)) { // after Series.update()
i = setting;
} else {
// #6138
if (!chart.series.length) {
(chart as any)[counterName] = 0;
}
(userOptions as any)['_' + indexName] = i =
(chart as any)[counterName] % len;
(chart as any)[counterName] += 1;
}
if (defaults) {
value = defaults[i];
}
}
// Set the colorIndex
if (typeof i !== 'undefined') {
(this as any)[indexName] = i;
}
(this as any)[prop] = value;