Skip to content

Commit

Permalink
Update other chart types (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
almossawi committed Mar 5, 2016
1 parent 565636b commit bdcaf45
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
19 changes: 12 additions & 7 deletions dist/metricsgraphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -3916,6 +3916,8 @@ MG.button_layout = function(target) {
var svg = mg_get_svg_child_of(args.target);
var $svg = $($(args.target).find('svg').get(0));

mg_add_g(svg, 'mg-active-datapoint-container');

//remove the old rollovers if they already exist
svg.selectAll('.mg-rollover-rect').remove();
svg.selectAll('.mg-active-datapoint').remove();
Expand Down Expand Up @@ -4003,7 +4005,7 @@ MG.button_layout = function(target) {
.classed('hist-symbol', true);

row.text(mg_format_x_mouseover(args, d)); // x
row.text(mg_format_y_mouseover(args, d, args.time_series === false));
row.text(mg_format_y_mouseover(args, d, args.time_series === false));
}

if (args.mouseover) {
Expand Down Expand Up @@ -4032,7 +4034,7 @@ MG.button_layout = function(target) {
.classed('active', false);

//reset active data point text
mg_remove_mouseover_container(svg);
mg_clear_mouseover_container(svg);
// svg.select('.mg-active-datapoint')
// .text('');

Expand Down Expand Up @@ -4082,7 +4084,7 @@ function point_mouseover (args, svg, d) {

mg_color_point_mouseover(args, row.text('\u25CF ').elem(), d); // point shape.
row.text(mg_format_x_mouseover(args, d)); // x
row.text(mg_format_y_mouseover(args, d, args.time_series === false));
row.text(mg_format_y_mouseover(args, d, args.time_series === false));
}

function mg_color_point_mouseover(args, elem, d) {
Expand All @@ -4103,7 +4105,7 @@ function mg_color_point_mouseover(args, elem, d) {
var x = args.x_accessor;
var y = args.y_accessor;
var new_data = data.filter(function(d){
return (args.min_x === null || d[x] >= args.min_x) &&
return (args.min_x === null || d[x] >= args.min_x) &&
(args.max_x === null || d[x] <= args.max_x) &&
(args.min_y === null || d[y] >= args.min_y) &&
(args.max_y === null || d[y] <= args.max_y);
Expand Down Expand Up @@ -4177,6 +4179,7 @@ function mg_color_point_mouseover(args, elem, d) {

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

//remove the old rollovers if they already exist
svg.selectAll('.mg-voronoi').remove();
Expand Down Expand Up @@ -4284,7 +4287,7 @@ function mg_color_point_mouseover(args, elem, d) {
}

//reset active data point text
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 Expand Up @@ -4659,6 +4662,8 @@ function mg_targeted_legend (args) {
var svg = mg_get_svg_child_of(args.target);
var g;

mg_add_g(svg, 'mg-active-datapoint-container');

//remove the old rollovers if they already exist
svg.selectAll('.mg-rollover-rect').remove();
svg.selectAll('.mg-active-datapoint').remove();
Expand Down Expand Up @@ -4775,7 +4780,7 @@ function mg_targeted_legend (args) {
return function(d, i) {
//reset active bar
var bar = svg.selectAll('g.mg-barplot .mg-bar.active').classed('active', false);

if (args.scales.hasOwnProperty('color')) {
bar.attr('fill', args.scalefns.color(d));
} else {
Expand All @@ -4786,7 +4791,7 @@ function mg_targeted_legend (args) {
svg.select('.mg-active-datapoint')
.text('');

mg_remove_mouseover_container(svg);
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.

6 changes: 4 additions & 2 deletions src/js/charts/bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ function mg_targeted_legend (args) {
var svg = mg_get_svg_child_of(args.target);
var g;

mg_add_g(svg, 'mg-active-datapoint-container');

//remove the old rollovers if they already exist
svg.selectAll('.mg-rollover-rect').remove();
svg.selectAll('.mg-active-datapoint').remove();
Expand Down Expand Up @@ -442,7 +444,7 @@ function mg_targeted_legend (args) {
return function(d, i) {
//reset active bar
var bar = svg.selectAll('g.mg-barplot .mg-bar.active').classed('active', false);

if (args.scales.hasOwnProperty('color')) {
bar.attr('fill', args.scalefns.color(d));
} else {
Expand All @@ -453,7 +455,7 @@ function mg_targeted_legend (args) {
svg.select('.mg-active-datapoint')
.text('');

mg_remove_mouseover_container(svg);
mg_clear_mouseover_container(svg);

if (args.mouseout) {
args.mouseout(d, i);
Expand Down
6 changes: 4 additions & 2 deletions src/js/charts/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
var svg = mg_get_svg_child_of(args.target);
var $svg = $($(args.target).find('svg').get(0));

mg_add_g(svg, 'mg-active-datapoint-container');

//remove the old rollovers if they already exist
svg.selectAll('.mg-rollover-rect').remove();
svg.selectAll('.mg-active-datapoint').remove();
Expand Down Expand Up @@ -158,7 +160,7 @@
.classed('hist-symbol', true);

row.text(mg_format_x_mouseover(args, d)); // x
row.text(mg_format_y_mouseover(args, d, args.time_series === false));
row.text(mg_format_y_mouseover(args, d, args.time_series === false));
}

if (args.mouseover) {
Expand Down Expand Up @@ -187,7 +189,7 @@
.classed('active', false);

//reset active data point text
mg_remove_mouseover_container(svg);
mg_clear_mouseover_container(svg);
// svg.select('.mg-active-datapoint')
// .text('');

Expand Down
7 changes: 4 additions & 3 deletions src/js/charts/point.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function point_mouseover (args, svg, d) {

mg_color_point_mouseover(args, row.text('\u25CF ').elem(), d); // point shape.
row.text(mg_format_x_mouseover(args, d)); // x
row.text(mg_format_y_mouseover(args, d, args.time_series === false));
row.text(mg_format_y_mouseover(args, d, args.time_series === false));
}

function mg_color_point_mouseover(args, elem, d) {
Expand All @@ -31,7 +31,7 @@ function mg_color_point_mouseover(args, elem, d) {
var x = args.x_accessor;
var y = args.y_accessor;
var new_data = data.filter(function(d){
return (args.min_x === null || d[x] >= args.min_x) &&
return (args.min_x === null || d[x] >= args.min_x) &&
(args.max_x === null || d[x] <= args.max_x) &&
(args.min_y === null || d[y] >= args.min_y) &&
(args.max_y === null || d[y] <= args.max_y);
Expand Down Expand Up @@ -105,6 +105,7 @@ function mg_color_point_mouseover(args, elem, d) {

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

//remove the old rollovers if they already exist
svg.selectAll('.mg-voronoi').remove();
Expand Down Expand Up @@ -212,7 +213,7 @@ function mg_color_point_mouseover(args, elem, d) {
}

//reset active data point text
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

0 comments on commit bdcaf45

Please sign in to comment.