From 9129abc6a19ad624c3bcada3e61ef4c59a8c05fa Mon Sep 17 00:00:00 2001 From: almossawi Date: Tue, 20 May 2014 11:11:21 -0700 Subject: [PATCH 1/3] Fix issue #33 --- js/main.js | 7 +++++++ js/metrics-graphics.js | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/js/main.js b/js/main.js index 8265f9adfa..3f8804c55d 100644 --- a/js/main.js +++ b/js/main.js @@ -55,6 +55,13 @@ $(document).ready(function() { area: false, xax_tick: 0, y_extended_ticks: true, + rollover_callback: function(d, i) { + //custom format the rollover text, show days + var prefix = d3.formatPrefix(d.value); + $('.active_datapoint') + .html('Day ' + (i+1) + '   ' + + prefix.scale(d.value).toFixed(2) + prefix.symbol); + }, height: torso.height, right: torso.right, target: '#long', diff --git a/js/metrics-graphics.js b/js/metrics-graphics.js index 2f8761a9d8..3777ac7baa 100644 --- a/js/metrics-graphics.js +++ b/js/metrics-graphics.js @@ -53,6 +53,7 @@ function moz_chart() { max_y: null, min_x: null, min_y: null, + rollover_callback: null, right: 10, scalefns: {}, scales: {}, @@ -649,6 +650,10 @@ charts.line = function(args) { + ', ' + args.y_accessor + ': ' + num(d[args.y_accessor]); } }); + + if(args.rollover_callback) { + args.rollover_callback(d, i); + } } } From f64452c1d45aa38046c42a5735def02ca794d2bf Mon Sep 17 00:00:00 2001 From: almossawi Date: Tue, 20 May 2014 11:14:13 -0700 Subject: [PATCH 2/3] Fix issue #60 --- js/metrics-graphics.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/js/metrics-graphics.js b/js/metrics-graphics.js index 3777ac7baa..d92f4e9699 100644 --- a/js/metrics-graphics.js +++ b/js/metrics-graphics.js @@ -29,8 +29,8 @@ function merge_with_defaults(obj){ return obj; }; - var charts = {}; +var time_series = true; function moz_chart() { var moz = {}; @@ -62,7 +62,6 @@ function moz_chart() { small_text: false, small_width_threshold: 160, target: '#viz', - time_series: true, top: 40, width: 350, x_accessor: 'date', @@ -148,7 +147,7 @@ function xAxis(args) { min_x = args.min_x ? args.min_x : min_x; max_x = args.max_x ? args.max_x : max_x; - args.scales.X = (args.time_series) + args.scales.X = (time_series) ? d3.time.scale() : d3.scale.linear(); @@ -213,7 +212,7 @@ function xAxis(args) { }) //are we adding years to x-axis - if (args.time_series && args.show_years) { + if (time_series && args.show_years) { var min_x; var max_x; @@ -384,10 +383,10 @@ function init(args) { //do we have a time_series? if($.type(args.data[0][0][args.x_accessor]) == 'date') { - args.time_series = true; + time_series = true; } else { - args.time_series = false; + time_series = false; } var linked; @@ -639,7 +638,7 @@ charts.line = function(args) { .attr('y', args.top / 2) .attr('text-anchor', 'end') .text(function() { - if(args.time_series) { + if(time_series) { var dd = new Date(+d[args.x_accessor]); dd.setDate(dd.getDate()); From 0e6e1a45ae6f3037bcd02493ece27c828331db10 Mon Sep 17 00:00:00 2001 From: almossawi Date: Tue, 20 May 2014 11:16:04 -0700 Subject: [PATCH 3/3] Cleaned up chart titles --- js/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/main.js b/js/main.js index 3f8804c55d..1489557367 100644 --- a/js/main.js +++ b/js/main.js @@ -48,8 +48,8 @@ $(document).ready(function() { }) moz_chart({ - title: "Extended Ticks", - description: "A longer chart with extended horizontal ticks enabled.", + title: "Extended Ticks, Custom Rollover", + description: "A wider chart with extended horizontal ticks enabled and a custom rollover text.", data: data, width: 960, area: false, @@ -136,7 +136,7 @@ $(document).ready(function() { moz_chart({ left: 80, bottom: 50, - title: "X-axis not time", + title: "X-axis Not Time", description: "A chart where we're not plotting dates on the x-axis and where the axes include labels.", data: data, area: false,