Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with size of titles inside circle #10

Open
thiagosaud opened this issue Dec 2, 2021 · 2 comments
Open

Problem with size of titles inside circle #10

thiagosaud opened this issue Dec 2, 2021 · 2 comments

Comments

@thiagosaud
Copy link

Describe the bug
I have two problems with the size of the title in the circle, which are:
When the text is large:

  1. Part of the text is hidden inside the circle;
  2. The text is not displayed in the circle;

Expected behavior
I need the circles to fit the text size so they don't get clipped or hidden.

Screenshots
image
image

Additional context
I'm using size according to the documentation to orchestrate the size of the circle, but it doesn't work.

Code

  CirclePack()
      .data(nodes)
      .label('name')
      .size('size')
      .color('color')
      .minCircleRadius(50)
      .tooltipContent((d, node) => tooltipoContent({ size: node.value }))(containerRef.current);
@vasturiano
Copy link
Owner

@thiagosaud thanks for reaching out.

It's not clear what your expectation would be for this case. The radius of the circles should not be adjusted to fit the label text, that would lead to distortion in the data. The radius of the circles is purely calculated from the size attribute in the nodes.

The only thing that can be done is to hide labels that would otherwise overflow out of their circle boundaries, which is what the component currently does. Do you have a different idea on how to handle that case?

@p4prawin
Copy link

for both of the issue temporary solution is to handle text visibility with css. below css worked for us...

text.path-label {
    opacity: 1 !important;
}

I think we can mitigate this case by just handling opacity between max 1 and min 0.5.
I am not sure but fix would be at line 241 in src/circlepack.js

.style('opacity', d => `${LABELS_WIDTH_OPACITY_SCALE((d.r * 2) * zoomTr.k / nameOf(d.data).length)}`)

to

.style('opacity', d => Math.max(0.5, `${LABELS_WIDTH_OPACITY_SCALE((d.r * 2) * zoomTr.k / nameOf(d.data).length)}`) )

PS: Its my wild guess by looking at code, I have not tested it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants