I need to modify the this.bar
property within my class when a click event occurs. The issue is that the context of this
inside the click function is different from the this
of the class.
export class Chart {
constructor() {
this.bar;
}
showChart() {
...
let group = svg.selectAll('g').data(data).enter().append('g');
group.append('rect')
.on('click', function(d) {
// My goal here is to set `this.bar = d`
});
}
}