У меня есть кнопка, которая активирует и деактивирует bru sh:
HTML:
<button class="button pksOnsets" style="width: 100%;" id="ManuAnnBtn" >Manual Annotation Disabled</button>
Javascript:
// Create brush
var myBrush = d3.brushX();
$("#ManuAnnBtn").click(function(){
if($(this).hasClass( "active" )){
$(this).removeClass('active');
$("#annText").removeClass('show');
$(this).text('Manual Annotation Disabled');
/* Removing brush from DOM */
d3.select("#graphSVG")
.call( myBrush // Add the brush feature using the d3.brush function
.extent( [ [0, 0], [0,0] ] ) // initialise the brush area: start at 0,0 and finishes at width,height: it means I select the whole graph area
)
}
else{
$(this).addClass('active');
$("#annText").addClass('show');
$(this).text('Manual Annotation Enabled');
// Add brushing
d3.select("#graphSVG")
.call( myBrush // Add the brush feature using the d3.brush function
.extent( [ [0, margin.top], [width, height+margin.top] ] ) // initialise the brush area: start at 0,0 and finishes at width,height: it means I select the whole graph area
)
}
});
Однако , когда я деактивирую кнопку и щелкаю в любом месте, я получаю следующую ошибку: TypeError: undefined не является объектом (оценка 't.event.target .__ data __. type')
Any идея, как я могу решить эту проблему? Спасибо!