Fixed missing x values
This commit is contained in:
@@ -29,9 +29,9 @@ export class CanvasDirective implements OnInit, OnChanges {
|
|||||||
|
|
||||||
@HostListener('window:resize', ['$event'])
|
@HostListener('window:resize', ['$event'])
|
||||||
private onResize(event) {
|
private onResize(event) {
|
||||||
// this.resetLines();
|
this.resetLines();
|
||||||
// this.resetPoints();
|
this.resetPoints();
|
||||||
// this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -142,13 +142,14 @@ export class CanvasDirective implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private get getExpandedPoints() {
|
private get getExpandedPoints() {
|
||||||
|
|
||||||
const group = Selection.select('g.points');
|
const group = Selection.select('g.points');
|
||||||
const points = [];
|
const points = [];
|
||||||
const that = this;
|
const that = this;
|
||||||
|
|
||||||
let point = null;
|
let point = null;
|
||||||
|
|
||||||
if (!group.size()) {
|
if (group.size() <= 1) {
|
||||||
return this.expandPoints([
|
return this.expandPoints([
|
||||||
this.config.start,
|
this.config.start,
|
||||||
this.config.end
|
this.config.end
|
||||||
@@ -157,13 +158,13 @@ export class CanvasDirective implements OnInit, OnChanges {
|
|||||||
|
|
||||||
group.selectAll('circle').each(function() {
|
group.selectAll('circle').each(function() {
|
||||||
point = Selection.select(this);
|
point = Selection.select(this);
|
||||||
|
|
||||||
points.push({
|
points.push({
|
||||||
x: point.attr('cx'),
|
x: point.attr('cx'),
|
||||||
y: point.attr('cy'),
|
y: point.attr('cy'),
|
||||||
color: (that.param.colors.start === point.attr('fill') || that.param.colors.end === point.attr('fill')) ? point.attr('fill') : '',
|
color: (that.param.colors.start === point.attr('fill') || that.param.colors.end === point.attr('fill')) ? point.attr('fill') : '',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,8 +196,6 @@ export class CanvasDirective implements OnInit, OnChanges {
|
|||||||
return this.Δ(a, pointMiddle) - this.Δ(b, pointMiddle);
|
return this.Δ(a, pointMiddle) - this.Δ(b, pointMiddle);
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(spreadPoints);
|
|
||||||
|
|
||||||
spreadPoints.some((point, index) => {
|
spreadPoints.some((point, index) => {
|
||||||
if (this.param.showGrid) {
|
if (this.param.showGrid) {
|
||||||
group.append('circle')
|
group.append('circle')
|
||||||
@@ -213,8 +212,6 @@ export class CanvasDirective implements OnInit, OnChanges {
|
|||||||
return index === 20;
|
return index === 20;
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log();
|
|
||||||
|
|
||||||
group.lower();
|
group.lower();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,6 +251,7 @@ export class CanvasDirective implements OnInit, OnChanges {
|
|||||||
* @param b
|
* @param b
|
||||||
*/
|
*/
|
||||||
private Δ(a: Point, b: Point) {
|
private Δ(a: Point, b: Point) {
|
||||||
|
|
||||||
return Math.pow(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2), 0.5);
|
return Math.pow(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2), 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,6 +306,7 @@ export class CanvasDirective implements OnInit, OnChanges {
|
|||||||
},
|
},
|
||||||
drag: this.drag
|
drag: this.drag
|
||||||
};
|
};
|
||||||
|
|
||||||
// Emit Canvas Config to parent Component.
|
// Emit Canvas Config to parent Component.
|
||||||
this.emitConfig.next(this.config);
|
this.emitConfig.next(this.config);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user