【问题标题】:How to add margins in nvd3 graphs如何在 nvd3 图表中添加边距
【发布时间】:2013-06-19 15:33:19
【问题描述】:

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


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    根据需要自定义图表选项。您可以为图表选项添加边距,如下所示。

     $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);
                        }
                    }
                }
            };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-26
      • 2020-07-19
      • 1970-01-01
      • 2019-05-27
      • 2015-07-05
      • 2021-08-08
      相关资源
      最近更新 更多