角度 4 的 d3.drag 出现问题。每当我拖动矩形对象时,它第一次移动得很好。释放鼠标并再次尝试拖动矩形后,它会返回到上一个事件,并且无法在可拖动对象上进行鼠标控制。请解决我的问题。
import { Component,Input, ElementRef, OnInit } from '@angular/core';
import * as d3 from 'd3';
interface LineData{
xVal: number,
yVal:number
}
@Component({
selector: 'app-line-chart',
template:'<svg height="500" width="500" ></svg>',
styleUrl: []
})
export class LineChartComponent implements OnInit {
@Input() data : LineData[];
private parentNativeElement : any;
constructor(private element:ElementRef) {
this.parentNativeElement = element.nativeElement;
}
ngOnInit() {
var width = 300;
var height = 300;
var margin = {top: 10, right: 10, bottom: 30, left: 10}
var x = …Run Code Online (Sandbox Code Playgroud)