如何解决如何使用Typescript中的d3.js事件
我在我的angular(9)应用程序中使用了D3.js(v4)。我有用于 mouseenter 事件的事件处理程序( mouseOver ),该事件处理程序返回 function ,并且该函数调用了另一个角度方法( LegendFade ),问题是此LegendFade方法未执行。有人知道出了什么问题吗?
下面是我的代码段,
调用mouseenter事件处理程序的代码-
.on('mouseenter',this.mouseOver)
mouseOver方法的代码-
private mouseOver(d): (d,i) => void {
if (this.doNotReactOnMouseEvents) {
return;
}
return (d,i) => {
d3.selectAll('[class^="column-chart"]').attr(
'class',(d,i,nodes) => {
const currentClass = d3.select(d3.event.currentTarget).attr('class');
if (
!currentClass.includes('-light') &&
nodes[i] !== d3.event.target
) {
return currentClass + '-light';
}
return currentClass;
}
);
const currentColumn = d3.select(d3.event.target);
const chartClass = currentColumn.attr('class');
const textIndex = chartClass.charAt(chartClass.length - 1);
this.LegendFade(textIndex,this.colors,this.containerSelector);
const coords = d3.mouse(d3.select('svg').node());
d3.select('tooltip')
.text(d.value)
.style('left',coords[0] + this.margin.left - 15 + 'px')
.style('top',coords[1] + this.margin.top - 35 + 'px');
d3.select('tooltip').style('visibility','visible');
};
}
这是angular中的另一个私有方法
private LegendFade(textIndex,colors,containerSelector) {}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。