Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	dist/metricsgraphics.min.js
  • Loading branch information
almossawi committed Nov 18, 2016
2 parents 24c7240 + 7501a63 commit f7912c7
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 12 deletions.
6 changes: 4 additions & 2 deletions dist/metricsgraphics.js
Expand Up @@ -353,7 +353,7 @@ function mg_target_ref(target) {
return mg_normalize(target);

} else if (target instanceof window.HTMLElement) {
target_ref = target.getAttribute('data-mg-uid');
var target_ref = target.getAttribute('data-mg-uid');
if (!target_ref) {
target_ref = mg_next_id();
target.setAttribute('data-mg-uid', target_ref);
Expand Down Expand Up @@ -3874,7 +3874,7 @@ function mg_remove_existing_markers(svg) {

function mg_in_range(args) {
return function(d) {
return (args.scales.X(d[args.x_accessor]) > mg_get_plot_left(args)) && (args.scales.X(d[args.x_accessor]) < mg_get_plot_right(args));
return (args.scales.X(d[args.x_accessor]) >= mg_get_plot_left(args)) && (args.scales.X(d[args.x_accessor]) <= mg_get_plot_right(args));
};
}

Expand Down Expand Up @@ -5822,6 +5822,7 @@ function mg_color_point_mouseover(args, elem, d) {
.zeroLine(args.y_axis_type === 'categorical')
.position(args.x_axis_position)
.rug(x_rug(args))
.label(mg_add_x_label)
.draw();

new MG.axis_factory(args)
Expand All @@ -5830,6 +5831,7 @@ function mg_color_point_mouseover(args, elem, d) {
.zeroLine(args.x_axis_type === 'categorical')
.position(args.y_axis_position)
.rug(y_rug(args))
.label(mg_add_y_label)
.draw();

this.mainPlot();
Expand Down
6 changes: 3 additions & 3 deletions dist/metricsgraphics.min.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions gulp/index.js
Expand Up @@ -10,8 +10,7 @@ var
//minifycss = require('gulp-minify-css'), // for minifiing css
jshint = require('gulp-jshint'),
testem = require('gulp-testem'),
connect = require('gulp-connect'),
es6ModuleTranspiler = require("gulp-es6-module-transpiler");
connect = require('gulp-connect');

// paths
var
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -43,7 +43,6 @@
"gulp": "^3.8.10",
"gulp-concat": "^2.4.2",
"gulp-connect": "^2.2.0",
"gulp-es6-module-transpiler": "^0.2.0",
"gulp-jshint": "^1.9.0",
"gulp-rename": "^1.2.0",
"gulp-rimraf": "^0.1.1",
Expand Down
2 changes: 2 additions & 0 deletions src/js/charts/point.js
Expand Up @@ -163,6 +163,7 @@ function mg_color_point_mouseover(args, elem, d) {
.zeroLine(args.y_axis_type === 'categorical')
.position(args.x_axis_position)
.rug(x_rug(args))
.label(mg_add_x_label)
.draw();

new MG.axis_factory(args)
Expand All @@ -171,6 +172,7 @@ function mg_color_point_mouseover(args, elem, d) {
.zeroLine(args.x_axis_type === 'categorical')
.position(args.y_axis_position)
.rug(y_rug(args))
.label(mg_add_y_label)
.draw();

this.mainPlot();
Expand Down
2 changes: 1 addition & 1 deletion src/js/common/markers.js
Expand Up @@ -9,7 +9,7 @@ function mg_remove_existing_markers(svg) {

function mg_in_range(args) {
return function(d) {
return (args.scales.X(d[args.x_accessor]) > mg_get_plot_left(args)) && (args.scales.X(d[args.x_accessor]) < mg_get_plot_right(args));
return (args.scales.X(d[args.x_accessor]) >= mg_get_plot_left(args)) && (args.scales.X(d[args.x_accessor]) <= mg_get_plot_right(args));
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/js/misc/utility.js
Expand Up @@ -342,7 +342,7 @@ function mg_target_ref(target) {
return mg_normalize(target);

} else if (target instanceof window.HTMLElement) {
target_ref = target.getAttribute('data-mg-uid');
var target_ref = target.getAttribute('data-mg-uid');
if (!target_ref) {
target_ref = mg_next_id();
target.setAttribute('data-mg-uid', target_ref);
Expand Down
24 changes: 22 additions & 2 deletions tests/common/markers_test.js
Expand Up @@ -25,13 +25,13 @@ test('Markers that lie outside the visible range are excluded', function() {
'date': new Date('2014-02-01'),
'label': '1st Milestone'
}, {
'date': new Date('2014-02-02'),
'date': new Date('2014-02-03'),
'label': '2nd Milestone'
}];

var params = {
target: '#qunit-fixture',
data: [{'date': new Date('2014-02-01'), 'value': 12},
data: [{'date': new Date('2014-02-02'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}],
markers: markers
};
Expand All @@ -40,6 +40,26 @@ test('Markers that lie outside the visible range are excluded', function() {
equal(document.querySelectorAll(params.target + ' .mg-markers line').length, 1, 'One marker added');
});

test('Markers that lie at the edge of the visible range are included', function() {
var markers = [{
'date': new Date('2014-02-01'),
'label': '1st Milestone'
}, {
'date': new Date('2014-03-01'),
'label': '2nd Milestone'
}];

var params = {
target: '#qunit-fixture',
data: [{'date': new Date('2014-02-01'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}],
markers: markers
};

MG.data_graphic(params);
equal(document.querySelectorAll(params.target + ' .mg-markers line').length, markers.length, 'Two markers added');
});

test('All baselines are added', function() {
var baselines = [{value:50, label:'a baseline'}];

Expand Down
15 changes: 15 additions & 0 deletions tests/common/x_axis_test.js
Expand Up @@ -71,6 +71,21 @@ test('args.x_label', function() {
ok(document.querySelector('.mg-x-axis .label'), 'X-axis label exists');
});

test('args.labels (scatter plot)', function() {
var params = {
target: '#qunit-fixture',
data: [{'date': new Date('2014-01-01'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}],
x_label: 'foo bar',
y_label: 'bar foo',
chart_type: 'point'
};

MG.data_graphic(params);
ok(document.querySelector('.mg-x-axis .label'), 'X-axis label exists');
ok(document.querySelector('.mg-y-axis .label'), 'Y-axis label exists');
});

test('X-axis doesn\'t break when data object is of length 1', function() {
var params = {
target: '#qunit-fixture',
Expand Down

0 comments on commit f7912c7

Please sign in to comment.