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

Multiple label style #676

Open
bendadaniel opened this issue Feb 1, 2019 · 2 comments
Open

Multiple label style #676

bendadaniel opened this issue Feb 1, 2019 · 2 comments

Comments

@bendadaniel
Copy link

bendadaniel commented Feb 1, 2019

Hi,
Is there a way to multiple style label in treemap? I need multiple line label with multiple styles. I discovered when I delimer the label text with \n it separates the string into the seperated 'text' object in svg, is there whey how to style that text objects one by one?

For example label:
ABC (size:200)
DEF (size:100)
GFIJ (size:50)
https://imgur.com/a/Lc3EMv3

Thank you
Daniel

@davelandry
Copy link
Member

This may be possible, but I would definitely classify it as experimental:

The label method of shapes can accept an Array of values, and then each font property will also be evaluated on expecting an Array. For example (and I haven't tested this):

.shapeConfig({
  label: function() { return ["ABC", "DEF", "GHIJ"]; },
  labelConfig: {
    fontSize: function() { return [200, 100, 50]; }
  }
})

@davelandry
Copy link
Member

Take a look at how the internal Treemap logic handles the main label and the share percentage label: https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Treemap.js#L95-L119

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

2 participants