Skip to content

Symbol size is misleading for circle #2730

@tuh8888

Description

@tuh8888

I found the documentation of symbol size misleading, in particular for the circle. The documentation describes the size parameter as "The area in pixels of the symbols bounding box. Note that this value sets the area of the symbol; the side lengths will increase with the square root of this value.".

In the force-directed-layout example, the node size is set like this:

{
"size": {"signal": "2 * nodeRadius * nodeRadius"}
}

Yet, in the source code which renders the circle symbol, there is this

'circle': {
    draw: function(context, size) {
      var r = Math.sqrt(size) / 2;
      context.moveTo(r, 0);
      context.arc(0, 0, r, 0, Tau);
    }
  },

Substituting the calculation of the node size in the example using nodeRadius for size in the calculation of the variable r used to draw the circle gives:
r = Math.sqrt(2nodeRadiusnodeRadius)/2
r = Math.sqrt(2)/2*nodeRadius

I had a use case where I had to determine the outside edge of the circle. It took me a long time to realize that I needed to use 4*nodeRadius*nodeRadius to be able to use the nodeRadius in my calculations properly.

  1. I don't understand why PI isn't used instead of 4 (inferred from the code) since that is the actual formula for the area of a circle.
  2. The force-directed-layout example's use of size for the circle symbol is misleading.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions