This is my code我的xaxis1包含月份名称:January..December。
我想选择每个月的值,所以我添加了这个功能:

d3.select(".xAxis1") //selecting xAxis1 division
.selectAll(".major")  //select all the tiket defined on it
.on("click",clickMe)  //applay the function on clik to each value

 function clickMe(){alert("I've been clicked!")}


但这不起作用吗?!有任何想法吗?

最佳答案

我的d3js不好,但是为什么你不尝试。

d3.select(".xAxis1") //selecting xAxis1 division
.on("click",clickMe);  //applay the function on clik to each value

d3.selectAll(".major")  //select all the tiket defined on it
.on("click",clickMe)  //applay the function on clik to each value

 function clickMe(){alert("I've been clicked!")}


当我查看您的代码时,我认为".xAxis1"是不正确的,应该是
".axis1"

10-06 00:44