d3.js x轴长度太短

时间:2017-07-07 18:26:35

标签: javascript d3.js

这是我的剧本:

minimum = []      # creates empty list for all possible minimum keys
def min(dict):    # defines a function called minimum taking a argument dict
    m= min(dict.values())     # stating minimum value in dict
    for key, values in dict.items():     # iterating through key and values in items of dictionary
        if value == m:        # checking if value is minimum
            minimum.append(key)      # appending minimum values to the empty list created
    return minimum         # returning the list

有没有办法将x轴稍微延伸,以便接触y轴? 我尝试使用某些值,但它会改变图表其余部分的内容,这是我不想要的。

enter image description here

1 个答案:

答案 0 :(得分:0)

我认为你已经强迫它在代码的这一部分翻译X中的20个像素:

svg.append("g")
    .attr("class", "x axis")
    .attr("transform", "translate(20," + height + ")") /* <-- here! make it 0 , height */
    .call(xAxis);