diff --git a/css/metricsgraphics.css b/css/metricsgraphics.css index 1feea49584..316144bc16 100644 --- a/css/metricsgraphics.css +++ b/css/metricsgraphics.css @@ -333,7 +333,6 @@ td.data-table { } td.table-text { - font-style: italic; opacity: 0.8; padding-left: 30px; } \ No newline at end of file diff --git a/js/main.js b/js/main.js index b759d6faec..ec9e15eb24 100644 --- a/js/main.js +++ b/js/main.js @@ -871,10 +871,10 @@ $(document).ready(function() { // data tables var table_data = [ - {'year': 1852,'value1': 10.2, 'value2': 1030004.43423,'share':.12, 'total':3403400, 'temp': 43, 'geo': 'United Kingdom', 'description': "Having a way of describing a row can be useful."}, - {'year': 1901,'value1': 10.1, 'value2': 54003.223, 'share':.11, 'total':43002100, 'temp': 55, 'geo': 'United States', 'description': "More made-up numbers."}, + {'year': 1852,'value1': 10.2, 'value2': 1030004.43423,'share':.12, 'total':34003400, 'temp': 43, 'geo': 'United Kingdom', 'description': "Having a way of describing a row can be useful."}, + {'year': 1901,'value1': 10.1, 'value2': 54003.223, 'share':.11, 'total':4302100, 'temp': 55, 'geo': 'United States', 'description': "More made-up numbers."}, {'year': 1732,'value1': 4.3, 'value2': 1004.91422, 'share':.14, 'total':4300240, 'temp': 42, 'geo': 'France', 'description': "We didn't specify a title for this column."}, - {'year': 1945,'value1': 2.9, 'value2': 2430.121, 'share':.23, 'total':2400000, 'temp': 54, 'geo': 'Brazil', 'description': "Brazil, Brazil."}, + {'year': 1945,'value1': 2.9, 'value2': 2430.121, 'share':.23, 'total':24000000, 'temp': 54, 'geo': 'Brazil', 'description': "Brazil, Brazil."}, {'year': 1910,'value1': 1.0, 'value2': 5432.3, 'share':.19, 'total':130000, 'temp': 52, 'geo': 'India', 'description': "Last description in the whole thing."} ] @@ -886,11 +886,18 @@ $(document).ready(function() { .target('#table1') .title( {accessor: 'geo', secondary_accessor:'year', label: 'Country'}) .number({accessor: 'value1', label: 'Size', value_formatter:function(d){return d+' yrds'}}) - .number({accessor: 'value2', label: 'Score', round:2}) - .number({accessor: 'temp', label: 'Temp.', format:'temperature', width:100}) - .number({accessor: 'total', label: 'Volume', format:'count', currency:'$', width:100}) + .number({accessor: 'value2', label: 'Score', round:2, font_weight: 'bold'}) + .number({accessor: 'temp', label: 'Temp.', format:'temperature', width:100, color: 'gray'}) + .number({ + accessor: 'total', + label: 'Volume', + format:'count', currency:'$', + width:100, + font_weight: function(d){return d < 5000000 ? 'bold' : '300'}, + color: function(d){return d < 5000000 ? '#b20000' : 'black'} + }) .number({accessor: 'share', label: 'Share', format:'percentage', width:100}) - .text({accessor: 'description', width:240}) + .text({accessor: 'description', width:240, font_style: 'italic'}) .display(); //add this scatterplot and color the groups based on the theme diff --git a/src/charts/table.js b/src/charts/table.js index 03ffaf731f..79282b81e4 100644 --- a/src/charts/table.js +++ b/src/charts/table.js @@ -17,8 +17,27 @@ var table = New data_table(data) function data_table(args){ 'use strict'; this.args = args; - this.args.standard_col = {width:150, font_size:12}; + this.args.standard_col = {width:150, font_size:12, font_weight:'normal'}; this.args.columns = []; + this.formatting_options = [['color', 'color'], ['font-weight', 'font_weight'], ['font-style', 'font_style'], ['font-size', 'font_size']]; + + this._strip_punctuation = function(s){ + var punctuationless = s.replace(/[^a-zA-Z0-9 _]+/g, ''); + var finalString = punctuationless.replace(/ +?/g, ""); + return finalString; + } + + this._format_element = function(element, value, args){ + this.formatting_options.forEach(function(fo){ + var attr = fo[0]; + var key = fo[1]; + if (args[key]) element.style(attr, + typeof args[key] == 'string' || + typeof args[key] == 'number' ? + args[key] : args[key](value)); + }); + + } this._add_column = function(_args, arg_type){ var standard_column = this.args.standard_col; @@ -66,6 +85,7 @@ function data_table(args){ } this.display = function(){ + var this_column; var args = this.args; @@ -77,8 +97,8 @@ function data_table(args){ var thead = table.append('thead').classed('data-table-thead', true); var tbody = table.append('tbody'); - var this_column; - var tr, th, td_accessor, td_type, th_text, td_text, td; + var this_column, this_title; + var tr, th, td_accessor, td_type, td_value, th_text, td_text, td; var col; tr = thead.append('tr').classed('header-row', true); @@ -106,7 +126,7 @@ function data_table(args){ for (var j=0;j