gpt4 book ai didi

javascript - NVD3 强制条形图中条形的特定宽度

转载 作者:数据小太阳 更新时间:2023-10-29 05:46:48 24 4
gpt4 key购买 nike

我正在尝试在 nvd3 离散条形图上设置特定的宽度值。我可以在初始渲染后更改矩形元素,但似乎有某种方法可以在图表设置中指定条形宽度。

这是我当前的图表设置。

nv.addGraph ->
chart = nv.models.discreteBarChart()
.x (d) ->
return d.label
.y (d) ->
return d.value
.staggerLabels(false).showValues(false)
.color(['#56bd78']).tooltips(false)
.margin({top: 0, right: 0, bottom: 30, left: 0})

chart.tooltipContent (key, x, y, e, graph) ->
return '<h3><span>' + parseFloat(y) + '</span><em>' +
key + '</em></h3>'

chart.xAxis.tickFormat (d) ->
return d3.time.format('%b')(new Date('2013/'+d+'/01'))
# chart.xAxis.tickPadding({top: 0, bottom: 0, left: 20, right:30})

d3.select(element).datum(data).transition().duration(500).call(chart)

nv.utils.windowResize(chart.update)
return chart

我假设因为我找不到关于这个特定问题的任何已发布问题,它可能很简单我错过了它。提前致谢。

最佳答案

尝试 chart.groupSpacing(0.5) 并相应地更改值以查看它是否解决了问题。

关于javascript - NVD3 强制条形图中条形的特定宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17617432/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com