Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript D3饼图更新问题,增加聚焦切片的大小_Javascript_Jquery_D3.js - Fatal编程技术网

Javascript D3饼图更新问题,增加聚焦切片的大小

Javascript D3饼图更新问题,增加聚焦切片的大小,javascript,jquery,d3.js,Javascript,Jquery,D3.js,我正在用D3构建一个饼图,可以用新信息进行更新,而且它还有一些很酷的特性 目前,饼图的功能还不错,但是我在增加任何一个上面有鼠标的切片的大小时遇到了麻烦。我已经这样做了: cv_path.enter() .append("path") .attr("fill", function(d, i) { return cv_color(i); } ) .attr("d", cv_arc) .each(function(d) { this._current = d; }) .attr(

我正在用D3构建一个饼图,可以用新信息进行更新,而且它还有一些很酷的特性

目前,饼图的功能还不错,但是我在增加任何一个上面有鼠标的切片的大小时遇到了麻烦。我已经这样做了:

cv_path.enter()
  .append("path")
  .attr("fill", function(d, i) { return cv_color(i); } )
  .attr("d", cv_arc)
  .each(function(d) { this._current = d; })
  .attr("stroke","white")
  .attr("stroke-width",1)
  .on("mouseenter", function(d) {
    d3.select(this)
      .transition()
      .duration(350)
      .attr("d", arcOver)
      .attr("stroke","white")
      .attr("stroke-width",1);
  })
  .on("mouseleave", function(d) {
    d3.select(this).transition()
      .attr("d", arc)
      .attr("stroke","none")
      .attr("stroke","white")
      .attr("stroke-width",1);
请原谅重复,我只是想让事情正常运作。所以,这实际上是我想要的,但我遇到了一个问题。当饼图更新/转换以表示更新的数据时,它不再保持块的放大。在我再次移动鼠标之前,它会进行更新,就像我的鼠标不再在那里一样。有没有一种方法,当图表更新时,我可以将块放大

下面是一个JSFIDLE来说明我的问题:


如果将鼠标悬停在某个切片上,它将放大,一旦图形更新,您将注意到没有任何切片被放大。这就是问题所在。

您可以使用数据存储一个切片是否更大,并在更新选择中检查,以决定使用哪个函数来设置d。嘿,Lars,有没有可能在JSFIDLE中显示我?我已经尝试过了,但在我创建的事件中,我甚至很难扩大一个片段。我对d3还不是很在行,所以我肯定我缺少了一些简单的东西,比如用数据存储状态实际上不起作用,因为数据正在更新,所以我将它存储在DOM节点中。