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

Ability to pass custom labels for linkTitle #28

Open
bsaunders23 opened this issue Mar 10, 2021 · 0 comments
Open

Ability to pass custom labels for linkTitle #28

bsaunders23 opened this issue Mar 10, 2021 · 0 comments

Comments

@bsaunders23
Copy link

bsaunders23 commented Mar 10, 2021

Love the package so far, but would be great to be able to pass custom strings to append to the label (i.e. d.custlabel) when passing the links. Use case for me would be for including in addition to the total count the percent of records from a particular node moving down a given forward.

Current implementation

const fmt = d3.format('.3s')
function linkTitle(d) {
  const parts = []
  const sourceTitle = nodeTitle(d.source)
  const targetTitle = nodeTitle(d.target)
  const matTitle = d.type

  parts.push(`${sourceTitle} → ${targetTitle}`)
  if (matTitle) parts.push(matTitle)
  parts.push(fmt(d.value))
  return parts.join('\n')
}

Proposed

const fmt = d3.format('.3s')
function linkTitle(d) {
  const parts = []
  const sourceTitle = nodeTitle(d.source)
  const targetTitle = nodeTitle(d.target)
  const matTitle = d.type
  const custTitle = d.custlabel

  parts.push(`${sourceTitle} → ${targetTitle}`)
  if (matTitle) parts.push(matTitle)
  parts.push(fmt(d.value))
  if (custTitle) parts.push(custTitle)
  return parts.join('\n')
}
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

1 participant