Skip to content

Added custom css class on edge labels#398

Open
kaelhem wants to merge 3 commits into
dagrejs:masterfrom
kaelhem:master
Open

Added custom css class on edge labels#398
kaelhem wants to merge 3 commits into
dagrejs:masterfrom
kaelhem:master

Conversation

@kaelhem

@kaelhem kaelhem commented Mar 27, 2020

Copy link
Copy Markdown

Hi,
I've just made a small update on edge label to be able to specify custom css classes.


This PR allow to add a labelClass parameter on the setEdge function.

// sample :
g.setEdge(link.source, link.target, {
  labelClass: 'cutomClass1 customClass2'
})

The original label class is untouched.

It should fix #195

@tik-stbuehler

Copy link
Copy Markdown

For consistency (with labelStyle and labelType) you probably should name the label class property labelClass instead of className.

(And I have no idea why you had to redo the way the class is applied - didn't classed work with the calculated class list?)

@kaelhem

kaelhem commented May 18, 2020

Copy link
Copy Markdown
Author

Hello. I changed the property name for labelClass as you asked. I replaced the "classed" stuff that allow to add/remove a specific class name to be able to specify several classes in the className parameter (like this : customClass1 customClass2).

If you think there is a better way to do it, tell me I will update the PR.

@tik-stbuehler

Copy link
Copy Markdown

I'm not a maintainer, just a user (and I'm interested in the feature too) :)

According to the API doc classed should work with multiple classes (like "label customClass1 customClass2" - i.e. just pass labelClass instead of "label") - but I'm no d3 expert, so perhaps I'm missing something here.

@kaelhem

kaelhem commented May 18, 2020

Copy link
Copy Markdown
Author

ok :)
I will have look, not a d3 expert too :)

edit:
@tik-stbuehler You were right, I've update the PR.

@tbo47

tbo47 commented Jan 6, 2022

Copy link
Copy Markdown

I ported the project to es6 and I accept contributions!
https://github.com/tbo47/dagre-es

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

Successfully merging this pull request may close these issues.

Add a class to edgeLabel?

3 participants