如何在 nvd3 图例和图表之间添加间隙

How to add a gap between the nvd3 legend and the chart

本文关键字:之间 添加 间隙 nvd3      更新时间:2023-09-26

我知道这个问题以前可能被问过,当我试图得到这个问题的答案时,我还没有真正找到一个。类似于这里的小提琴: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});

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

你应该像下面这样尝试:

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

更新了你的小提琴

希望有帮助:(