removed width and height params and added instead manually margins for graph
This commit is contained in:
@@ -109,16 +109,34 @@ export class NlsGraphsComponent implements OnChanges {
|
|||||||
const genShiftStart = this.shiftPoint(this.matrix.start, this.config.vectors.start);
|
const genShiftStart = this.shiftPoint(this.matrix.start, this.config.vectors.start);
|
||||||
const genShiftEnd = this.shiftPoint(this.matrix.end, this.config.vectors.end, false);
|
const genShiftEnd = this.shiftPoint(this.matrix.end, this.config.vectors.end, false);
|
||||||
|
|
||||||
|
console.log(this.matrix);
|
||||||
|
|
||||||
const curveList = [
|
const curveList = [
|
||||||
{
|
{
|
||||||
color: this.config.colors.primary,
|
color: this.config.colors.primary,
|
||||||
start: genShiftStart.next().value,
|
start: genShiftStart.next().value,
|
||||||
end: genShiftEnd.next().value
|
end: genShiftEnd.next().value
|
||||||
|
// start: {
|
||||||
|
// point: this.matrix.start,
|
||||||
|
// vector: this.config.vectors.start
|
||||||
|
// },
|
||||||
|
// end: {
|
||||||
|
// point: this.matrix.end,
|
||||||
|
// vector: this.config.vectors.end
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: this.config.colors.secondary,
|
color: this.config.colors.secondary,
|
||||||
start: genShiftEnd.next().value,
|
start: genShiftEnd.next().value,
|
||||||
end: genShiftStart.next().value
|
end: genShiftStart.next().value
|
||||||
|
// end: {
|
||||||
|
// point: this.matrix.start,
|
||||||
|
// vector: this.config.vectors.start
|
||||||
|
// },
|
||||||
|
// start: {
|
||||||
|
// point: this.matrix.end,
|
||||||
|
// vector: this.config.vectors.end
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -173,46 +191,20 @@ export class NlsGraphsComponent implements OnChanges {
|
|||||||
const canvasHeight = this.canvas.getBoundingClientRect().height;
|
const canvasHeight = this.canvas.getBoundingClientRect().height;
|
||||||
const totalArea = Math.abs(canvasWidth * canvasHeight);
|
const totalArea = Math.abs(canvasWidth * canvasHeight);
|
||||||
const totalCenter = this.math.centerOfArea(canvasWidth, canvasHeight);
|
const totalCenter = this.math.centerOfArea(canvasWidth, canvasHeight);
|
||||||
const baseArea = Math.abs(this.config.width * this.config.height);
|
|
||||||
const baseScale = Math.pow(totalArea / baseArea * this.config.scale, 0.5);
|
|
||||||
const baseWidthScaled = baseScale * this.config.width;
|
|
||||||
const baseHeightScaled = baseScale * this.config.height;
|
|
||||||
const baseCenter = this.math.centerOfArea(
|
|
||||||
baseWidthScaled,
|
|
||||||
baseHeightScaled
|
|
||||||
);
|
|
||||||
|
|
||||||
if (this.config.autoHeight) {
|
return {
|
||||||
// Snap bottom and top to window limits
|
start: {
|
||||||
return {
|
x: 0,
|
||||||
start: {
|
y: canvasHeight - this.config.vectors.spacing - this.config.margin.y
|
||||||
x: totalCenter.x - baseCenter.x,
|
},
|
||||||
y: canvasHeight
|
end: {
|
||||||
},
|
x: canvasWidth - this.config.vectors.spacing - this.config.margin.x,
|
||||||
end: {
|
y: 0
|
||||||
x: totalCenter.x + baseCenter.x,
|
},
|
||||||
y: 0
|
width: canvasWidth,
|
||||||
},
|
height: canvasHeight,
|
||||||
width: canvasWidth,
|
center: totalCenter
|
||||||
height: canvasHeight,
|
};
|
||||||
center: totalCenter
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
// Adjust matrix relatively to window size
|
|
||||||
return {
|
|
||||||
start: {
|
|
||||||
x: totalCenter.x - baseCenter.x,
|
|
||||||
y: totalCenter.y + baseCenter.y
|
|
||||||
},
|
|
||||||
end: {
|
|
||||||
x: totalCenter.x + baseCenter.x,
|
|
||||||
y: totalCenter.y - baseCenter.y
|
|
||||||
},
|
|
||||||
width: baseWidthScaled,
|
|
||||||
height: baseHeightScaled,
|
|
||||||
center: totalCenter
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private genVectorPoint(point: Point, vector: number) {
|
private genVectorPoint(point: Point, vector: number) {
|
||||||
|
|||||||
@@ -15,8 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export interface Config {
|
export interface Config {
|
||||||
width: number;
|
|
||||||
height: number;
|
|
||||||
margin: {
|
margin: {
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
@@ -49,5 +47,4 @@ export interface Config {
|
|||||||
scale: any;
|
scale: any;
|
||||||
interval: number;
|
interval: number;
|
||||||
date?: Date;
|
date?: Date;
|
||||||
autoHeight?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,18 +20,6 @@
|
|||||||
<input type="number" class="form-control" formControlName="y">
|
<input type="number" class="form-control" formControlName="y">
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-control-label">
|
|
||||||
Breite
|
|
||||||
</label>
|
|
||||||
<input type="number" class="form-control" formControlName="width">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-control-label">
|
|
||||||
Höhe
|
|
||||||
</label>
|
|
||||||
<input type="number" class="form-control" formControlName="height">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-control-label">
|
<label class="form-control-label">
|
||||||
Skalierung
|
Skalierung
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ export let ConfigForm: FormGroup = fb.group({
|
|||||||
x: fb.control('', Validators.min(0)),
|
x: fb.control('', Validators.min(0)),
|
||||||
y: fb.control('', Validators.min(0))
|
y: fb.control('', Validators.min(0))
|
||||||
}),
|
}),
|
||||||
width: fb.control('', Validators.required),
|
|
||||||
height: fb.control('', Validators.required),
|
|
||||||
vectors: fb.group({
|
vectors: fb.group({
|
||||||
start: fb.control('', Validators.compose([
|
start: fb.control('', Validators.compose([
|
||||||
Validators.min(0),
|
Validators.min(0),
|
||||||
|
|||||||
@@ -23,28 +23,25 @@ export const environment = {
|
|||||||
colors: {
|
colors: {
|
||||||
primary: '#129490',
|
primary: '#129490',
|
||||||
secondary: '#CE1483'
|
secondary: '#CE1483'
|
||||||
},
|
}
|
||||||
autoHeight: true
|
|
||||||
},
|
},
|
||||||
formDefaults: {
|
formDefaults: {
|
||||||
margin: {
|
margin: {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0
|
y: 0
|
||||||
},
|
},
|
||||||
width: 1e-10,
|
|
||||||
height: 1,
|
|
||||||
scale: 0.4,
|
scale: 0.4,
|
||||||
overlap: 0.3,
|
overlap: 0.5,
|
||||||
vectors: {
|
vectors: {
|
||||||
start: 1,
|
start: 0.5,
|
||||||
end: 0,
|
end: 0,
|
||||||
range: 0.6,
|
range: 0.2,
|
||||||
spacing: 7
|
spacing: 7
|
||||||
},
|
},
|
||||||
nodes: 3,
|
nodes: 4,
|
||||||
stroke: 0.7,
|
stroke: 0.7,
|
||||||
spread: {
|
spread: {
|
||||||
amount: 30,
|
amount: 60,
|
||||||
spacing: 20
|
spacing: 20
|
||||||
},
|
},
|
||||||
interval: 30
|
interval: 30
|
||||||
|
|||||||
Reference in New Issue
Block a user