src/lib/models/cut.model.ts
Cut for specifying filters on event data attribute.
Properties |
|
Methods |
constructor(field: string, minValue: number, maxValue: number, step: number, minCutActive: boolean, maxCutActive: boolean)
|
||||||||||||||||||||||||||||
Defined in src/lib/models/cut.model.ts:12
|
||||||||||||||||||||||||||||
Create the cut to filter an event data attribute.
Parameters :
|
Private defaultApplyMaxValue |
Type : boolean
|
Defined in src/lib/models/cut.model.ts:10
|
Default if upper bound applied |
Private defaultApplyMinValue |
Type : boolean
|
Defined in src/lib/models/cut.model.ts:12
|
Default if lower bound applied |
Private defaultMaxValue |
Type : number
|
Defined in src/lib/models/cut.model.ts:8
|
Default maximum allowed value of the event data attribute. |
Private defaultMinValue |
Type : number
|
Defined in src/lib/models/cut.model.ts:6
|
Default minimum allowed value of the event data attribute. |
Public field |
Type : string
|
Defined in src/lib/models/cut.model.ts:24
|
Name of the event data attribute to be filtered.
|
Public maxCutActive |
Type : boolean
|
Default value : true
|
Defined in src/lib/models/cut.model.ts:29
|
If true, the maximum cut is appled. Can be overriden later with enableMaxCut.
|
Public maxValue |
Type : number
|
Defined in src/lib/models/cut.model.ts:26
|
Maximum allowed value of the event data attribute.
|
Public minCutActive |
Type : boolean
|
Default value : true
|
Defined in src/lib/models/cut.model.ts:28
|
If true, the minimum cut is appled. Can be overriden later with enableMinCut.
|
Public minValue |
Type : number
|
Defined in src/lib/models/cut.model.ts:25
|
Minimum allowed value of the event data attribute.
|
Public step |
Type : number
|
Default value : 1
|
Defined in src/lib/models/cut.model.ts:27
|
Size of increment when using slider.
|
cutPassed | ||||||
cutPassed(value: number)
|
||||||
Defined in src/lib/models/cut.model.ts:48
|
||||||
Returns true if the passed value is within the active cut range.
Parameters :
Returns :
boolean
|
enableMaxCut | ||||||
enableMaxCut(check: boolean)
|
||||||
Defined in src/lib/models/cut.model.ts:38
|
||||||
Returns true if upper cut is valid.
Parameters :
Returns :
void
|
enableMinCut | ||||||
enableMinCut(check: boolean)
|
||||||
Defined in src/lib/models/cut.model.ts:43
|
||||||
Returns true if upper cut is valid.
Parameters :
Returns :
void
|
reset |
reset()
|
Defined in src/lib/models/cut.model.ts:58
|
Reset the minimum and maximum value of the cut to default.
Returns :
void
|
export class Cut {
/** Default minimum allowed value of the event data attribute. */
private defaultMinValue: number;
/** Default maximum allowed value of the event data attribute. */
private defaultMaxValue: number;
/** Default if upper bound applied */
private defaultApplyMaxValue: boolean;
/** Default if lower bound applied */
private defaultApplyMinValue: boolean;
/**
* Create the cut to filter an event data attribute.
* @param field Name of the event data attribute to be filtered.
* @param minValue Minimum allowed value of the event data attribute.
* @param maxValue Maximum allowed value of the event data attribute.
* @param step Size of increment when using slider.
* @param minCutActive If true, the minimum cut is appled. Can be overriden later with enableMinCut.
* @param maxCutActive If true, the maximum cut is appled. Can be overriden later with enableMaxCut.
*
*/
constructor(
public field: string,
public minValue: number,
public maxValue: number,
public step: number = 1,
public minCutActive: boolean = true,
public maxCutActive: boolean = true,
) {
this.defaultMinValue = minValue;
this.defaultMaxValue = maxValue;
this.defaultApplyMinValue = minCutActive;
this.defaultApplyMaxValue = maxCutActive;
}
/** Returns true if upper cut is valid. */
enableMaxCut(check: boolean) {
this.maxCutActive = check;
}
/** Returns true if upper cut is valid. */
enableMinCut(check: boolean) {
this.minCutActive = check;
}
/** Returns true if the passed value is within the active cut range. */
cutPassed(value: number): boolean {
return (
(!this.maxCutActive || value <= this.maxValue) &&
(!this.minCutActive || value > this.minValue)
);
}
/**
* Reset the minimum and maximum value of the cut to default.
*/
reset() {
this.minValue = this.defaultMinValue;
this.maxValue = this.defaultMaxValue;
this.minCutActive = this.defaultApplyMinValue;
this.maxCutActive = this.defaultApplyMaxValue;
}
}