Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
almossawi committed Mar 5, 2016
1 parent 58d26b9 commit 565636b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 65 deletions.
38 changes: 7 additions & 31 deletions dist/metricsgraphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -2473,15 +2473,16 @@ MG.markers = markers;
/////////////////////////////////////////////////////////////////////////////////////////


function mg_remove_mouseover_container(svg) {
svg.selectAll('.mg-active-datapoint-container').remove();
function mg_clear_mouseover_container (svg) {
svg.selectAll('.mg-active-datapoint-container').selectAll('*').remove();
}

function mg_setup_mouseover_container (svg, args) {
svg.select('.mg-active-datapoint').remove();
var text_anchor = args.mouseover_align === 'right' ? 'end' : (args.mouseover_align === 'left' ? 'start' : 'middle');
var mouseover_x = args.mouseover_align === 'right' ? mg_get_plot_right(args) : (args.mouseover_align === 'left' ? mg_get_plot_left(args) : (args.width-args.left-args.right) / 2 + args.left);
var active_datapoint = mg_add_g(svg, 'mg-active-datapoint-container')

var active_datapoint = svg.select('.mg-active-datapoint-container')
.append('text')
.attr('class', 'mg-active-datapoint')
.attr('xml:space', 'preserve')
Expand Down Expand Up @@ -3221,32 +3222,7 @@ MG.button_layout = function(target) {
// remove the old rollover text and circle if they already exist
mg_selectAll_and_remove(svg, '.mg-active-datapoint');
mg_selectAll_and_remove(svg, '.mg-line-rollover-circle');
mg_selectAll_and_remove(svg, '.mg-active-datapoint-container');
}

function mg_add_line_active_datapoint_container(args, svg) {
var activeDatapointContainer = mg_add_g(svg, 'mg-active-datapoint-container')
.append('text')
.attr('class', 'mg-active-datapoint')
.attr('xml:space', 'preserve')
.attr('text-anchor', 'end');

// set the rollover text's position; if we have markers on two lines,
// nudge up the rollover text a bit
var activeDatapointYnudge = 0.75;
if (args.markers) {
var yPos;
svg.selectAll('.mg-marker-text')
.each(function () {
if (!yPos) {
yPos = d3.select(this).attr('y');
} else if (yPos !== d3.select(this).attr('y')) {
activeDatapointYnudge = 0.56;
}
});
}
activeDatapointContainer
.attr('transform', 'translate(' + (mg_get_plot_right(args)) + ',' + (mg_get_top(args) * activeDatapointYnudge) + ')');
//mg_selectAll_and_remove(svg, '.mg-active-datapoint-container');
}

function mg_add_rollover_circle (args, svg) {
Expand Down Expand Up @@ -3592,9 +3568,9 @@ MG.button_layout = function(target) {

function mg_line_rollover_setup (args, graph) {
var svg = mg_get_svg_child_of(args.target);
mg_add_g(svg, 'mg-active-datapoint-container');

mg_remove_existing_line_rollover_elements(svg);
//mg_add_line_active_datapoint_container(args, svg);
mg_add_rollover_circle(args, svg);
mg_set_unique_line_id_for_each_series(args);

Expand Down Expand Up @@ -3841,7 +3817,7 @@ MG.button_layout = function(target) {
}

//mg_remove_active_text(svg);
if (args.data[0].length > 1) mg_remove_mouseover_container(svg);
if (args.data[0].length > 1) mg_clear_mouseover_container(svg);
if (args.mouseout) {
args.mouseout(d, i);
}
Expand Down
6 changes: 3 additions & 3 deletions dist/metricsgraphics.min.js

Large diffs are not rendered by default.

31 changes: 3 additions & 28 deletions src/js/charts/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,32 +251,7 @@
// remove the old rollover text and circle if they already exist
mg_selectAll_and_remove(svg, '.mg-active-datapoint');
mg_selectAll_and_remove(svg, '.mg-line-rollover-circle');
mg_selectAll_and_remove(svg, '.mg-active-datapoint-container');
}

function mg_add_line_active_datapoint_container(args, svg) {
var activeDatapointContainer = mg_add_g(svg, 'mg-active-datapoint-container')
.append('text')
.attr('class', 'mg-active-datapoint')
.attr('xml:space', 'preserve')
.attr('text-anchor', 'end');

// set the rollover text's position; if we have markers on two lines,
// nudge up the rollover text a bit
var activeDatapointYnudge = 0.75;
if (args.markers) {
var yPos;
svg.selectAll('.mg-marker-text')
.each(function () {
if (!yPos) {
yPos = d3.select(this).attr('y');
} else if (yPos !== d3.select(this).attr('y')) {
activeDatapointYnudge = 0.56;
}
});
}
activeDatapointContainer
.attr('transform', 'translate(' + (mg_get_plot_right(args)) + ',' + (mg_get_top(args) * activeDatapointYnudge) + ')');
//mg_selectAll_and_remove(svg, '.mg-active-datapoint-container');
}

function mg_add_rollover_circle (args, svg) {
Expand Down Expand Up @@ -622,9 +597,9 @@

function mg_line_rollover_setup (args, graph) {
var svg = mg_get_svg_child_of(args.target);
mg_add_g(svg, 'mg-active-datapoint-container');

mg_remove_existing_line_rollover_elements(svg);
//mg_add_line_active_datapoint_container(args, svg);
mg_add_rollover_circle(args, svg);
mg_set_unique_line_id_for_each_series(args);

Expand Down Expand Up @@ -871,7 +846,7 @@
}

//mg_remove_active_text(svg);
if (args.data[0].length > 1) mg_remove_mouseover_container(svg);
if (args.data[0].length > 1) mg_clear_mouseover_container(svg);
if (args.mouseout) {
args.mouseout(d, i);
}
Expand Down
7 changes: 4 additions & 3 deletions src/js/common/rollover.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,16 @@
/////////////////////////////////////////////////////////////////////////////////////////


function mg_remove_mouseover_container(svg) {
svg.selectAll('.mg-active-datapoint-container').remove();
function mg_clear_mouseover_container (svg) {
svg.selectAll('.mg-active-datapoint-container').selectAll('*').remove();
}

function mg_setup_mouseover_container (svg, args) {
svg.select('.mg-active-datapoint').remove();
var text_anchor = args.mouseover_align === 'right' ? 'end' : (args.mouseover_align === 'left' ? 'start' : 'middle');
var mouseover_x = args.mouseover_align === 'right' ? mg_get_plot_right(args) : (args.mouseover_align === 'left' ? mg_get_plot_left(args) : (args.width-args.left-args.right) / 2 + args.left);
var active_datapoint = mg_add_g(svg, 'mg-active-datapoint-container')

var active_datapoint = svg.select('.mg-active-datapoint-container')
.append('text')
.attr('class', 'mg-active-datapoint')
.attr('xml:space', 'preserve')
Expand Down

0 comments on commit 565636b

Please sign in to comment.