Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
almossawi committed Jul 28, 2016
1 parent e63667a commit ef4d6e1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
20 changes: 8 additions & 12 deletions examples/charts/experimental.htm
Expand Up @@ -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);
}
});

Expand Down Expand Up @@ -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);
}
});

Expand All @@ -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);
}
});

Expand All @@ -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);
}
});

Expand Down Expand Up @@ -744,15 +744,14 @@
chart_type: 'histogram',
width: 295,
height: 180,
right: 10,
bins: 50,
bar_margin: 0,
target: '#histogram1',
y_extended_ticks: true,
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);
}
});

Expand Down Expand Up @@ -795,15 +794,14 @@
chart_type: 'histogram',
width: 295,
height: 180,
right: 10,
target: '#histogram2',
y_extended_ticks: true,
x_accessor: 'value',
y_accessor: 'count',
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);
}
});

Expand All @@ -817,15 +815,14 @@
chart_type: 'histogram',
width: 295,
height: 180,
right: 10,
target: '#histogram3',
linked: true,
y_extended_ticks: true,
x_accessor: 'val1',
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);
}
});

Expand All @@ -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);
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/js/common/x_axis.js
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/js/common/y_axis.js
Expand Up @@ -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) {
Expand Down
9 changes: 5 additions & 4 deletions src/js/misc/process.js
Expand Up @@ -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.
Expand Down

0 comments on commit ef4d6e1

Please sign in to comment.