I'm using Data-Driven Documents (D3.js) library to plot a bar chart.It is working fine.Now I need to change the color of the bar chart when the user clicks it.But it is not working.Can you tell me why?
Note: When I use D3.selectAll(".interval").style("fill", "#F96845");
then it changes the color of all the bar charts.But I need to change only the color of clicked one.
for (var i = 0; i < this.data.length; i++) {
var item = this.data[i];
this.svg.append("rect")
.attr("class", "interval")
.attr("y", offset + item['start'] * max_height / 86400)
.attr("x", horz_inset)
.attr("height", item['length'] * max_height / 86400)
.attr("width", width - 2 * horz_inset)
.on("click", () => {
D3.select(".interval").style("fill", "#F96845");//here it is not working?
});
}