【问题标题】:How to add a gap between the nvd3 legend and the chart如何在nvd3图例和图表之间添加间隙
【发布时间】:2014-12-18 18:18:52
【问题描述】:

我知道以前可能有人问过这个问题,当我试图寻找这个问题的答案时,我还没有真正找到答案。类似于这里的小提琴:http://jsfiddle.net/rdesai/vfe2B/51/,我试图通过这样做来增加图例和图表之间的差距:

  graph.select(".nv-wrap.nv-legendWrap nv-legend nv-series").attr("transform", "translate(100,75)").style('padding','200px');
  graph.select(".nv-wrap.nv-lineChart").attr("transform", "translate(100,75)");

使用这种方法,我可以移动图表的位置,但是当我单击其中一个图例(打开/关闭圆圈)时,图表会回到其原始位置。我也试过了:

chart = nv.models.lineChart().options({
                width: 1050
            }).margin({top: 0, right:30, left:80, bottom: 150});

但没有运气......关于如何解决这个问题的任何想法?谢谢!

【问题讨论】:

    标签: javascript jquery nvd3.js


    【解决方案1】:

    你应该尝试如下:

    chart = nv.models.lineChart()
    chart.legend.margin({top: 0, right:30, left:80, bottom: 150});
    

    Updated your fiddle

    希望对你有帮助:)

    【讨论】: