AxisTypes has a better toString method

This commit is contained in:
2020-02-08 12:41:02 +01:00
parent c7d58d568c
commit b59b49f2d1
2 changed files with 49 additions and 11 deletions

View File

@@ -128,20 +128,49 @@ export enum DataType {
}
export class AxesTypes {
x : Set<DataType>;
y : Set<DataType>;
x : Array<DataType>;
y : Array<DataType>;
constructor(x: Set<DataType>, y : Set<DataType>) {
constructor(x: Array<DataType>, y : Array<DataType>) {
this.x = x;
this.y = y;
}
hasXAxis(type : DataType){
return this.x.has(type);
return this.x.includes(type);
}
hasYAxis(type : DataType){
return this.y.has(type);
return this.y.includes(type);
}
/**
* return the 1-indexed axis data type, e.g. getXAxisDataType(1) for the x1 axis
*/
getXAxisDataType(index: number){
if (this.x.length+1 >= index){
return this.x[index-1];
}
return undefined;
}
/**
* return the 1-indexed axis data type, e.g. getYAxisDataType(1) for the x1 axis
*/
getYAxisDataType(index: number){
if (this.y.length+1 >= index){
return this.y[index-1];
}
return undefined;
}
toString() {
const x1 = this.getXAxisDataType(1);
const y1 = this.getYAxisDataType(1);
const x2 = this.getXAxisDataType(2);
const y2 = this.getYAxisDataType(2);
return "x1:"+DataType[x1]+ " y1:"+DataType[y1]+ " x2:"+DataType[x2]+ " y2:"+DataType[y2];
}
}