Merge branch 'master' of https://github.com/novus/nvd3 into development

Conflicts:
	nv.d3.min.js
master
Tyler Wolf 11 years ago
commit a437d1ef0e

@ -55,7 +55,7 @@ console.log('td',test_data);
var negative_test_data = new d3.range(0,3).map(function(d,i) { return {
key: 'Stream' + i,
values: new d3.range(0,10).map( function(f,j) {
values: new d3.range(0,11).map( function(f,j) {
return {
y: 10 + Math.random()*100 * (Math.floor(Math.random()*100)%2 ? 1 : -1),
x: j
@ -72,9 +72,11 @@ nv.addGraph(function() {
chart.multibar
.hideable(true);
chart.reduceXTicks(false).staggerLabels(true);
chart.xAxis
.showMaxMin(true)
.tickFormat(d3.format(',f'));
.showMaxMin(true);
// .tickFormat(d3.format(',f'));
chart.yAxis
.tickFormat(d3.format(',.1f'));

@ -3759,7 +3759,7 @@ nv.models.line = function() {
.size(16) // default size
.sizeDomain([16,256]) //set to speed up calculation, needs to be unset if there is a custom size accessor
;
//============================================================
@ -6518,13 +6518,14 @@ nv.models.multiBarChart = function() {
, controls = nv.models.legend()
;
var margin = {top: 30, right: 20, bottom: 30, left: 60}
var margin = {top: 30, right: 20, bottom: 50, left: 60}
, width = null
, height = null
, color = nv.utils.defaultColor()
, showControls = true
, showLegend = true
, reduceXTicks = true // if false a tick will show for every data point
, staggerLabels = false
, rotateLabels = 0
, tooltips = true
, tooltip = function(key, x, y, e, graph) {
@ -6739,6 +6740,27 @@ nv.models.multiBarChart = function() {
.selectAll('line, text')
.style('opacity', 1)
if (staggerLabels) {
var getTranslate = function(x,y) {
return "translate(" + x + "," + y + ")";
};
var staggerUp = 5, staggerDown = 17; //pixels to stagger by
// Issue #140
xTicks
.selectAll("text")
.attr('transform', function(d,i,j) {
return getTranslate(0, (j % 2 == 0 ? staggerUp : staggerDown));
});
var totalInBetweenTicks = d3.selectAll(".nv-x.nv-axis .nv-wrap g g text")[0].length;
g.selectAll(".nv-x.nv-axis .nv-axisMaxMin text")
.attr("transform", function(d,i) {
return getTranslate(0, (i === 0 || totalInBetweenTicks % 2 !== 0) ? staggerDown : staggerUp);
});
}
if (reduceXTicks)
xTicks
.filter(function(d,i) {
@ -6928,6 +6950,12 @@ nv.models.multiBarChart = function() {
return chart;
}
chart.staggerLabels = function(_) {
if (!arguments.length) return staggerLabels;
staggerLabels = _;
return chart;
};
chart.tooltip = function(_) {
if (!arguments.length) return tooltip;
tooltip = _;
@ -9484,8 +9512,8 @@ nv.models.scatter = function() {
return group.values
.map(function(point, pointIndex) {
// *Adding noise to make duplicates very unlikely
// **Injecting series and point index for reference
/*[SUPPORT-706] adding a 'jitter' to the points, because there's an issue in d3.geom.voronoi.
// *Injecting series and point index for reference
/* *Adding a 'jitter' to the points, because there's an issue in d3.geom.voronoi.
*/
var pX = getX(point,pointIndex) + Math.random() * 1e-10;
var pY = getY(point,pointIndex) + Math.random() * 1e-10;

8
nv.d3.min.js vendored

File diff suppressed because one or more lines are too long

@ -26,7 +26,7 @@ nv.models.line = function() {
.size(16) // default size
.sizeDomain([16,256]) //set to speed up calculation, needs to be unset if there is a custom size accessor
;
//============================================================

@ -12,13 +12,14 @@ nv.models.multiBarChart = function() {
, controls = nv.models.legend()
;
var margin = {top: 30, right: 20, bottom: 30, left: 60}
var margin = {top: 30, right: 20, bottom: 50, left: 60}
, width = null
, height = null
, color = nv.utils.defaultColor()
, showControls = true
, showLegend = true
, reduceXTicks = true // if false a tick will show for every data point
, staggerLabels = false
, rotateLabels = 0
, tooltips = true
, tooltip = function(key, x, y, e, graph) {
@ -233,6 +234,27 @@ nv.models.multiBarChart = function() {
.selectAll('line, text')
.style('opacity', 1)
if (staggerLabels) {
var getTranslate = function(x,y) {
return "translate(" + x + "," + y + ")";
};
var staggerUp = 5, staggerDown = 17; //pixels to stagger by
// Issue #140
xTicks
.selectAll("text")
.attr('transform', function(d,i,j) {
return getTranslate(0, (j % 2 == 0 ? staggerUp : staggerDown));
});
var totalInBetweenTicks = d3.selectAll(".nv-x.nv-axis .nv-wrap g g text")[0].length;
g.selectAll(".nv-x.nv-axis .nv-axisMaxMin text")
.attr("transform", function(d,i) {
return getTranslate(0, (i === 0 || totalInBetweenTicks % 2 !== 0) ? staggerDown : staggerUp);
});
}
if (reduceXTicks)
xTicks
.filter(function(d,i) {
@ -422,6 +444,12 @@ nv.models.multiBarChart = function() {
return chart;
}
chart.staggerLabels = function(_) {
if (!arguments.length) return staggerLabels;
staggerLabels = _;
return chart;
};
chart.tooltip = function(_) {
if (!arguments.length) return tooltip;
tooltip = _;

@ -160,8 +160,8 @@ nv.models.scatter = function() {
return group.values
.map(function(point, pointIndex) {
// *Adding noise to make duplicates very unlikely
// **Injecting series and point index for reference
/*[SUPPORT-706] adding a 'jitter' to the points, because there's an issue in d3.geom.voronoi.
// *Injecting series and point index for reference
/* *Adding a 'jitter' to the points, because there's an issue in d3.geom.voronoi.
*/
var pX = getX(point,pointIndex) + Math.random() * 1e-10;
var pY = getY(point,pointIndex) + Math.random() * 1e-10;

Loading…
Cancel
Save