From ef4d6e1b1e401026ff83899f198623debb8848e2 Mon Sep 17 00:00:00 2001 From: almossawi Date: Thu, 28 Jul 2016 14:19:34 -0700 Subject: [PATCH] #671 --- examples/charts/experimental.htm | 20 ++++++++------------ src/js/common/x_axis.js | 2 +- src/js/common/y_axis.js | 2 +- src/js/misc/process.js | 9 +++++---- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/examples/charts/experimental.htm b/examples/charts/experimental.htm index 9882f2f0ee..7fb54b5d16 100644 --- a/examples/charts/experimental.htm +++ b/examples/charts/experimental.htm @@ -443,7 +443,7 @@ mouseover: function(d, i) { var pf = d3.format(',.2f'); d3.select('#histogram1 svg .mg-active-datapoint') - .text('Value: ' + pf(d.x) + ' Count: ' + pf(d.y)); + .text('Value: ' + pf(d.x) + ' Count: ' + d.y); } }); @@ -494,7 +494,7 @@ mouseover: function(d, i) { var pf = d3.format(',.2f'); d3.select('#histogram2 svg .mg-active-datapoint') - .text('Value: ' + pf(d.x) + ' Count: ' + pf(d.y)); + .text('Value: ' + pf(d.x) + ' Count: ' + d.y); } }); @@ -516,7 +516,7 @@ mouseover: function(d, i) { var pf = d3.format(',.2f'); d3.select('#histogram3 svg .mg-active-datapoint') - .text('Value: ' + pf(d.x) + ' Count: ' + pf(d.y)); + .text('Value: ' + pf(d.x) + ' Count: ' + d.y); } }); @@ -538,7 +538,7 @@ mouseover: function(d, i) { var pf = d3.format(',.2f'); d3.select('#histogram4 svg .mg-active-datapoint') - .text('Value: ' + pf(d.x) + ' Count: ' + pf(d.y)); + .text('Value: ' + pf(d.x) + ' Count: ' + d.y); } }); @@ -744,7 +744,6 @@ chart_type: 'histogram', width: 295, height: 180, - right: 10, bins: 50, bar_margin: 0, target: '#histogram1', @@ -752,7 +751,7 @@ mouseover: function(d, i) { var pf = d3.format(',.2f'); d3.select('#histogram1 svg .mg-active-datapoint') - .text('Value: ' + pf(d.x) + ' Count: ' + pf(d.y)); + .text('Value: ' + pf(d.x) + ' Count: ' + d.y); } }); @@ -795,7 +794,6 @@ chart_type: 'histogram', width: 295, height: 180, - right: 10, target: '#histogram2', y_extended_ticks: true, x_accessor: 'value', @@ -803,7 +801,7 @@ mouseover: function(d, i) { var pf = d3.format(',.2f'); d3.select('#histogram2 svg .mg-active-datapoint') - .text('Value: ' + pf(d.x) + ' Count: ' + pf(d.y)); + .text('Value: ' + pf(d.x) + ' Count: ' + d.y); } }); @@ -817,7 +815,6 @@ chart_type: 'histogram', width: 295, height: 180, - right: 10, target: '#histogram3', linked: true, y_extended_ticks: true, @@ -825,7 +822,7 @@ mouseover: function(d, i) { var pf = d3.format(',.2f'); d3.select('#histogram3 svg .mg-active-datapoint') - .text('Value: ' + pf(d.x) + ' Count: ' + pf(d.y)); + .text('Value: ' + pf(d.x) + ' Count: ' + d.y); } }); @@ -840,14 +837,13 @@ chart_type: 'histogram', width: 295, height: 180, - right: 10, target: '#histogram4', y_extended_ticks: true, x_accessor: 'val1', mouseover: function(d, i) { var pf = d3.format(',.2f'); d3.select('#histogram4 svg .mg-active-datapoint') - .text('Value: ' + pf(d.x) + ' Count: ' + pf(d.y)); + .text('Value: ' + pf(d.x) + ' Count: ' + d.y); } }); diff --git a/src/js/common/x_axis.js b/src/js/common/x_axis.js index 3c2bd09c63..328e4f3d2d 100644 --- a/src/js/common/x_axis.js +++ b/src/js/common/x_axis.js @@ -320,7 +320,7 @@ function mg_default_xax_format(args) { return args.processed.main_x_time_format(new Date(d)); } else if (typeof test_point_x === 'number') { var pf; - if (d < 1.0 && d > 0) { + if (d < 1.0 && d !== 0) { // don't scale tiny values pf = d3.format(',.' + args.decimals + 'f'); } else if (d < 1000) { diff --git a/src/js/common/y_axis.js b/src/js/common/y_axis.js index 1c3a315c7f..a921338a7a 100644 --- a/src/js/common/y_axis.js +++ b/src/js/common/y_axis.js @@ -803,7 +803,7 @@ function mg_compute_yax_format (args) { yax_format = function (f) { var pf; - if (f < 1.0 && f > 0) { + if (f < 1.0 && f !== 0) { // don't scale tiny values pf = d3.format(',.' + args.decimals + 'f'); } else if (f < 1000) { diff --git a/src/js/misc/process.js b/src/js/misc/process.js index 6cb0849a3f..9ba6acde61 100644 --- a/src/js/misc/process.js +++ b/src/js/misc/process.js @@ -292,10 +292,11 @@ function process_histogram(args) { hist.thresholds(args.bins); } - args.processed_data = hist(extracted_data) - .map(function(d) { - return { 'x': d.x0, 'y': d.x1 }; - }); + var bins = hist(extracted_data); + + args.processed_data = bins.map(function(d) { + return { 'x': d.x0, 'y': d.length }; + }); } else { // here, we just need to reconstruct the array of objects // take the x accessor and y accessor.