Skip to content

Commit

Permalink
Labels as links (#29)
Browse files Browse the repository at this point in the history
Allow for creation of `a` tags instead of `span` when a url is added for each node in the dataset
this allows for standard click/middleclick experience which otherwise needs `onEventClick` handler.
  • Loading branch information
jcsrb authored Apr 2, 2021
1 parent 7b58cd8 commit a3f08ae
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default function milestones(selector) {
entries: undefined,
timestamp: 'timestamp',
text: 'text',
url: 'url',
};
function assignMapping(d) {
mapping = Object.assign(mapping, d);
Expand Down Expand Up @@ -367,6 +368,13 @@ export default function milestones(selector) {
.classed('milestones-image-label', true)
.attr('height', '100')
.attr('src', t);
} else if (v[mapping.url]) {
item = element
.append('a')
.classed('milestones-label', true)
.classed('milestones-link-label', true)
.attr('href', v[mapping.url])
.text(t);
} else {
item = element
.append('span')
Expand Down

0 comments on commit a3f08ae

Please sign in to comment.