D3 - How to convert circle-pack to ellipse-pack?

VividD

How to utilize D3 circle pack layout to get diagram similar to this:

enter image description here

(even with more elongated ellipses)?

The key aplication of this diagram style would be easier label placement.

This is jsfiddle that demonstrates circle pack, that I made for other purposes, but I guess it might be useful starting point for anyone wanting to experiment and test potential solution involving ellipses.


Based on @Mariatta 's answer, I got this jsfiddle:

enter image description here

But I was hoping I would preserve parent-children visual connection.


In the second attempt, I got what I want (jsfiddle):

enter image description here

The key was to change cy of the ellipses the same way as ry.

Mariatta

Well the part you need to pay attention to is :

var circles = vis.append("circle")
    .attr("stroke", "black")
    .style("fill", function(d) { return !d.children ? "tan" : "beige"; })
    .attr("cx", function(d) { return d.x; })
    .attr("cy", function(d) { return d.y; })
    .attr("r", function(d) { return d.r; });

What happens here is you are creating an svg circle element with attributes of cx, cy, and r, similar to <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />

To convert this to ellipsis, you need to know what are the attributes you need to set. An svg ellipse element can be created like so: <ellipse cx="200" cy="80" rx="100" ry="50"> Note how you need to set the cx, cy, rx, and ry as opposed to cx, cy, and r for <circle>

Based on this knowledge you should be now able to convert your circle to ellipse like this :

var ellipses = vis.append("ellipse")
    .attr("stroke", "black")
    .style("fill", function(d) { return !d.children ? "tan" : "beige"; })
    .attr("cx", function(d) { return d.x; })
    .attr("cy", function(d) { return d.y; })
    .attr("rx", 10) // define your own rule for x radius
    .attr("ry", 5); // define your own rule for y radius

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to center root node circle in a d3.layout.pack graph?

From Dev

How to Hide Overlapping Text of Labels in D3 Zoomable Pack Layout?

From Dev

Realtime D3 bubble chart (circle pack)

From Dev

Tooltips for nested circles in D3 circle pack layout

From Dev

Different colors for each circle - D3 circle pack

From Dev

Controlling order of circles in D3 circle pack layout algorithm

From Dev

Generating visually pleasing circle pack

From Dev

Text along circles in a D3 circle pack layout

From Dev

how to update data form file json using d3.js (zoomable circle pack)

From Dev

Keeping aspect ratio of D3 circle pack - responsive design

From Dev

D3 bubble chart / pack layout - How to make bubbles radiate out from the largest bubbles to the smallest?

From Dev

Adding hyeperlinks to zoomable d3 circle pack

From Dev

stop d3 circle pack labels from overlapping

From Dev

'd3-circle-text' on zoomable circle-pack

From Dev

D3 update circle-pack data new nodes overlap existing nodes

From Dev

Add circle to pack layout

From Dev

D3 Circle Pack Layout with a horizontal arrangement

From Dev

pack in small circles into a bigger circle

From Dev

How to convert a struct into a template parameter pack?

From Dev

How to center root node circle in a d3.layout.pack graph?

From Dev

How to Hide Overlapping Text of Labels in D3 Zoomable Pack Layout?

From Dev

Controlling order of circles in D3 circle pack layout algorithm

From Dev

Keeping aspect ratio of D3 circle pack - responsive design

From Dev

Undefined function when loading D3 circle pack

From Dev

D3 bubble chart / pack layout - How to make bubbles radiate out from the largest bubbles to the smallest?

From Dev

is it possible to tweak the d3 bubble chart to obtain the bubbles at scattered positions instead of a circle pack?

From Dev

D3 add zoom to circle pack

From Dev

Circle Pack Layout D3 - remove add nodes on new data

From Dev

how to use circle pack layout in ggraph library in r

Related Related

  1. 1

    How to center root node circle in a d3.layout.pack graph?

  2. 2

    How to Hide Overlapping Text of Labels in D3 Zoomable Pack Layout?

  3. 3

    Realtime D3 bubble chart (circle pack)

  4. 4

    Tooltips for nested circles in D3 circle pack layout

  5. 5

    Different colors for each circle - D3 circle pack

  6. 6

    Controlling order of circles in D3 circle pack layout algorithm

  7. 7

    Generating visually pleasing circle pack

  8. 8

    Text along circles in a D3 circle pack layout

  9. 9

    how to update data form file json using d3.js (zoomable circle pack)

  10. 10

    Keeping aspect ratio of D3 circle pack - responsive design

  11. 11

    D3 bubble chart / pack layout - How to make bubbles radiate out from the largest bubbles to the smallest?

  12. 12

    Adding hyeperlinks to zoomable d3 circle pack

  13. 13

    stop d3 circle pack labels from overlapping

  14. 14

    'd3-circle-text' on zoomable circle-pack

  15. 15

    D3 update circle-pack data new nodes overlap existing nodes

  16. 16

    Add circle to pack layout

  17. 17

    D3 Circle Pack Layout with a horizontal arrangement

  18. 18

    pack in small circles into a bigger circle

  19. 19

    How to convert a struct into a template parameter pack?

  20. 20

    How to center root node circle in a d3.layout.pack graph?

  21. 21

    How to Hide Overlapping Text of Labels in D3 Zoomable Pack Layout?

  22. 22

    Controlling order of circles in D3 circle pack layout algorithm

  23. 23

    Keeping aspect ratio of D3 circle pack - responsive design

  24. 24

    Undefined function when loading D3 circle pack

  25. 25

    D3 bubble chart / pack layout - How to make bubbles radiate out from the largest bubbles to the smallest?

  26. 26

    is it possible to tweak the d3 bubble chart to obtain the bubbles at scattered positions instead of a circle pack?

  27. 27

    D3 add zoom to circle pack

  28. 28

    Circle Pack Layout D3 - remove add nodes on new data

  29. 29

    how to use circle pack layout in ggraph library in r

HotTag

Archive