This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(chart): Fix dynamic heatfield generation that was not possible.
Fixes an issue where the heatfields could not be created dynamic. Fixes #1580
- Loading branch information
1 parent
a3e6936
commit 796b9e9
Showing
7 changed files
with
274 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
apps/components-e2e/src/components/chart/heatfield/heatfield.e2e.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 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. | ||
*/ | ||
|
||
import { Selector } from 'testcafe'; | ||
import { resetWindowSizeToDefault, waitForAngular } from '../../../utils'; | ||
|
||
fixture('Chart Heatfield') | ||
.page('http://localhost:4200/chart/heatfield') | ||
.beforeEach(async () => { | ||
await resetWindowSizeToDefault(); | ||
await waitForAngular(); | ||
}); | ||
|
||
const chart = (chartIndex = 1) => Selector('.dt-chart').nth(chartIndex); | ||
const heatfieldMarker = (chartIndex?: number) => | ||
chart(chartIndex).find('.dt-chart-heatfield-marker'); | ||
export const overlay = Selector('.dt-chart-heatfield-overlay'); | ||
|
||
test('should display a heatfield correctly', async (testController: TestController) => { | ||
await testController | ||
.expect(heatfieldMarker().count) | ||
.eql(1) | ||
.expect(heatfieldMarker().getBoundingClientRectProperty('width')) | ||
.eql(108) | ||
.click(chart()) | ||
.click(heatfieldMarker()) | ||
.expect(overlay.textContent) | ||
.match(/heatfield content/g) | ||
.click(heatfieldMarker()) | ||
.expect(overlay.exists) | ||
.notOk(); | ||
}); | ||
|
||
test('should update the heatfields programmatically', async (testController: TestController) => { | ||
await testController | ||
.expect(heatfieldMarker().count) | ||
.eql(1) | ||
.click(heatfieldMarker()) | ||
.expect(overlay.exists) | ||
.ok() | ||
.click(heatfieldMarker()) | ||
.expect(overlay.exists) | ||
.notOk() | ||
.click(Selector('#update-heatfield-stream')) | ||
.expect(heatfieldMarker().count) | ||
.eql(2) | ||
.click(heatfieldMarker().nth(1)) | ||
.expect(overlay.textContent) | ||
.ok(); | ||
}); |
36 changes: 36 additions & 0 deletions
36
apps/components-e2e/src/components/chart/heatfield/heatfield.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<dt-chart [options]="options" [series]="series"> | ||
<dt-chart-heatfield | ||
*ngFor="let heatfield of heatfields" | ||
[start]="heatfield.start" | ||
[end]="heatfield.end" | ||
> | ||
heatfield content | ||
</dt-chart-heatfield> | ||
</dt-chart> | ||
|
||
<button (click)="heatfields = [{ start: 3000, end: 4000 }]"> | ||
update Heatfields | ||
</button> | ||
<hr /> | ||
|
||
<dt-chart [options]="options" [series]="series"> | ||
<dt-chart-heatfield | ||
*ngFor="let heatfield of heatfields$ | async" | ||
[start]="heatfield.start" | ||
[end]="heatfield.end" | ||
> | ||
heatfield content | ||
</dt-chart-heatfield> | ||
</dt-chart> | ||
|
||
<button | ||
id="update-heatfield-stream" | ||
(click)=" | ||
heatfields$.next([ | ||
{ start: 70000, end: 90000 }, | ||
{ start: 50000, end: 60000 } | ||
]) | ||
" | ||
> | ||
update Heatfields stream | ||
</button> |
88 changes: 88 additions & 0 deletions
88
apps/components-e2e/src/components/chart/heatfield/heatfield.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 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. | ||
*/ | ||
|
||
import { Component } from '@angular/core'; | ||
import { generateData } from '@dynatrace/testing/fixtures'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'dt-e2e-heat-field', | ||
templateUrl: 'heatfield.html', | ||
styles: [ | ||
` | ||
:host { | ||
display: block; | ||
margin-top: 100px; | ||
} | ||
`, | ||
], | ||
}) | ||
export class Heatfield { | ||
value = 0; | ||
|
||
options: Highcharts.Options = { | ||
chart: { | ||
spacingLeft: 100, | ||
spacingRight: 100, | ||
}, | ||
xAxis: { | ||
type: 'datetime', | ||
min: 0, | ||
max: 100000, | ||
}, | ||
yAxis: [ | ||
{ | ||
title: undefined, | ||
labels: { | ||
enabled: false, | ||
}, | ||
tickLength: 0, | ||
}, | ||
], | ||
plotOptions: { | ||
column: { | ||
stacking: 'normal', | ||
}, | ||
series: { | ||
marker: { | ||
enabled: false, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
series: Highcharts.SeriesOptionsType[] = [ | ||
{ | ||
name: 'Requests', | ||
type: 'line', | ||
data: generateData(11, 0, 200, 0, 10000), | ||
}, | ||
]; | ||
|
||
heatfields$ = new BehaviorSubject([ | ||
{ | ||
start: 10000, | ||
end: 20000, | ||
}, | ||
]); | ||
|
||
heatfields = [ | ||
{ | ||
start: 1000, | ||
end: 2000, | ||
}, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.