交互式饼图:将点击事件与饼图的切片相关联
Interactive pie charts: Associate a click event with a slice of a pie chart
我正在使用d3制作玩具饼图.js
我的饼图有 3 个切片。我想知道是否可以在单击饼图的一部分时调用函数。
function animateFirstStep(){
d3.select(this)
.transition()
.attr("d",arc1);
/* .attr("d", arc2)
.style("fill", "black"); */
/* .style("stroke", "black")
.style("stroke-width", 1); */
};
function animateSecondStep(){
d3.select(this)
.transition()
.ease("elastic")
.duration(1500)
.attr("d", arc)
.style("fill", function(d) { return color(d.data.trName); });
/* .style("stroke", "white")
.style("stroke-width", 0); */
};
var g = svg.selectAll(".arc")
.data(pie(data.HubActivity.hubWorkloadList))
.enter().append("g")
.attr("class", "arc");
g.append("path")
.attr("d", arc)
.style("fill", function(d) { return color(d.data.trName); })
.on("mouseover", animateFirstStep)
.on("mouseout", animateSecondStep);
我认为这会有所帮助...当您将鼠标悬停在任何弧形功能上时,您可以将其更改为单击
相关文章:
- 对不同的数组进行切片并返回选定的值
- 多维关联数组的最后一个索引
- node.js/javascript/couchdb视图到关联数组似乎不起作用
- javascript中如何进行时间切片
- Rails——处理多态关联上的Ajax destroy调用
- 我想将链接关联到动态创建的p元素上的相应文章
- ExtJS 4:编写带有模型关联的嵌套XML
- 具有关联数组数据集的D3.js表
- Sequelize associations:set[Models]添加新模型,而不是关联现有模型
- JavaScript JSON关联对象键和值都作为日期时间戳
- 选择框中带有关联的ng模型,选项中带有ng重复
- 后关联数组使用jquery ajax
- Sequelize:属性之间的命名冲突'播放列表'以及关联'播放列表'
- 获取关联单元格onchange的值
- 在不同的屏幕和分辨率上跟踪鼠标并将其关联起来
- 如何创建php函数或任何脚本/jquery Javascript,使我能够获取与复选框关联的值并添加它们
- 我应该如何循环通过和“;关联对象“;在javascript中
- 返回一个关联数组,而不是mongoose中的文档数组
- 如何在 Angular JS 中从关联数组创建多个复选框
- 交互式饼图:将点击事件与饼图的切片相关联