我正在使用nvd3.js库及其水平图http://nvd3.org/ghpages/multiBarHorizontal.html 我试图通过以下css在栏之间添加一些边距但是不起作用。 http://jsfiddle.net/petran/x7Cdz/1/
rect {
display: inline-block;
margin-top: 25px;
margin-bottom: 5px;}
还有另一种方法可以实现吗?
答案 0 :(得分:8)
.margin({top:30,right:20,bottom:50,left:175})
答案 1 :(得分:0)
根据需要自定义图表选项。您可以为图表选项添加边距,如下所示。
$scope.options = {
chart: {
type: 'multiBarHorizontalChart',
height: 450,
margin : {
top: 20,
right: 20,
bottom: 40,
left: 55
},
x: function(d){return d.label;},
y: function(d){return d.value;},
//yErr: function(d){ return [-Math.abs(d.value * Math.random() * 0.3), Math.abs(d.value * Math.random() * 0.3)] },
showControls: true,
showValues: true,
duration: 500,
xAxis: {
showMaxMin: false
},
yAxis: {
axisLabel: 'Values',
tickFormat: function(d){
return d3.format(',.2f')(d);
}
}
}
};