D3.js ValueAccessor可以';t在dc.js中的条形图上显示百分比
我无法在带有代码的条形图上显示百分比:D3.js ValueAccessor可以';t在dc.js中的条形图上显示百分比,d3.js,dc.js,crossfilter,D3.js,Dc.js,Crossfilter,我无法在带有代码的条形图上显示百分比: chart3barchart2 .width(500) .height(500) .x(d3.scale.ordinal().domain(['18-21', '22-26', '27-30', '31-35'])) .xUnits(dc.units.ordinal) .margins({top: 24, left: 0, r
chart3barchart2
.width(500)
.height(500)
.x(d3.scale.ordinal().domain(['18-21', '22-26', '27-30', '31-35']))
.xUnits(dc.units.ordinal)
.margins({top: 24, left: 0, right: 10, bottom: 20})
.colors(d3.scale.category10())
.brushOn(false)
.ordinalColors(['#FC6E4C'])
.dimension(ageDim)
.group(ageGroup)
.valueAccessor(function (d) { return parseInt((d.value.RespondCount/ntotal2.all()[0].value.RespondCount* 100).toFixed(0),10) + "%";})
.elasticY(true)
.yAxisPadding('60%')
.renderLabel(true)
.barPadding(0.2)
.outerPadding(0.6);
dc.renderAll("viz2");
有关整个代码,请参见。
每次我将“%”放在
.valueAccessor(函数(d){return parseInt((d.value.RespondCount/ntotal2.all()[0].value.RespondCount*100)。toFixed(0),10)+“%”;})
图形将完全消失,而不会在浏览器控制台中显示错误。有人有主意吗?谢谢大家! 您可能想单独使用valueAccessor()
,并使用.label()
或.title()
更改标签或工具提示。值访问器提供用于分配坐标的数值,其他值访问器提供文本。您可能希望将值访问器()
单独保留,并使用.label()
或.title()
更改标签或工具提示。值访问器提供用于分配坐标的数值,其他访问器提供文本。