Skip to content

Commit

Permalink
closes w3c#511
Browse files Browse the repository at this point in the history
  • Loading branch information
hamilton committed Oct 27, 2015
1 parent bddf299 commit 1f043ec
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 83 deletions.
23 changes: 6 additions & 17 deletions dist/metricsgraphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ MG.data_graphic = function(args) {
full_height: false, // sets the graphic width to be the width of the parent element and resizes dynamically
small_height_threshold: 120, // the height threshold for when smaller text appears
small_width_threshold: 160, // the width threshold for when smaller text appears
small_text: false, // coerces small text regardless of graphic size
//small_text: false, // coerces small text regardless of graphic size
xax_count: 6, // number of x axis ticks
xax_tick_length: 5, // x axis tick length
axes_not_compact: true,
Expand Down Expand Up @@ -1128,8 +1128,7 @@ function y_axis(args) {

//y axis
g = svg.append('g')
.classed('mg-y-axis', true)
.classed('mg-y-axis-small', args.use_small_class);
.classed('mg-y-axis', true);

//are we adding a label?
if (args.y_label) {
Expand Down Expand Up @@ -1269,8 +1268,7 @@ function y_axis_categorical(args) {
svg.selectAll('.mg-y-axis').remove();

var g = svg.append('g')
.classed('mg-y-axis', true)
.classed('mg-y-axis-small', args.use_small_class);
.classed('mg-y-axis', true);

if (!args.y_axis) {
return this;
Expand Down Expand Up @@ -1391,8 +1389,7 @@ function x_axis(args) {

//x axis
g = svg.append('g')
.classed('mg-x-axis', true)
.classed('mg-x-axis-small', args.use_small_class);
.classed('mg-x-axis', true);

var last_i = args.scales.X.ticks(args.xax_count).length - 1;

Expand Down Expand Up @@ -1435,8 +1432,7 @@ function x_axis_categorical(args) {
svg.selectAll('.mg-x-axis').remove();

var g = svg.append('g')
.classed('mg-x-axis', true)
.classed('mg-x-axis-small', args.use_small_class);
.classed('mg-x-axis', true);

if (!args.x_axis) {
return this;
Expand Down Expand Up @@ -1776,7 +1772,6 @@ function mg_add_x_tick_labels(g, args) {
//append year marker to x-axis group
g = g.append('g')
.classed('mg-year-marker', true)
.classed('mg-year-marker-small', args.use_small_class);

if (time_frame === 'default' && args.show_year_markers) {
g.selectAll('.mg-year-marker')
Expand Down Expand Up @@ -2017,10 +2012,6 @@ function init(args) {
//add chart title if it's different than existing one
chart_title(args);

//draw axes
args.use_small_class = args.height - args.top - args.bottom - args.buffer
<= args.small_height_threshold && args.width - args.left-args.right - args.buffer * 2
<= args.small_width_threshold || args.small_text;

//if we're updating an existing chart and we have fewer lines than
//before, remove the outdated lines, e.g. if we had 3 lines, and we're calling
Expand Down Expand Up @@ -2134,8 +2125,7 @@ function markers(args) {

if (args.baselines) {
gb = svg.append('g')
.attr('class', 'mg-baselines')
.classed('mg-baselines-small', args.use_small_class);
.attr('class', 'mg-baselines');

gb.selectAll('.mg-baselines')
.data(args.baselines)
Expand Down Expand Up @@ -2799,7 +2789,6 @@ MG.button_layout = function(target) {
.attr('class', 'mg-active-datapoint-container')
.append('text')
.attr('class', 'mg-active-datapoint')
.classed('mg-active-datapoint-small', args.use_small_class)
.attr('xml:space', 'preserve')
.attr('text-anchor', 'end');

Expand Down
6 changes: 3 additions & 3 deletions dist/metricsgraphics.min.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/js/charts/line.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/js/common/data_graphic.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ MG.data_graphic = function(args) {
full_height: false, // sets the graphic width to be the width of the parent element and resizes dynamically
small_height_threshold: 120, // the height threshold for when smaller text appears
small_width_threshold: 160, // the width threshold for when smaller text appears
small_text: false, // coerces small text regardless of graphic size
//small_text: false, // coerces small text regardless of graphic size
xax_count: 6, // number of x axis ticks
xax_tick_length: 5, // x axis tick length
axes_not_compact: true,
Expand Down
4 changes: 0 additions & 4 deletions src/js/common/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ function init(args) {
//add chart title if it's different than existing one
chart_title(args);

//draw axes
args.use_small_class = args.height - args.top - args.bottom - args.buffer
<= args.small_height_threshold && args.width - args.left-args.right - args.buffer * 2
<= args.small_width_threshold || args.small_text;

//if we're updating an existing chart and we have fewer lines than
//before, remove the outdated lines, e.g. if we had 3 lines, and we're calling
Expand Down
3 changes: 1 addition & 2 deletions src/js/common/markers.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ function markers(args) {

if (args.baselines) {
gb = svg.append('g')
.attr('class', 'mg-baselines')
.classed('mg-baselines-small', args.use_small_class);
.attr('class', 'mg-baselines');

gb.selectAll('.mg-baselines')
.data(args.baselines)
Expand Down
7 changes: 2 additions & 5 deletions src/js/common/x_axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ function x_axis(args) {

//x axis
g = svg.append('g')
.classed('mg-x-axis', true)
.classed('mg-x-axis-small', args.use_small_class);
.classed('mg-x-axis', true);

var last_i = args.scales.X.ticks(args.xax_count).length - 1;

Expand Down Expand Up @@ -132,8 +131,7 @@ function x_axis_categorical(args) {
svg.selectAll('.mg-x-axis').remove();

var g = svg.append('g')
.classed('mg-x-axis', true)
.classed('mg-x-axis-small', args.use_small_class);
.classed('mg-x-axis', true);

if (!args.x_axis) {
return this;
Expand Down Expand Up @@ -473,7 +471,6 @@ function mg_add_x_tick_labels(g, args) {
//append year marker to x-axis group
g = g.append('g')
.classed('mg-year-marker', true)
.classed('mg-year-marker-small', args.use_small_class);

if (time_frame === 'default' && args.show_year_markers) {
g.selectAll('.mg-year-marker')
Expand Down
6 changes: 2 additions & 4 deletions src/js/common/y_axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ function y_axis(args) {

//y axis
g = svg.append('g')
.classed('mg-y-axis', true)
.classed('mg-y-axis-small', args.use_small_class);
.classed('mg-y-axis', true);

//are we adding a label?
if (args.y_label) {
Expand Down Expand Up @@ -349,8 +348,7 @@ function y_axis_categorical(args) {
svg.selectAll('.mg-y-axis').remove();

var g = svg.append('g')
.classed('mg-y-axis', true)
.classed('mg-y-axis-small', args.use_small_class);
.classed('mg-y-axis', true);

if (!args.y_axis) {
return this;
Expand Down
28 changes: 14 additions & 14 deletions tests/common/markers_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,17 @@ test('When an existing chart is updated with no baselines, existing baselines ar
equal(document.querySelectorAll('.mg-baselines').length, 0, 'Old baselines were cleared');
});

test('args.small_text', function() {
var baselines = [{value:50, label:'a baseline'}];

var params = {
target: '#qunit-fixture',
data: [{'date': new Date('2014-01-01'), 'value': 100},
{'date': new Date('2014-03-01'), 'value': 10}],
baselines: baselines,
small_text: true
};

MG.data_graphic(params);
ok(document.querySelector('.mg-baselines-small'), 'Small baselines is set');
});
// test('args.small_text', function() {
// var baselines = [{value:50, label:'a baseline'}];

// var params = {
// target: '#qunit-fixture',
// data: [{'date': new Date('2014-01-01'), 'value': 100},
// {'date': new Date('2014-03-01'), 'value': 10}],
// baselines: baselines,
// small_text: true
// };

// MG.data_graphic(params);
// ok(document.querySelector('.mg-baselines-small'), 'Small baselines is set');
// });
44 changes: 22 additions & 22 deletions tests/common/x_axis_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,28 @@ test('X-axis doesn\'t break when data object is of length 1', function() {
ok(document.querySelector('.mg-x-axis'), 'X-axis exists');
});

test('args.small_text', function() {
var params = {
target: '#qunit-fixture',
data: [{'date': new Date('2014-01-01'), 'value': 12}],
small_text: true,
};

MG.data_graphic(params);
ok(document.querySelector('.mg-x-axis-small'), 'Small x-axis is set');
});

test('args.small_text and args.show_secondary_x_label', function() {
var params = {
target: '#qunit-fixture',
data: [{'date': new Date('2014-01-01'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}],
small_text: true
};

MG.data_graphic(params);
ok(document.querySelector('.mg-year-marker-small'), 'Small year-marker is set');
});
// test('args.small_text', function() {
// var params = {
// target: '#qunit-fixture',
// data: [{'date': new Date('2014-01-01'), 'value': 12}],
// small_text: true,
// };

// MG.data_graphic(params);
// ok(document.querySelector('.mg-x-axis-small'), 'Small x-axis is set');
// });

// test('args.small_text and args.show_secondary_x_label', function() {
// var params = {
// target: '#qunit-fixture',
// data: [{'date': new Date('2014-01-01'), 'value': 12},
// {'date': new Date('2014-03-01'), 'value': 18}],
// small_text: true
// };

// MG.data_graphic(params);
// ok(document.querySelector('.mg-year-marker-small'), 'Small year-marker is set');
// });

test('args.x_rug', function() {
var params = {
Expand Down
20 changes: 10 additions & 10 deletions tests/common/y_axis_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ test('Y-axis doesn\'t break when data object is of length 1', function() {
ok(document.querySelector('.mg-y-axis'), 'Y-axis exists');
});

test('args.small_text', function() {
var params = {
target: '#qunit-fixture',
data: [{'date': new Date('2014-01-01'), 'value': 12}],
small_text: true,
};

MG.data_graphic(params);
ok(document.querySelector('.mg-y-axis-small'), 'Small y-axis is set');
});
// test('args.small_text', function() {
// var params = {
// target: '#qunit-fixture',
// data: [{'date': new Date('2014-01-01'), 'value': 12}],
// small_text: true,
// };

// MG.data_graphic(params);
// ok(document.querySelector('.mg-y-axis-small'), 'Small y-axis is set');
// });

test('args.y_rug', function() {
var params = {
Expand Down

0 comments on commit 1f043ec

Please sign in to comment.