Skip to content

Commit

Permalink
fix bug to not duplicate breadcrumb trail
Browse files Browse the repository at this point in the history
  • Loading branch information
timelyportfolio committed Feb 27, 2018
1 parent 00b9737 commit fcb11b0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
15 changes: 11 additions & 4 deletions inst/htmlwidgets/sunburst.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,19 @@ function draw (el, instance, dispatch_) {

function initializeBreadcrumbTrail() {
// Add the svg area.
var trail = d3Selection.select(el).select(".sunburst-sequence").append("svg")
.attr("width", width)
//.attr("height", 50)
var trail = d3Selection.select(el).select(".sunburst-sequence").select("svg");
if(trail.nodes().length === 0) {
trail = d3Selection.select(el).select(".sunburst-sequence").append("svg")
.attr("id", el.id + "-trail");
trail.append("text");
}

trail
.attr("width", width);
//.attr("height", 50)

// Add the label at the end, for the percentage.
trail.append("text")
trail.select("text")
.attr("id", el.id + "-endlabel")
.style("fill", "#000");
}
Expand Down
17 changes: 12 additions & 5 deletions javascript/src/sunburst-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,19 @@ export default function (el, instance, dispatch_) {

function initializeBreadcrumbTrail() {
// Add the svg area.
var trail = select(el).select(".sunburst-sequence").append("svg")
.attr("width", width)
//.attr("height", 50)
.attr("id", el.id + "-trail");
var trail = select(el).select(".sunburst-sequence").select("svg")
if(trail.nodes().length === 0) {
trail = select(el).select(".sunburst-sequence").append("svg")
.attr("id", el.id + "-trail")
trail.append("text")
}

trail
.attr("width", width);
//.attr("height", 50)

// Add the label at the end, for the percentage.
trail.append("text")
trail.select("text")
.attr("id", el.id + "-endlabel")
.style("fill", "#000");
}
Expand Down

0 comments on commit fcb11b0

Please sign in to comment.