我有一堆使用dc.js绘制的条形图,我想增加标签的字体大小。我认为使用renderLet函数有一个简单的解决方案,但是,我必须为每个图形执行renderLet函数,我有一堆。我想知道是否有办法使用CSS增加标签文本大小。我提供了jsfiddle三种类型的图表。这是代码。如果您有任何想法,请告诉我。感谢。
HTML
<body>
<div id='pie'><div><h3>Pie</h3></div></div>
<div id='row'><div><h3>Row</h3></div></div>
<div id='bar'><div><h3>Bar</h3></div></div>
</body>
JS
var data = [{
Category: "A",
ID: "1"
}, {
Category: "A",
ID: "1"
}, {
Category: "A",
ID: "1"
}, {
Category: "A",
ID: "2"
}, {
Category: "A",
ID: "2"
}, {
Category: "B",
ID: "1"
}, {
Category: "B",
ID: "1"
}, {
Category: "B",
ID: "1"
}, {
Category: "B",
ID: "2"
}, {
Category: "B",
ID: "3"
}, {
Category: "B",
ID: "3"
}, {
Category: "B",
ID: "3"
}, {
Category: "B",
ID: "4"
}, {
Category: "C",
ID: "1"
}, {
Category: "C",
ID: "2"
}, {
Category: "C",
ID: "3"
}, {
Category: "C",
ID: "4"
}, {
Category: "C",
ID: "4"
}, {
Category: "C",
ID: "5"
}];
var ndx = crossfilter(data);
var XDimension = ndx.dimension(function (d) {
return d.Category;
});
var YDimension = XDimension.group();
dc.pieChart("#pie")
.width(200).height(200)
.dimension(XDimension)
.group(YDimension)
.label(function (d) {
return d.data.key + ' ' + Math.round((d.endAngle - d.startAngle) / Math.PI * 50) + '%';
});
dc.rowChart("#row")
.width(400).height(150)
.dimension(XDimension)
.group(YDimension)
.label(function (d) {return d.key + " " + d.value;})
dc.barChart("#bar")
.width(400).height(150)
.dimension(XDimension)
.group(YDimension)
.x(d3.scale.ordinal().domain(["A","B","C"]))
.xUnits(dc.units.ordinal)
dc.renderAll();
答案 0 :(得分:1)