-
Notifications
You must be signed in to change notification settings - Fork 137
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
1 parent
3ae153d
commit d5a5b30
Showing
4 changed files
with
43 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { IField } from "../interfaces"; | ||
|
||
// TODO: make property with couping effect as readonly, and implements a setFunction to edit those prop with those effects. | ||
export class Field<T extends IField> { | ||
protected _field: T; | ||
constructor (f: T) { | ||
this._field = f; | ||
} | ||
public asDimension (): T { | ||
this._field.analyticType = 'dimension'; | ||
return this._field | ||
} | ||
public asMeasure (): T { | ||
this._field.analyticType = 'measure'; | ||
this._field.aggName = 'sum'; | ||
this._field.semanticType = 'quantitative' | ||
return this._field | ||
} | ||
public asGeo(role: T['geoRole']): T { | ||
this._field.geoRole = role; | ||
if (role === 'longitude') { | ||
this._field.semanticType = 'quantitative'; | ||
this._field.analyticType = 'dimension'; | ||
} | ||
if (role === 'latitude') { | ||
this._field.semanticType = 'quantitative'; | ||
this._field.analyticType = 'measure' | ||
} | ||
return this._field | ||
} | ||
public switchAnalyticType (analyticType: T['analyticType'] | string): T { | ||
if (analyticType === 'dimension') { | ||
return this.asDimension(); | ||
} else if (analyticType === 'measure') { | ||
return this.asMeasure(); | ||
} | ||
return this._field | ||
} | ||
} |
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