Skip to content

Commit

Permalink
Revert the change for #563 until I get the chance to look at it again
Browse files Browse the repository at this point in the history
  • Loading branch information
almossawi committed Jan 8, 2016
1 parent 6b79d0a commit 93a2b6e
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 100 deletions.
90 changes: 41 additions & 49 deletions dist/metricsgraphics.js
Expand Up @@ -860,16 +860,9 @@ function chart_title(args) {

var svg = mg_get_svg_child_of(args.target);

// remove the current title, and its associated event listeners, if it exists
if (args.show_tooltips && args.description) {
// TODO possible issue with memory leak due to d3's remove? investigate.
// tooltips are the only feature that require jquery
$(args.target + ' .mg-header').remove();
} else {
mg_remove_element(svg, '.mg-header');
}
//remove the current title if it exists
svg.select('.mg-header').remove();

// add the title
if (args.target && args.title) {
var chartTitle = svg.insert('text')
.attr('class', 'mg-header')
Expand All @@ -878,48 +871,47 @@ function chart_title(args) {
.attr('text-anchor', 'middle')
.attr('dy', '0.55em');

// show the title
//show the title
chartTitle.append('tspan')
.attr('class', 'mg-chart-title')
.text(args.title);

//show and activate the description icon if we have a description
if (args.show_tooltips && args.description) {
chartTitle.append('tspan')
.attr('class', 'mg-chart-title')
.text(args.title);

// show and activate the description icon if we have a description
if (args.show_tooltips && args.description) {
chartTitle.append('tspan')
.attr('class', 'mg-chart-description')
.attr('dx', '0.3em')
.text('\uf059');

// now that the title is an svg text element, we'll have to trigger
// mouseenter, mouseleave events manually for the popover to work properly
$(chartTitle.node()).popover({
html: true,
animation: false,
placement: 'top',
content: args.description,
container: args.target,
trigger: 'manual',
template: '<div class="popover mg-popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
}).on('mouseenter', function() {
d3.selectAll(args.target)
.selectAll('.mg-popover')
.remove();

$(this).popover('show');
$(args.target).select('.popover')
.on('mouseleave', function () {
$chartTitle.popover('hide');
});
}).on('mouseleave', function () {
setTimeout(function () {
if (!$('.popover:hover').length) {
$chartTitle.popover('hide');
}
}, 120);
});
}
.attr('class', 'mg-chart-description')
.attr('dx', '0.3em')
.text('\uf059');

//now that the title is an svg text element, we'll have to trigger
//mouseenter, mouseleave events manually for the popover to work properly
var $chartTitle = $(chartTitle.node());
$chartTitle.popover({
html: true,
animation: false,
placement: 'top',
content: args.description,
container: args.target,
trigger: 'manual',
template: '<div class="popover mg-popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
}).on('mouseenter', function() {
d3.selectAll(args.target)
.selectAll('.mg-popover')
.remove();

chartTitle = null;
$(this).popover('show');
$(args.target).select('.popover')
.on('mouseleave', function () {
$chartTitle.popover('hide');
});
}).on('mouseleave', function () {
setTimeout(function () {
if (!$('.popover:hover').length) {
$chartTitle.popover('hide');
}
}, 120);
});
}
}

if (args.error) {
Expand Down

0 comments on commit 93a2b6e

Please sign in to comment.