-
Notifications
You must be signed in to change notification settings - Fork 78
/
event-chart.spec.ts
789 lines (704 loc) · 24 KB
/
event-chart.spec.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
/**
* @license
* Copyright 2019 Dynatrace LLC
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// tslint:disable no-lifecycle-call no-use-before-declare no-magic-numbers
// tslint:disable no-any max-file-line-count no-unbound-method use-component-selector
import { OverlayContainer } from '@angular/cdk/overlay';
import { Component, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed, inject } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DtEventChartModule } from '@dynatrace/barista-components/event-chart';
import { dispatchFakeEvent } from '@dynatrace/barista-components/testing';
import { DtEventChart } from './event-chart';
import { DtEventChartSelectedEvent } from './event-chart-directives';
/** Gets the rendered merged numbering. */
function getRenderedMergedTextLabels(fixture: ComponentFixture<any>): string[] {
const texts = fixture.debugElement.queryAll(
By.css('.dt-event-chart-event-mergednumber'),
);
return texts.map(text => text.nativeElement.innerHTML.trim());
}
/** Gets the rendered path that connects the rendered Event bubbles. */
function getRenderedEventsPath(fixture: ComponentFixture<any>): string {
const pathElement = fixture.debugElement.query(
By.css('.dt-event-chart-path'),
);
return pathElement.nativeElement.getAttribute('d');
}
/** Get legend items from the fixture. */
function getLegendItems(
fixture: ComponentFixture<any>,
): {
label: string;
hasErrorColor: boolean;
hasConversionColor: boolean;
hasFilteredColor: boolean;
hasPattern: boolean;
}[] {
const legendItemElements = fixture.debugElement.queryAll(
By.css('.dt-legend-item'),
);
return legendItemElements.map(element => {
const label = element
.query(By.css('.dt-legend-item-label'))
.nativeElement.textContent.trim();
const hasErrorColor = element
.query(By.css('.dt-event-chart-legend-symbol'))
.nativeElement.classList.toString()
.includes('error');
const hasConversionColor = element
.query(By.css('.dt-event-chart-legend-symbol'))
.nativeElement.classList.toString()
.includes('conversion');
const hasFilteredColor = element
.query(By.css('.dt-event-chart-legend-symbol'))
.nativeElement.classList.toString()
.includes('filtered');
const hasPattern =
// tslint:disable-next-line: strict-type-predicates
element.query(
By.css(
'.dt-event-chart-legend-symbol .dt-event-chart-legend-symbol-pattern',
),
) !== null;
return {
label,
hasErrorColor,
hasConversionColor,
hasFilteredColor,
hasPattern,
};
});
}
function getLaneLabels(fixture: ComponentFixture<any>): string[] {
const laneLabels = fixture.debugElement.queryAll(
By.css('.dt-event-chart-lane-label'),
);
return laneLabels.map(text => text.nativeElement.innerHTML.trim());
}
describe('DtEventChart', () => {
let overlayContainer: OverlayContainer;
let overlayContainerElement: HTMLElement;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [DtEventChartModule],
declarations: [
EventChartStaticData,
EventChartStaticDataWithLegendAndOverlay,
EventChartDynamicData,
],
});
TestBed.compileComponents();
});
beforeEach(inject([OverlayContainer], (oc: OverlayContainer) => {
overlayContainer = oc;
overlayContainerElement = oc.getContainerElement();
}));
describe('with static data and minimal configuration', () => {
let fixture;
beforeEach(() => {
fixture = TestBed.createComponent(EventChartStaticData);
const canvas = fixture.debugElement.query(
By.css('.dt-event-chart-canvas'),
);
// Mock the clientWidth function of the canvas, to accurately get
// merging and rendering values. Otherwhise jsDom would return 0 for
// clientWidth.
jest
.spyOn(canvas.nativeElement, 'clientWidth', 'get')
.mockImplementation(() => 1024);
fixture.detectChanges();
});
it('should create the dt-event-chart', () => {
expect(fixture).toBeDefined();
});
it('should render the events correctly', () => {
const renderedEvents =
fixture.componentInstance._eventChartInstance._renderEvents;
// Expect the correct amount of dots being drawn
expect(renderedEvents).toHaveLength(6);
expect(renderedEvents[0]).toMatchObject({
x1: 13,
x2: 13,
y: 73,
pattern: true,
color: 'default',
});
// Check points for bubble 1
expect(renderedEvents[1].x1).toBeCloseTo(146, 0.5);
expect(renderedEvents[1].x2).toBeCloseTo(146, 0.5);
expect(renderedEvents[1].y).toBe(24);
// Check points for bubble 2
expect(renderedEvents[2].x1).toBeCloseTo(212.6, 0.5);
expect(renderedEvents[2].x2).toBeCloseTo(212.6, 0.5);
expect(renderedEvents[2].y).toBe(73);
// Check points for bubble 3
expect(renderedEvents[3].x1).toBeCloseTo(345.6, 0.5);
expect(renderedEvents[3].x2).toBeCloseTo(345.6, 0.5);
expect(renderedEvents[3].y).toBe(73);
expect(renderedEvents[3].color).toContain('error');
// Check points for bubble 4
expect(renderedEvents[4].x1).toBeCloseTo(478.7, 0.5);
expect(renderedEvents[4].x2).toBeCloseTo(678.3, 0.5);
expect(renderedEvents[4].y).toBe(73);
expect(renderedEvents[4].pattern).toBe(true);
// Check points for bubble 5
expect(renderedEvents[5].x1).toBeCloseTo(1011, 0.5);
expect(renderedEvents[5].x2).toBeCloseTo(1011, 0.5);
expect(renderedEvents[5].y).toBe(24);
});
it('should render the path correctly', () => {
const path = getRenderedEventsPath(fixture);
const expectedPath = [
'M13 73',
'L146.06666666666666 24',
'L212.60000000000002 73',
'L345.66666666666663 73',
'L478.73333333333335 73',
'M678.3333333333333 73',
'L1011 24',
].join(' ');
expect(path).toBe(expectedPath);
});
it('should render the correct lanes and lables', () => {
const lanes = getLaneLabels(fixture);
expect(lanes).toHaveLength(2);
expect(lanes).toStrictEqual(['User event', 'XHR']);
});
it('should not have merge labels', () => {
const mergeLables = getRenderedMergedTextLabels(fixture);
expect(mergeLables).toHaveLength(0);
});
it('should not have legend items', () => {
const legendItems = getLegendItems(fixture);
expect(legendItems).toHaveLength(0);
});
});
describe('with static data including legend and overlay', () => {
let fixture;
beforeEach(() => {
fixture = TestBed.createComponent(
EventChartStaticDataWithLegendAndOverlay,
);
const canvas = fixture.debugElement.query(
By.css('.dt-event-chart-canvas'),
);
// Mock the clientWidth function of the canvas, to accurately get
// merging and rendering values. Otherwhise jsDom would return 0 for
// clientWidth.
jest
.spyOn(canvas.nativeElement, 'clientWidth', 'get')
.mockImplementation(() => 1024);
// Reset selected property.
fixture.componentInstance.selected = undefined;
fixture.detectChanges();
});
it('should create a event chart with the setup configuration', () => {
expect(fixture).toBeDefined();
});
it('should have the correct legends', () => {
const legends = getLegendItems(fixture);
// Legend for the default duration event
expect(legends[0]).toMatchObject({
label: 'This is the default duration legend',
hasErrorColor: false,
hasConversionColor: false,
hasFilteredColor: false,
hasPattern: true,
});
// Default label for a single event.
expect(legends[1]).toMatchObject({
label: 'This is the default legend',
hasErrorColor: false,
hasConversionColor: false,
hasFilteredColor: false,
hasPattern: false,
});
// Legend for the error event
expect(legends[2]).toMatchObject({
label: 'This is the error legend',
hasErrorColor: true,
hasConversionColor: false,
hasFilteredColor: false,
hasPattern: true,
});
});
it('should have an overlay container defined', () => {
expect(overlayContainer).toBeDefined();
});
it('should display an overlay when hovering over a point', () => {
const firstBubble = fixture.debugElement.query(
By.css('.dt-event-chart-event'),
);
dispatchFakeEvent(firstBubble.nativeElement, 'mouseenter');
fixture.detectChanges();
const overlayPane = overlayContainerElement.querySelector(
'.dt-event-chart-overlay-panel',
);
expect(overlayPane).toBeDefined();
const overlayContent = (overlayPane!.textContent || '').trim();
expect(overlayContent).toBe('1');
});
it('should remove the overlay when moving the mouse away from the point', () => {
const firstBubble = fixture.debugElement.query(
By.css('.dt-event-chart-event'),
);
let overlayPane = overlayContainerElement.querySelector(
'.dt-event-chart-overlay-panel',
);
dispatchFakeEvent(firstBubble.nativeElement, 'mouseenter');
fixture.detectChanges();
overlayPane = overlayContainerElement.querySelector(
'.dt-event-chart-overlay-panel',
);
dispatchFakeEvent(firstBubble.nativeElement, 'mouseleave');
fixture.detectChanges();
overlayPane = overlayContainerElement.querySelector(
'.dt-event-chart-overlay-panel',
);
expect(overlayPane).toBeNull();
});
it('should call bound function when selecting an eventBubble', () => {
jest.spyOn(fixture.componentInstance, 'logSelected');
const firstBubble = fixture.debugElement.query(
By.css('.dt-event-chart-event'),
);
dispatchFakeEvent(firstBubble.nativeElement, 'click');
expect(fixture.componentInstance.logSelected).toHaveBeenCalledWith(
expect.any(DtEventChartSelectedEvent),
);
// Check if the now selected element fits the elements
expect(fixture.componentInstance.selected.sources).toHaveLength(1);
expect(fixture.componentInstance.selected.sources[0]).toMatchObject({
_duration: 0,
_value: 0,
lane: 'xhr',
data: '1',
});
});
it('should select an event when a bubble is clicked', () => {
const firstBubble = fixture.debugElement.query(
By.css('.dt-event-chart-event'),
);
dispatchFakeEvent(firstBubble.nativeElement, 'click');
fixture.detectChanges();
expect(firstBubble.nativeElement.classList).toContain(
'dt-event-chart-event-selected',
);
});
});
describe('with dynamic data', () => {
let fixture;
beforeEach(() => {
fixture = TestBed.createComponent(EventChartDynamicData);
const canvas = fixture.debugElement.query(
By.css('.dt-event-chart-canvas'),
);
// Mock the clientWidth function of the canvas, to accurately get
// merging and rendering values. Otherwhise jsDom would return 0 for
// clientWidth.
jest
.spyOn(canvas.nativeElement, 'clientWidth', 'get')
.mockImplementation(() => 1024);
// Reset selected property.
fixture.componentInstance.selected = undefined;
fixture.detectChanges();
});
it('should create the chart correctly with dynamic content-children', () => {
expect(fixture).toBeDefined();
});
it('should render the correct amount of events', () => {
const renderedEvents =
fixture.componentInstance._eventChartInstance._renderEvents;
// Expect the correct amount of dots being drawn
expect(renderedEvents).toHaveLength(7);
// Expect the event to have a error color
expect(renderedEvents[3].color).toBe('error');
// Expect the event to have a conversion color
expect(renderedEvents[4].color).toBe('conversion');
// Expect the event to have a duration
expect(renderedEvents[5].pattern).toBe(true);
});
it('should render the correct lanes and lables', () => {
const lanes = getLaneLabels(fixture);
expect(lanes).toHaveLength(2);
expect(lanes).toStrictEqual(['User event', 'XHR']);
});
it('should update the rendered events after one event is removed', () => {
const newEvents = [...fixture.componentInstance._events];
newEvents.splice(2, 1);
fixture.componentInstance._events = newEvents;
fixture.detectChanges();
const renderedEvents =
fixture.componentInstance._eventChartInstance._renderEvents;
// Expect the length to decrease.
expect(renderedEvents).toHaveLength(6);
// Expect the event to have a error color
expect(renderedEvents[2].color).toBe('error');
// Expect the event to have a conversion color
expect(renderedEvents[3].color).toBe('conversion');
// Expect the event to have a duration
expect(renderedEvents[4].pattern).toBe(true);
});
it('should update the rendered events if one event is added', () => {
const newEvents = [...fixture.componentInstance._events];
newEvents.push({
value: 150,
duration: 0,
lane: 'user-event',
color: 'default',
data: 8,
});
fixture.componentInstance._events = newEvents;
fixture.detectChanges();
const renderedEvents =
fixture.componentInstance._eventChartInstance._renderEvents;
// Expect the length to increase.
expect(renderedEvents).toHaveLength(8);
});
it('should update the rendered events if one event is added and instantly merged', () => {
const newEvents = [...fixture.componentInstance._events];
newEvents.push({
value: 15.5,
duration: 0,
lane: 'xhr',
color: 'default',
data: 8,
});
fixture.componentInstance._events = newEvents;
fixture.detectChanges();
const renderedEvents =
fixture.componentInstance._eventChartInstance._renderEvents;
// Expect the length to stay the same, as the newly added one should be merged.
expect(renderedEvents).toHaveLength(7);
});
it('should have merged labels, if events are merged', () => {
const newEvents = [...fixture.componentInstance._events];
newEvents.push({
value: 15.5,
duration: 0,
lane: 'xhr',
color: 'default',
data: 8,
});
fixture.componentInstance._events = newEvents;
fixture.detectChanges();
const mergedLables = getRenderedMergedTextLabels(fixture);
expect(mergedLables).toHaveLength(1);
expect(mergedLables[0]).toBe('2');
});
it('should receive the merged data if a merged event is clicked', () => {
jest.spyOn(fixture.componentInstance, 'logSelected');
const newEvents = [...fixture.componentInstance._events];
newEvents.push({
value: 15.5,
duration: 0,
lane: 'xhr',
color: 'default',
data: 8,
});
fixture.componentInstance._events = newEvents;
fixture.detectChanges();
const mergedBubble = fixture.debugElement.queryAll(
By.css('.dt-event-chart-event'),
)[1];
dispatchFakeEvent(mergedBubble.nativeElement, 'click');
expect(fixture.componentInstance.logSelected).toHaveBeenCalledWith(
expect.any(DtEventChartSelectedEvent),
);
// Check if the now selected element contains the expected data.
expect(fixture.componentInstance.selected.sources).toHaveLength(2);
expect(fixture.componentInstance.selected.sources[0]).toMatchObject({
_duration: 0,
_value: 15,
lane: 'xhr',
data: 2,
});
expect(fixture.componentInstance.selected.sources[1]).toMatchObject({
_duration: 0,
_value: 15.5,
lane: 'xhr',
data: 8,
});
});
it('should show the merged data in the overlay when hovered', () => {
const newEvents = [...fixture.componentInstance._events];
newEvents.push({
value: 15.5,
duration: 0,
lane: 'xhr',
color: 'default',
data: 8,
});
fixture.componentInstance._events = newEvents;
fixture.detectChanges();
const mergedBubble = fixture.debugElement.queryAll(
By.css('.dt-event-chart-event'),
)[1];
dispatchFakeEvent(mergedBubble.nativeElement, 'mouseenter');
fixture.detectChanges();
const overlayPane = overlayContainerElement.querySelector(
'.dt-event-chart-overlay-panel',
);
expect(overlayPane).toBeDefined();
const overlayContent = (overlayPane!.textContent || '').trim();
expect(overlayContent).toContain('2');
expect(overlayContent).toContain('8');
});
it('should render the correct legend items', () => {
const legendItems = getLegendItems(fixture);
expect(legendItems).toHaveLength(2);
expect(legendItems[0].label).toBe('This is the default duration legend');
expect(legendItems[1].label).toBe('This is the error legend');
});
it('should update the legends if they are changed dynamically', () => {
fixture.componentInstance._errorLegendEnabled = false;
fixture.detectChanges();
const legendItems = getLegendItems(fixture);
expect(legendItems).toHaveLength(1);
expect(legendItems[0].label).toBe('This is the default duration legend');
});
it('should update the legends if a binding inside changes', () => {
fixture.componentInstance._durationLabel = 'Updated label';
fixture.detectChanges();
const legendItems = getLegendItems(fixture);
expect(legendItems).toHaveLength(2);
expect(legendItems[0].label).toBe('Updated label');
expect(legendItems[1].label).toBe('This is the error legend');
});
it('should react to changing lanes', () => {
fixture.componentInstance._userEventsLaneEnabled = false;
fixture.detectChanges();
const lanes = getLaneLabels(fixture);
expect(lanes).toHaveLength(1);
expect(lanes).toStrictEqual(['XHR']);
// Events on lanes, that are not defined, should not be rendered.
const renderedEvents =
fixture.componentInstance._eventChartInstance._renderEvents;
expect(renderedEvents).toHaveLength(5);
});
});
});
/** Test component that contains an DtEventChart. */
@Component({
selector: 'dt-test-app',
template: `
<dt-event-chart>
<dt-event-chart-event value="0" lane="xhr"></dt-event-chart-event>
<dt-event-chart-event value="15" lane="xhr"></dt-event-chart-event>
<dt-event-chart-event
value="25"
lane="xhr"
color="error"
></dt-event-chart-event>
<dt-event-chart-event value="10" lane="user-event"></dt-event-chart-event>
<dt-event-chart-event
value="35"
lane="xhr"
duration="15"
></dt-event-chart-event>
<dt-event-chart-event value="75" lane="user-event"></dt-event-chart-event>
<dt-event-chart-lane
name="xhr"
label="XHR"
pattern="true"
></dt-event-chart-lane>
<dt-event-chart-lane
name="user-event"
label="User event"
></dt-event-chart-lane>
</dt-event-chart>
`,
})
class EventChartStaticData {
@ViewChild(DtEventChart, { static: true })
_eventChartInstance: DtEventChart<any>;
}
@Component({
selector: 'dt-test-app',
template: `
<dt-event-chart>
<dt-event-chart-event
value="0"
lane="xhr"
data="1"
(selected)="logSelected($event)"
></dt-event-chart-event>
<dt-event-chart-event
value="15"
lane="xhr"
data="3"
></dt-event-chart-event>
<dt-event-chart-event
value="25"
lane="xhr"
color="error"
data="2"
></dt-event-chart-event>
<dt-event-chart-event
value="10"
lane="user-event"
data="4"
></dt-event-chart-event>
<dt-event-chart-event
value="35"
lane="xhr"
duration="15"
></dt-event-chart-event>
<dt-event-chart-event
value="75"
lane="user-event"
data="5"
></dt-event-chart-event>
<dt-event-chart-lane
name="xhr"
label="XHR"
pattern="true"
></dt-event-chart-lane>
<dt-event-chart-lane
name="user-event"
label="User event"
></dt-event-chart-lane>
<dt-event-chart-legend-item [lanes]="['xhr', 'user-event']">
This is the default legend
</dt-event-chart-legend-item>
<dt-event-chart-legend-item [lanes]="['xhr']" pattern>
This is the default duration legend
</dt-event-chart-legend-item>
<dt-event-chart-legend-item [lanes]="['xhr']" pattern color="error">
This is the error legend
</dt-event-chart-legend-item>
<ng-template dtEventChartOverlay let-tooltip>
<div *ngFor="let t of tooltip">
{{ t.data }}
</div>
</ng-template>
</dt-event-chart>
`,
})
class EventChartStaticDataWithLegendAndOverlay {
selected;
@ViewChild(DtEventChart, { static: true })
_eventChartInstance: DtEventChart<any>;
logSelected(selected: DtEventChartSelectedEvent<string>): void {
this.selected = selected;
}
}
@Component({
selector: 'dt-test-app',
template: `
<dt-event-chart>
<dt-event-chart-event
*ngFor="let event of _events"
[value]="event.value"
[duration]="event.duration"
[lane]="event.lane"
[color]="event.color"
(selected)="logSelected($event)"
[data]="event.data"
></dt-event-chart-event>
<dt-event-chart-lane
name="xhr"
label="XHR"
pattern="true"
></dt-event-chart-lane>
<dt-event-chart-lane
*ngIf="_userEventsLaneEnabled"
name="user-event"
label="User event"
></dt-event-chart-lane>
<dt-event-chart-legend-item [lanes]="['xhr', 'user-event']">
This is the default legend
</dt-event-chart-legend-item>
<dt-event-chart-legend-item [lanes]="['xhr']" pattern>
{{ _durationLabel }}
</dt-event-chart-legend-item>
<dt-event-chart-legend-item
*ngIf="_errorLegendEnabled"
[lanes]="['xhr', 'user-event']"
color="error"
>
This is the error legend
</dt-event-chart-legend-item>
<ng-template dtEventChartOverlay let-tooltip>
<div *ngFor="let t of tooltip">
{{ t.data }}
</div>
</ng-template>
</dt-event-chart>
`,
})
class EventChartDynamicData {
@ViewChild(DtEventChart, { static: true })
_eventChartInstance: DtEventChart<any>;
selected;
logSelected(selected: DtEventChartSelectedEvent<number>): void {
this.selected = selected;
}
_userEventsLaneEnabled = true;
_errorLegendEnabled = true;
_durationLabel = 'This is the default duration legend';
_events = [
{
value: 0,
duration: 0,
lane: 'xhr',
color: 'default',
data: 1,
},
{
value: 15,
duration: 0,
lane: 'xhr',
color: 'default',
data: 2,
},
{
value: 35,
duration: 0,
lane: 'xhr',
color: 'default',
data: 3,
},
{
value: 45,
duration: 0,
lane: 'user-event',
color: 'error',
data: 4,
},
{
value: 65,
duration: 0,
lane: 'user-event',
color: 'conversion',
data: 5,
},
{
value: 80,
duration: 20,
lane: 'xhr',
color: 'default',
data: 6,
},
{
value: 110,
duration: 0,
lane: 'xhr',
color: 'default',
data: 7,
},
];
}