forked from syncfusion/ej2-javascript-ui-controls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchart3D.ts
2984 lines (2877 loc) · 117 KB
/
chart3D.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
import { Component, Property, NotifyPropertyChanges, Internationalization, INotifyPropertyChanged, remove, Complex, Collection, ModuleDeclaration, Browser, EventHandler, TapEventArgs, extend, Animation, AnimationOptions, AnimationModel, animationMode } from '@syncfusion/ej2-base';
import { L10n, isNullOrUndefined, Touch } from '@syncfusion/ej2-base';
import { Event, EmitType } from '@syncfusion/ej2-base';
import { Chart3DModel } from './chart3D-model';
import { Rect, Size, SvgRenderer, TextOption, measureText, removeElement } from '@syncfusion/ej2-svg-base';
import { ImageOption, RectOption, appendChildElement, createSvg, getElement, getTextAnchor, getTitle, redrawElement, textElement, titlePositionX, showTooltip, appendClipElement, getAnimationFunction, withInBounds } from '../common/utils/helper';
import { beforeResize, load, pointClick, pointMove, resized } from '../common/model/constants';
import { Chart3DBoderElements, Chart3DLoadedEventArgs, Chart3DThemeStyle, Chart3DBeforeResizeEventArgs, Chart3DLegendClickEventArgs, Chart3DLegendRenderEventArgs, Chart3DPointRenderEventArgs, Chart3DResizeEventArgs, Chart3DTooltipRenderEventArgs } from './model/chart3d-Interface';
import { Chart3DSeriesRenderEventArgs, Chart3DAxisLabelRenderEventArgs, Chart3DExportEventArgs, Chart3DMouseEventArgs, Chart3DPointEventArgs, Chart3DPrintEventArgs, Chart3DSelectionCompleteEventArgs, Chart3DTextRenderEventArgs, Chart3DPolygon } from './model/chart3d-Interface';
import { CartesianAxisLayoutPanel } from './axis/cartesian-panel';
import { get3DSeriesColor, get3DThemeColor } from './model/theme';
import { Border, Indexes, Margin, titleSettings } from '../common/model/base';
import { BorderModel, IndexesModel, MarginModel } from '../common/model/base-model';
import { titleSettingsModel } from '../common/model/base-model';
import { Alignment, HighlightMode, SelectionPattern, ExportType, ChartTheme } from '../common/utils/enum';
import { Vector3D, Matrix3D, Graphics3D, BinaryTreeBuilder, Polygon3D, ChartTransform3D, Svg3DRenderer, Chart3DRender } from './utils/chart3dRender';
import { AxisRenderer, WallRenderer } from './utils/renderer';
import { Chart3DAxisModel, Chart3DColumnModel, Chart3DRowModel } from './axis/axis-model';
import { Chart3DAxis, Chart3DColumn, Chart3DRow } from './axis/axis';
import { DataManager } from '@syncfusion/ej2-data';
import { Data } from '../common/model/data';
import { Chart3DPoint, Chart3DSeries } from './series/chart-series';
import { DataLabel3D } from './series/data-label';
import { Chart3DTooltipSettings, Tooltip3D } from './user-interaction/tooltip';
import { Legend3D, Chart3DLegendSettings } from './legend/legend';
import { Highlight3D } from './user-interaction/high-light';
import { Selection3D } from './user-interaction/selection';
import { Export3D } from './print-export/export';
import { Chart3DSeriesModel } from './series/chart-series-model';
import { PrintUtils } from '../common/utils/print';
import { IAfterExportEventArgs } from '../common/model/interface';
import { Chart3DSelectionMode } from './utils/enum';
import { Chart3DTooltipSettingsModel } from './user-interaction/tooltip-model';
import { Chart3DLegendSettingsModel } from './legend/legend-model';
/**
* The Chart3D class represents a 3D chart component that extends the Component class
* and implements the INotifyPropertyChanged interface.
*
* @public
* @class
* @extends Component<HTMLElement>
* @implements {INotifyPropertyChanged} INotifyPropertyChanged
*/
@NotifyPropertyChanges
export class Chart3D extends Component<HTMLElement> implements INotifyPropertyChanged {
/**
* Title of the chart
*
* @default ''
*/
@Property('')
public title: string;
/**
* SubTitle of the chart.
*
* @default ''
*/
@Property('')
public subTitle: string;
/**
* Specifies the theme for the chart.
*
* @default 'Bootstrap5'
*/
@Property('Bootstrap5')
public theme: ChartTheme;
/**
* Description for chart.
*
* @default null
*/
@Property(null)
public description: string;
/**
* The width of the chart as a string accepts input as both like '100px' or '100%'.
* If specified as '100%, chart renders to the full width of its parent element.
*
* @default null
*/
@Property(null)
public width: string;
/**
* The background image of the chart that accepts value in string as url link or location of an image.
*
* @default null
*/
@Property(null)
public backgroundImage: string;
/**
* The background color of the chart that accepts value in hex and rgba as a valid CSS color string.
*
* @default null
*/
@Property(null)
public background: string;
/**
* Specifies the DataSource for the chart. It can be an array of JSON objects or an instance of DataManager.
* ```html
* <div id='Chart'></div>
* ```
* ```typescript
* let dataManager: DataManager = new DataManager({
* url: 'http://mvc.syncfusion.com/Services/Northwnd.svc/Tasks/'
* });
* let query: Query = new Query().take(50).where('Estimate', 'greaterThan', 0, false);
* let chart3D: Chart3D = new Chart3D({
* ...
* dataSource:dataManager,
* series: [{
* xName: 'Id',
* yName: 'Estimate',
* query: query
* }],
* ...
* });
* chart3D.appendTo('#Chart');
* ```
*
* @default ''
*/
@Property('')
public dataSource: Object | DataManager;
/**
* The height of the chart as a string accepts input both as '100px' or '100%'.
* If specified as '100%, chart renders to the full height of its parent element.
*
* @default null
*/
@Property(null)
public height: string;
/**
* Depth of the 3D Chart from front view of the series to the background wall.
*
* @default 50
*/
@Property(50)
public depth: number;
/**
* Defines the width of the 3D chart wall.
*
* @default 2
*/
@Property(2)
public wallSize: number;
/**
* Defines the slope angle for the 3D chart.
*
* @default 0
*/
@Property(0)
public tilt: number;
/**
* If set true, enables the rotation in the 3D chart.
*
* @default false
*/
@Property(false)
public enableRotation: boolean;
/**
* Defines the rotating angle for the 3D chart.
*
* @default 0
*/
@Property(0)
public rotation: number;
/**
* To enable the side by side placing the points for column type series.
*
* @default true
*/
@Property(true)
public enableSideBySidePlacement: boolean;
/**
* Defines the perspective angle for the 3D chart.
*
* @default 90
*/
@Property(90)
public perspectiveAngle: number;
/**
* Represents the color of the 3D wall.
*
* @default null
*/
@Property(null)
public wallColor: string;
/**
* It specifies whether the chart should be render in transposed manner or not.
*
* @default false
*/
@Property(false)
public isTransposed: boolean;
/**
* Defines the currencyCode format of the chart
*
* @private
* @aspType string
*/
@Property('USD')
private currencyCode: string;
/**
* Triggered before the chart is loaded.
*
* @event load
*/
@Event()
public load: EmitType<Chart3DLoadedEventArgs>;
/**
* Triggered after the chart is loaded.
*
* @event loaded
*/
@Event()
public loaded: EmitType<Chart3DLoadedEventArgs>;
/**
* Triggered when the user clicks on data points.
*
* @event pointClick
*
*/
@Event()
public pointClick: EmitType<Chart3DPointEventArgs>;
/**
* Triggered when the user hovers over data points.
*
* @event pointMove
*
*/
@Event()
public pointMove: EmitType<Chart3DPointEventArgs>;
/**
* Triggered when the data point is ready to render on the screen.
*
* @event pointRender
* @deprecated
*/
@Event()
public pointRender: EmitType<Chart3DPointRenderEventArgs>;
/**
* Triggered when the legend is ready to render on the screen.
*
* @event legendRender
* @deprecated
*
*/
@Event()
public legendRender: EmitType<Chart3DLegendRenderEventArgs>;
/**
* Triggered when the user clicks on the legend.
*
* @event legendClick
*/
@Event()
public legendClick: EmitType<Chart3DLegendClickEventArgs>;
/**
* Triggered when the series is ready to render on the screen.
*
* @event seriesRender
* @deprecated
*/
@Event()
public seriesRender: EmitType<Chart3DSeriesRenderEventArgs>;
/**
* Triggered when the data label is ready to render on the screen.
*
* @event textRender
* @deprecated
*/
@Event()
public textRender: EmitType<Chart3DTextRenderEventArgs>;
/**
* Triggered when the tooltip is ready to render on the screen.
*
* @event tooltipRender
*/
@Event()
public tooltipRender: EmitType<Chart3DTooltipRenderEventArgs>;
/**
* Triggers before resizing of chart
*
* @event beforeResize
*
*/
@Event()
public beforeResize: EmitType<Chart3DBeforeResizeEventArgs>;
/**
* Triggers after resizing of chart.
*
* @event resized
*
*/
@Event()
public resized: EmitType<Chart3DResizeEventArgs>;
/**
* Triggered when the user hovers over a 3D chart.
*
* @event chart3DMouseMove
*
*/
@Event()
public chart3DMouseMove: EmitType<Chart3DMouseEventArgs>;
/**
* Triggered when the user clicks on a 3D chart.
*
* @event chart3DMouseClick
*
*/
@Event()
public chart3DMouseClick: EmitType<Chart3DMouseEventArgs>;
/**
* Triggered when the mouse is pressed down on a 3D chart.
*
* @event chart3DMouseDown
*
*/
@Event()
public chart3DMouseDown: EmitType<Chart3DMouseEventArgs>;
/**
* Triggered when the cursor leaves a 3D chart.
*
* @event chart3DMouseLeave
*
*/
@Event()
public chart3DMouseLeave: EmitType<Chart3DMouseEventArgs>;
/**
* Triggered when the mouse button is released on a 3D chart.
*
* @event chart3DMouseUp
*
*/
@Event()
public chart3DMouseUp: EmitType<Chart3DMouseEventArgs>;
/**
* Triggers before each axis label is rendered.
*
* @event axisLabelRender
* @deprecated
*/
@Event()
public axisLabelRender: EmitType<Chart3DAxisLabelRenderEventArgs>;
/**
* Triggers after the selection is completed.
*
* @event selectionComplete
*/
@Event()
public selectionComplete: EmitType<Chart3DSelectionCompleteEventArgs>;
/**
* Triggers before the export gets started.
*
* @event beforeExport
*/
@Event()
public beforeExport: EmitType<Chart3DExportEventArgs>;
/**
* Triggers after the export completed.
*
* @event afterExport
*/
@Event()
public afterExport: EmitType<IAfterExportEventArgs>;
/**
* Triggers before the prints gets started.
*
* @event beforePrint
*/
@Event()
public beforePrint: EmitType<Chart3DPrintEventArgs>;
/**
* Options to customize left, right, top and bottom margins of the chart.
*/
@Complex<MarginModel>({}, Margin)
public margin: MarginModel;
/**
* Options for customizing the title of the Chart.
*/
@Complex<titleSettingsModel>({ fontFamily: null, size: '16px', fontStyle: 'Normal', fontWeight: '600', color: null }, titleSettings)
public titleStyle: titleSettingsModel;
/**
* Options for customizing the Subtitle of the Chart.
*/
@Complex<titleSettingsModel>({ fontFamily: null, size: '14px', fontStyle: 'Normal', fontWeight: '400', color: null }, titleSettings)
public subTitleStyle: titleSettingsModel;
/**
* The chart legend configuration options.
*/
@Complex<Chart3DLegendSettingsModel>({}, Chart3DLegendSettings)
public legendSettings: Chart3DLegendSettingsModel;
/**
* Options for customizing the color and width of the chart border.
*/
@Complex<BorderModel>({ color: '#DDDDDD', width: 0 }, Border)
public border: BorderModel;
/**
* Options to configure the horizontal axis.
*/
@Complex<Chart3DAxisModel>({ name: 'primaryXAxis' }, Chart3DAxis)
public primaryXAxis: Chart3DAxisModel;
/**
* Options to configure the vertical axis.
*/
@Complex<Chart3DAxisModel>({ name: 'primaryYAxis' }, Chart3DAxis)
public primaryYAxis: Chart3DAxisModel;
/**
* The chart tooltip configuration options.
*/
@Complex<Chart3DTooltipSettingsModel>({}, Chart3DTooltipSettings)
public tooltip: Chart3DTooltipSettingsModel;
/**
* Options to split Chart into multiple plotting areas horizontally.
* Each object in the collection represents a plotting area in the Chart.
*/
@Collection<Chart3DRowModel>([{}], Chart3DRow)
public rows: Chart3DRowModel[];
/**
* Options to split chart into multiple plotting areas vertically.
* Each object in the collection represents a plotting area in the chart.
*/
@Collection<Chart3DColumnModel>([{}], Chart3DColumn)
public columns: Chart3DColumnModel[];
/**
* Secondary axis collection for the chart.
*/
@Collection<Chart3DAxisModel>([{}], Chart3DAxis)
public axes: Chart3DAxisModel[];
/**
* The configuration for series in the chart.
*/
@Collection<Chart3DSeriesModel>([{}], Chart3DSeries)
public series: Chart3DSeriesModel[];
/**
* Defines the color for the highlighted data point.
*
* @default ''
*/
@Property('')
public highlightColor: string;
/**
* Specifies whether a series or data point should be highlighted. The options are:
* * none: Disables the selection.
* * series: selects a series.
* * point: selects a point.
* * cluster: selects a cluster of point
*
* @default None
*/
@Property('None')
public selectionMode: Chart3DSelectionMode;
/**
* Specifies whether a series or data point should be highlighted. The options are:
* * none: Disables the highlight.
* * series: highlight a series.
* * point: highlight a point.
* * cluster: highlight a cluster of point
*
* @default None
*/
@Property('None')
public highlightMode: HighlightMode;
/**
* Specifies whether series or data point has to be selected. They are,
* * none: sets none as selecting pattern.
* * chessboard: sets chess board as selecting pattern.
* * dots: sets dots as selecting pattern.
* * diagonalForward: sets diagonal forward as selecting pattern.
* * crosshatch: sets crosshatch as selecting pattern.
* * pacman: sets pacman selecting pattern.
* * diagonalbackward: sets diagonal backward as selecting pattern.
* * grid: sets grid as selecting pattern.
* * turquoise: sets turquoise as selecting pattern.
* * star: sets star as selecting pattern.
* * triangle: sets triangle as selecting pattern.
* * circle: sets circle as selecting pattern.
* * tile: sets tile as selecting pattern.
* * horizontaldash: sets horizontal dash as selecting pattern.
* * verticaldash: sets vertical dash as selecting pattern.
* * rectangle: sets rectangle as selecting pattern.
* * box: sets box as selecting pattern.
* * verticalstripe: sets vertical stripe as selecting pattern.
* * horizontalstripe: sets horizontal stripe as selecting pattern.
* * bubble: sets bubble as selecting pattern.
*
* @default None
*/
@Property('None')
public selectionPattern: SelectionPattern;
/**
* Specifies whether series or data point has to be selected. They are,
* * none: sets none as highlighting pattern.
* * chessboard: sets chess board as highlighting pattern.
* * dots: sets dots as highlighting pattern.
* * diagonalForward: sets diagonal forward as highlighting pattern.
* * crosshatch: sets crosshatch as highlighting pattern.
* * pacman: sets pacman highlighting pattern.
* * diagonalbackward: sets diagonal backward as highlighting pattern.
* * grid: sets grid as highlighting pattern.
* * turquoise: sets turquoise as highlighting pattern.
* * star: sets star as highlighting pattern.
* * triangle: sets triangle as highlighting pattern.
* * circle: sets circle as highlighting pattern.
* * tile: sets tile as highlighting pattern.
* * horizontaldash: sets horizontal dash as highlighting pattern.
* * verticaldash: sets vertical dash as highlighting pattern.
* * rectangle: sets rectangle as highlighting pattern.
* * box: sets box as highlighting pattern.
* * verticalstripe: sets vertical stripe as highlighting pattern.
* * horizontalstripe: sets horizontal stripe as highlighting pattern.
* * bubble: sets bubble as highlighting pattern.
*
* @default None
*/
@Property('None')
public highlightPattern: SelectionPattern;
/**
* If set true, enables the multi selection in chart. It requires `selectionMode` to be `Point` | `Series` | or `Cluster`.
*
* @default false
*/
@Property(false)
public isMultiSelect: boolean;
/**
* Specifies the point indexes to be selected while loading a chart.
* It requires `selectionMode` or `highlightMode` to be `Point` | `Series` | or `Cluster`.
* ```html
* <div id='Chart'></div>
* ```
* ```typescript
* let chart3D: Chart3D = new Chart3D({
* ...
* selectionMode: 'Point',
* selectedDataIndexes: [ { series: 0, point: 1},
* { series: 2, point: 3} ],
* ...
* });
* chart3D.appendTo('#Chart');
* ```
*
* @default []
*/
@Collection<IndexesModel>([], Indexes)
public selectedDataIndexes: IndexesModel[];
/**
* Specifies whether a grouping separator should be used for a number.
*
* @default false
*/
@Property(false)
public useGroupingSeparator: boolean;
/**
* Palette for the chart series.
*
* @default []
*/
@Property([])
public palettes: string[];
/**
*
* Localization object.
*
* @private
*/
public localeObject: L10n;
/**
* Default values of localization values.
*/
private defaultLocalConstants: Object;
/**
* Gets the current visible series of the Chart.
*
* @hidden
*/
public visibleSeries: Chart3DSeries[];
/**
* Gets the current visible axis of the Chart.
*
* @hidden
*/
public axisCollections: Chart3DAxis[];
/**
* The `dataLabel3DModule` is used to manipulate and add data label to the series.
*/
public dataLabel3DModule: DataLabel3D;
/**
* The `tooltip3DModule` is used to manipulate and add tooltip to the series.
*/
public tooltip3DModule: Tooltip3D;
/**
* The `selection3DModule` is used to manipulate and add selection to the chart.
*/
public selection3DModule: Selection3D;
/**
* The `highlight3DModule` is used to manipulate and add highlight to the chart.
*/
public highlight3DModule: Highlight3D;
/**
* The Export Module is used to export chart.
*/
public export3DModule: Export3D;
/**
* The `legend3DModule` is used to manipulate and add legend to the chart.
*
* @private
*/
public legend3DModule: Legend3D;
private previousTargetId: string = '';
private currentPointIndex: number = 0;
private currentSeriesIndex: number = 0;
private currentLegendIndex: number = 0;
private isLegend: boolean;
public requireInvertedAxis: boolean;
/** @private */
public svgObject: Element;
/** @private */
public isTouch: boolean;
/** @private */
public renderer: SvgRenderer;
/** @private */
public svgRenderer: SvgRenderer;
/** @private */
public initialClipRect: Rect;
/** @private */
public seriesElements: Element;
/** @private */
public visibleSeriesCount: number;
/** @private */
public intl: Internationalization;
/** @private */
public dataLabelCollections: Rect[];
/** @private */
public dataLabelElements: Element;
/** @private */
public mouseX: number;
/** @private */
public mouseY: number;
/** @private */
public redraw: boolean;
/** @private */
public animateSeries: boolean;
/** @public */
public animated: boolean = false;
/** @public */
public duration: number;
/** @private */
public availableSize: Size;
/** @private */
public delayRedraw: boolean;
/** @private */
public mouseDownX: number;
/** @private */
public mouseDownY: number;
/** @private */
public previousMouseMoveX: number;
/** @private */
public previousMouseMoveY: number;
/** @private */
public isPointMouseDown: boolean = false;
private resizeTo: number;
/** @private */
public disableTrackTooltip: boolean;
/** @private */
public startMove: boolean;
/** @private */
public radius: number;
/** @private */
public visible: number = 0;
/** @private */
public clickCount: number = 0;
/** @private */
public maxPointCount: number = 0;
/** @private */
public singleClickTimer: number = 0;
/** @private */
public isRtlEnabled: boolean = false;
/** @private */
public scaleX: number = 1;
/** @private */
public scaleY: number = 1;
private titleCollection: string[];
private subTitleCollection: string[];
/** @private */
public themeStyle: Chart3DThemeStyle;
private chartId: number = 57723;
/** @private */
public svgId: string;
/** @private */
public chart3D: Element;
/** @private */
public isRedrawSelection: boolean;
/**
* Touch object to unwire the touch event from element.
*/
private touchObject: Touch;
/** @private */
// eslint-disable-next-line
public resizeBound: any;
/** @private */
// eslint-disable-next-line
public longPressBound: any;
/** @private */
public isLegendClicked: boolean = false;
// Internal variables
private htmlObject: HTMLElement;
/** @private */
public vector: Vector3D;
/** @private */
public wallRender: WallRenderer;
/** @private */
public matrixObj: Matrix3D;
/** @private */
public bspTreeObj: BinaryTreeBuilder;
/** @private */
public polygon: Polygon3D;
/** @private */
public graphics: Graphics3D;
/** @private */
public transform3D: ChartTransform3D;
/** @private */
public svg3DRenderer: Svg3DRenderer;
/** @private */
public axisRender: AxisRenderer;
/** @private */
public chart3DRender: Chart3DRender;
/** @private */
public rotateActivate: boolean = false;
/** @private */
public isRemove: boolean = false;
/** @private */
public previousCoords: { x: number; y: number; };
/** @private */
public polygons: Chart3DPolygon[] = [];
/** @private */
public currentSeries: Chart3DSeries;
/**
* Render panel for chart.
*
* @hidden
*/
public chartAxisLayoutPanel: CartesianAxisLayoutPanel;
/**
* Gets all the horizontal axis of the Chart.
*
* @hidden
*/
public horizontalAxes: Chart3DAxis[];
/**
* Gets all the vertical axis of the Chart.
*
* @hidden
*/
public verticalAxes: Chart3DAxis[];
/**
* Constructor for creating the 3D chart
*
* @param {Chart3DModel} options - Specifies the 3D chart model.
* @param {string | HTMLElement} element - Specifies the element for the 3D chart.
* @hidden
*/
constructor(options?: Chart3DModel, element?: string | HTMLElement) {
super(options, <HTMLElement | string>element);
}
/**
* Checks if the given elementId has special characters and modifies it if necessary.
*
* @param {string} elementId - The input elementId to be checked.
* @returns {string} - The modified elementId.
*/
private isIdHasSpecialCharacter(elementId: string): string {
const regex: RegExp = /^[A-Za-z ]+$/;
const numberRegex: RegExp = /^[0-9 ]+$/;
let childElementId: string = '';
if (!regex.test(elementId)) {
let start: number = 0;
if (numberRegex.test(elementId[0])) {
childElementId += ('\\3' + elementId[0]);
start = 1;
}
for (let i: number = start; i < elementId.length; i++) {
if (!regex.test(elementId[i as number]) && elementId.indexOf('-') === -1 &&
elementId.indexOf('_') === -1 && elementId.indexOf('\\') === -1 && !numberRegex.test(elementId[i as number])) {
childElementId += ('\\' + elementId[i as number]);
} else {
childElementId += elementId[i as number];
}
}
return childElementId;
} else {
return elementId;
}
}
/**
* For internal use only - Initialize the event handler;
*
* @returns {void}
*/
protected preRender(): void {
this.element.id = this.isIdHasSpecialCharacter(this.element.id);
this.allowServerDataBinding = false;
this.unWireEvents();
this.initPrivateVariable();
this.setCulture();
this.wireEvents();
this.element.setAttribute('dir', this.enableRtl ? 'rtl' : '');
}
/**
* Initializes private variables and prepares the chart component for rendering.
*
* @returns {void}
*/
private initPrivateVariable(): void {
this.delayRedraw = false;
this.animateSeries = true;
this.horizontalAxes = [];
this.verticalAxes = [];
this.polygons = [];
this.vector = new Vector3D(0, 0, 0);
this.wallRender = new WallRenderer();
this.matrixObj = new Matrix3D();
this.bspTreeObj = new BinaryTreeBuilder();
this.polygon = new Polygon3D();
this.graphics = new Graphics3D();
this.transform3D = new ChartTransform3D();
this.svg3DRenderer = new Svg3DRenderer();
this.axisRender = new AxisRenderer();
this.chart3DRender = new Chart3DRender();
this.chartAxisLayoutPanel = new CartesianAxisLayoutPanel(this);
this.refreshAxis();
this.refreshDefinition(<Chart3DRow[]>this.rows);
this.refreshDefinition(<Chart3DColumn[]>this.columns);
if (this.tooltip3DModule) {
this.tooltip3DModule.previousPoints = [];
}
this.element.setAttribute('role', 'region');
this.element.setAttribute('tabindex', '0');
this.element.setAttribute('aria-label', this.description || this.title + '. Syncfusion interactive chart.');
if (!(this.element.classList.contains('e-chart-focused'))) {
this.element.setAttribute('class', this.element.getAttribute('class') + ' e-chart-focused');
}
if (this.element.id === '') {
const collection: number = document.getElementsByClassName('e-chart').length;
this.element.id = 'chart_' + this.chartId + '_' + collection;
}
this.svgId = this.element.id + '_svg';
}
/**
* Method to set culture for chart.
*
* @returns {void}
*/
private setCulture(): void {
this.intl = new Internationalization();
this.localeObject = new L10n(this.getModuleName(), this.defaultLocalConstants, this.locale);
}
/**
* To Initialize the 3D chart rendering.
*
* @returns {void}
*/
protected render(): void {
this.svgRenderer = new SvgRenderer(this.element.id);
const loadEventData: Chart3DLoadedEventArgs = {
chart: this, theme: this.theme, cancel: false
};
/**
* Load event for the 3D chart componet.
*/
this.trigger(load, loadEventData, () => {
if (!loadEventData.cancel) {
this.cartesianChartRendering();
}
});
}
/**
* Renders the chart using a Cartesian coordinate system.
*
* This function is responsible for rendering the chart's graphical elements and data points using a Cartesian coordinate system.
* It may include actions such as drawing axes, plotting data, and applying visual styles.
*
* @returns {void}
*/
private cartesianChartRendering(): void {
this.setTheme();
this.createChartSvg();
this.calculateVisibleSeries();
this.calculateVisibleAxis();
this.processData();
this.renderComplete();
this.allowServerDataBinding = true;
}
/**
* Method to create SVG element.
*
* @returns {void}
*/
public createChartSvg(): void {
this.removeSvg();
createSvg(this);
}
/**
* Method to remove the SVG.
*
* @returns {void}
* @private
*/
public removeSvg(): void {
if (this.redraw) {
return null;
}
removeElement(this.element.id + '_Secondary_Element');
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if ((this as any).isReact) { this.clearTemplate(); }
const removeLength: number = 0;
if (this.svgObject) {
while (this.svgObject.childNodes.length > removeLength) {
this.svgObject.removeChild(this.svgObject.firstChild);
}
if (!this.svgObject.hasChildNodes() && this.svgObject.parentNode) {
remove(this.svgObject);
}
}
}
/**
* Processes and prepares data for rendering.
*
* @param {boolean} render - (Optional) Indicates whether to trigger rendering after data processing.
* @returns {void}
*/
private processData(render: boolean = true): void {
this.visibleSeriesCount = 0;
const check: boolean = true;
for (const series of this.visibleSeries) {
if (!series.visible && !this.legendSettings.visible) {
this.visibleSeriesCount++;
continue;
}
this.initializeDataModule(series);
}
if (render && (!this.visibleSeries.length || this.visibleSeriesCount === this.visibleSeries.length && check)) {
this.refreshBound();
this.trigger('loaded', { chart: this });
}
}
/**
* Initializes the data module for a three-dimensional series.
*
* @param {Chart3DSeries} series - The series for which data module is initialized.
* @returns {void}
*/
private initializeDataModule(series: Chart3DSeries): void {
series.xData = []; series.yData = [];
let dataSource: Object | DataManager;
const isAngular: string = 'isAngular';
if (this[isAngular as string]) {
dataSource = Object.keys(series.dataSource).length ? series.dataSource : this.dataSource;
} else {
dataSource = series.dataSource || this.dataSource;
}
series.dataModule = new Data(dataSource, series.query);
series.points = [];
series.refreshDataManager(this);
}
/**
* Animate the series bounds.
*
* @private
*/
public animate(duration?: number): void {
this.redraw = true;
this.animated = true; //used to set duration as 1000 for animation at default 300
this.duration = duration ? duration : 1000;
}
/**
* Refresh the chart bounds.
*
* @private
* @returns {void}
*/
public refreshBound(): void {
if (this.legend3DModule && this.legendSettings.visible) {
this.legend3DModule.getLegendOptions(this.visibleSeries, this);
}
if (this.tooltip.enable && this.tooltip3DModule) {
this.tooltip3DModule.previousPoints = [];
}
this.calculateStackValues();