如何在nvd3图表中添加边距

问题描述 投票:3回答:2

我正在使用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;}

还有另一种方法可以实现吗?

svg margins nvd3.js rect
2个回答
8
投票

.margin({top:30,right:20,bottom:50,left:175})

http://nvd3.org/livecode/index.html#codemirrorNav


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);
                    }
                }
            }
        };
© www.soinside.com 2019 - 2024. All rights reserved.