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): Fixes an issue where the range was destroyed on click.
Fixes #100. Fixes an issue where the chart selection of a time-frame was destroyed when a click somewhere else in the chart was performed.
- Loading branch information
1 parent
050a325
commit a941b12
Showing
12 changed files
with
219 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* @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 { map } from 'rxjs/operators'; | ||
|
||
import { DataService } from '../../services/data.service'; | ||
import { options } from './chart-options'; | ||
|
||
export abstract class DtE2EChartBase { | ||
validRange = false; | ||
|
||
options = options; | ||
|
||
series$ = this._dataService | ||
.getFixture<{ data: Highcharts.IndividualSeriesOptions[] }>( | ||
'/data-small.json', | ||
) | ||
.pipe(map(result => result.data)); | ||
|
||
constructor(private _dataService: DataService) {} | ||
|
||
rangeValidChanges(valid: boolean): void { | ||
this.validRange = valid; | ||
} | ||
|
||
/** emits when the selection gets closed */ | ||
abstract closed(): void; | ||
|
||
/** emits when the value changes */ | ||
abstract valueChanges(_value: number | [number, number]): void; | ||
} |
File renamed without changes.
61 changes: 61 additions & 0 deletions
61
apps/components-e2e/src/components/chart/selection-area/range/range.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,61 @@ | ||
/** | ||
* @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 { waitForAngular } from '../../../../utils'; | ||
import { | ||
createRange, | ||
rangeSelection, | ||
selection, | ||
overlayText, | ||
} from '../selection-area.po'; | ||
|
||
const closeCounter = Selector('.closed-counter'); | ||
|
||
fixture('Selection Area Range Only') | ||
.page('http://localhost:4200/chart/selection-area/range') | ||
.beforeEach(async (testController: TestController) => { | ||
await testController.resizeWindow(1200, 800); | ||
await waitForAngular(); | ||
}); | ||
|
||
test('should not have an initial range selection', async (testController: TestController) => { | ||
await testController | ||
.expect(selection.exists) | ||
.notOk() | ||
.expect(rangeSelection.exists) | ||
.notOk() | ||
.expect(closeCounter.textContent) | ||
.eql('0'); | ||
}); | ||
|
||
test('should not close the range when a click is performed somewhere else in the chart', async () => { | ||
await createRange(520, { x: 310, y: 100 }) | ||
.wait(500) | ||
.expect(rangeSelection.exists) | ||
.ok() | ||
.expect(overlayText.textContent) | ||
.match(/Jul 31 \d{2}:17 — \d{2}:23/g) | ||
.click(Selector('.highcharts-plot-background'), { | ||
speed: 0.3, | ||
offsetX: 10, | ||
offsetY: 10, | ||
}) | ||
.expect(rangeSelection.exists) | ||
.ok() | ||
.expect(overlayText.textContent) | ||
.match(/Jul 31 \d{2}:17 — \d{2}:23/g); | ||
}); |
23 changes: 23 additions & 0 deletions
23
apps/components-e2e/src/components/chart/selection-area/range/range.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,23 @@ | ||
<dt-chart [options]="options" [series]="series$ | async"> | ||
<dt-chart-range | ||
aria-label-close="Close the selection" | ||
aria-label-left-handle="The left handle to update the selection" | ||
aria-label-right-handle="The right handle to update the selection" | ||
aria-label-selected-area="The selected time-frame" | ||
(valid)="rangeValidChanges($event)" | ||
(valueChanges)="valueChanges($event)" | ||
(closed)="closed()" | ||
> | ||
<button | ||
aria-label="Apply the selection" | ||
dt-button | ||
dtChartSelectionAreaAction | ||
[disabled]="!validRange" | ||
i18n | ||
> | ||
Apply | ||
</button> | ||
</dt-chart-range> | ||
</dt-chart> | ||
|
||
<div class="closed-counter">{{ closedCounter }}</div> |
47 changes: 47 additions & 0 deletions
47
apps/components-e2e/src/components/chart/selection-area/range/range.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,47 @@ | ||
/** | ||
* @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 { DtE2EChartBase } from '../../chart-base'; | ||
import { DataService } from '../../../../services/data.service'; | ||
|
||
@Component({ | ||
selector: 'dt-e2e-range', | ||
templateUrl: './range.html', | ||
styles: [ | ||
` | ||
:host { | ||
display: block; | ||
width: 1200px; | ||
} | ||
`, | ||
], | ||
}) | ||
export class DtE2ERange extends DtE2EChartBase { | ||
closedCounter = 0; | ||
|
||
constructor(dataService: DataService) { | ||
super(dataService); | ||
} | ||
|
||
closed(): void { | ||
this.closedCounter++; | ||
} | ||
|
||
valueChanges(_value: number | [number, number]): void { | ||
// emits when the value changes | ||
} | ||
} |
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
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
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
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
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
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.