javascript - Dc.js - 具有动态高度的行图

标签 javascript d3.js dc.js

我用 Dc.js 创建了一个行图。我有动态数据,所以我每次都有多种数据。现在,我的问题是我的行图的高度是静态的,并且 Svg 已压缩并且不清楚:

rowChart = dc.rowChart('#rowChart');

rowChart 
 .width(300)
 .height(300)
 .margins({ top: 20, left: 10, right: 10, bottom: 20 })
 .group(barChartDimensionGroup)
 .dimension(barChartDimension)
 ...

我有一个错误:

Error: Invalid negative value for attribute height="-4.894322420223788"

最佳答案

我通过@gordon找到了解决方案:

 rowChart = dc.rowChart('#rowChart');
 var heightRowChart=0;
 heightRowChart = rowChartDimensionGroup.all().length;

 tmpRowChart /* dc.rowChart('#day-of-week-chart', 'chartGroup') */
 .width(300)
 .height(heightRowChart*30)
 ...

关于javascript - Dc.js - 具有动态高度的行图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33141812/

相关文章:

javascript - 在 "close"单击时禁用 Bootstrap 中的折叠动画

d3.js - d3 v4 scaleBand滴答声

javascript - 使用 ViewBox 根据窗口大小调整 svg 的大小

javascript - 如何在模态打开时隐藏弹出窗口

javascript - 使用 Javascript 扩展表单

javascript - 加载 asset javascripts 下的所有 javascripts 好不好

javascript - 拟合 D3 图表的数据以创建图例

javascript - dc.js/d3.js - 每个类别组的最小/最大值

javascript - DC.js lineChart 上序数比例的原始排序

d3.js - 在 dc.js + labelColors 中向饼图切片添加边框