Permalink
Browse files

add label support for scatter plots

  • Loading branch information...
1 parent f2cdd70 commit fd93db17ea85035c8a4419c4d904962413d3e504 @Ezekiel-DA Ezekiel-DA committed Nov 13, 2016
Showing with 23 additions and 4 deletions.
  1. +3 −1 dist/metricsgraphics.js
  2. +3 −3 dist/metricsgraphics.min.js
  3. +2 −0 src/js/charts/point.js
  4. +15 −0 tests/common/x_axis_test.js
@@ -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));
};
}
@@ -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)
@@ -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();
Oops, something went wrong.
@@ -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)
@@ -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();
@@ -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',

0 comments on commit fd93db1

Please sign in to comment.