d3v4 hybrid dougnut and bubble chart — but the bubbles aren't working?

我的未来我决定 提交于 2020-06-13 11:46:20

问题


I'm trying to convert and old d3v3 hybrid chart -- but the bubble chart elements are not working?

d3v3 - https://jsfiddle.net/jfxoy7wr/

d3v4 example v4 https://jsfiddle.net/30odhpft/

this bubble chart code - is currently commented out - it was reporting an error loading in the d3.pack()?

          var bubble = d3.pack()
            .size([diameter, diameter])
            .value(function(d) {
              return d.value;
            })
            .padding(3);

          //_create bubble
          var data = bubbledata(data);


        var node = svg.selectAll(".node")
                    .data(bubble(nodes).descendants())

          var nodes = bubble.nodes(data)
            .filter(function(d) {
              return !d.children;
            }); // filter out the outer bubble


          var bubbles = bubs.selectAll('circle')
            .data(nodes);

          bubbles.enter()
            .insert("circle")
            .attr('transform', function(d) {
              return 'translate(' + d.x + ',' + d.y + ')';
            })
            .attr('r', function(d) {
              return d.r;
            })
            .style("fill", function(d) {
              return colores_google(d.groupid);
            });

          bubbles = bubbles.transition()
            .transition()
            .duration(250)
            .attr('transform', function(d) {
              return 'translate(' + d.x + ',' + d.y + ')';
            })
            .attr('r', function(d) {
              return d.r;
            })
            .ease('sine');

来源:https://stackoverflow.com/questions/62111863/d3v4-hybrid-dougnut-and-bubble-chart-but-the-bubbles-arent-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!