This repository has been archived by the owner on Aug 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
124 additions
and
8 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './threshold.component'; | ||
export * from './percentile.component'; |
10 changes: 10 additions & 0 deletions
10
src/app/charts/extra-params-components/percentile.component.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,10 @@ | ||
<div class="chart-options-group percentile"> | ||
<form [formGroup]="percentileForm" novalidate> | ||
<div class="chart-options-body form-group"> | ||
<span class="optional-parameters-label">Show {{indicator.label | lowercase}} at percentile | ||
<input type="number" | ||
formControlName="percentileCtl"> | ||
of projections.</span> | ||
</div> | ||
</form> | ||
</div> |
55 changes: 55 additions & 0 deletions
55
src/app/charts/extra-params-components/percentile.component.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,55 @@ | ||
import { AfterViewInit, Component, EventEmitter, Input, Output, OnInit } from '@angular/core'; | ||
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | ||
|
||
import { Indicator } from '../../models/indicator.model'; | ||
|
||
import * as _ from 'lodash'; | ||
|
||
/* | ||
* Percentile params component | ||
* Uni-field form to allow user to specify the percentile params | ||
*/ | ||
@Component({ | ||
selector: 'ccl-percentile-parameters', | ||
templateUrl: './percentile.component.html' | ||
}) | ||
export class PercentileComponent implements AfterViewInit, OnInit { | ||
|
||
@Input() indicator: Indicator; | ||
@Input() extraParams: any; | ||
|
||
percentileForm: FormGroup; | ||
|
||
// default form values | ||
private defaultPercentile = 50; | ||
|
||
@Output() percentileParamSelected = new EventEmitter<any>(); | ||
|
||
constructor(private formBuilder: FormBuilder) {} | ||
|
||
ngOnInit() { | ||
// must create form on init instead of constructor to capture @Input values | ||
this.createForm(); | ||
} | ||
|
||
ngAfterViewInit() { | ||
// Since valueChanges triggers initially before parent is ready, wait until | ||
// parent is ready here and trigger it to draw chart with extra parameters. | ||
this.percentileParamSelected.emit({data: { | ||
'percentile': this.percentileForm.controls.percentileCtl.value | ||
}}); | ||
} | ||
|
||
createForm() { | ||
this.percentileForm = this.formBuilder.group({ | ||
percentileCtl: [this.extraParams.percentile || this.defaultPercentile, Validators.required] | ||
}); | ||
|
||
this.percentileForm.valueChanges.debounceTime(700).subscribe(form => { | ||
this.percentileParamSelected.emit({data: { | ||
'event': event, | ||
'percentile': form.percentileCtl | ||
}}); | ||
}); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { IndicatorQueryOpts } from './indicator-query-opts.model'; | ||
|
||
export interface PercentileIndicatorQueryOpts extends IndicatorQueryOpts { | ||
params: { | ||
percentile: Number; | ||
} | ||
} |
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