2016-11-03 58 views
1

我创建了一个图表,其中的传说正在重叠。我尝试增加gap()的值。 但它只适用于传奇处于垂直模式。 我对图表使用了下面的代码。请帮助我移动这些传说,以免它们重叠。 当前分析是图表的名称。如何增加横向格式的图例之间的差距?

currentanalysis 


.width(280) 
.height(190) 
.dimension(currentanalysisdimension) 
.group(Incoming2) 
.group(Outgoing2) 
.elasticY(true) 
.yAxisPadding(1) 
.x(d3.scale.ordinal().domain(["2","3","4","5"])) 
.xUnits(dc.units.ordinal) 
.legend(dc.legend().x(0).horizontal(true).y(170).itemHeight(20).gap(0)) 
.compose([ 
    dc.lineChart(currentanalysis) 
      .dimension(currentanalysisdimension) 
      .colors('blue') 
      .group(Incoming2, "Incoming/Download") 
      .dashStyle([10,0]) 
      .renderDataPoints({radius: 4, fillOpacity: 0.8, strokeOpacity: 0.8}), 

    dc.lineChart(currentanalysis) 
      .dimension(currentanalysisdimension) 
      .colors('orange') 
      .group(Outgoing2, "Outgoing/Upload") 
      .dashStyle([10,0]) 
      .renderDataPoints({radius: 4, fillOpacity: 0.8, strokeOpacity: 0.8}), 

     ]) 


    .renderlet(function (chart) { 
        chart.selectAll("g._3").attr("transform", "translate(" + 15 + ", 0)"); 
        chart.selectAll("g._2").attr("transform", "translate(" + 15 + ", 0)"); 
       }) 
.render() 
}); 

我得到的结果为:

enter image description here

回答

1

使用下面的一段代码。这将工作。

.legend(dc.legend() .x(10).y(195).itemWidth(120).horizontal(true)) 
+1

工作,非常感谢你 –