我想在图表上同时显示值和数据类别。这是一个条形图,我希望将数据值和字符串打印在条形左侧的列中:
A 1 #
B 3 ###
我尝试将两个 add(pv.Label) 调用链接到我的图表上,但它似乎什么也没做 - 第二个标签集没有添加。这甚至可以用 protovis 完成吗?有什么建议吗?
vis = new pv.Panel()
.def("j", -1)
.width(800)
.height(50)
.right(3);
vis.add(pv.Bar)
.data(wData)
.bottom(0)
.width(20)
.height(function(d) d[1] * 1.2)
.left(function() this.index * 27)
.fillStyle(function() vis.j() == this.index ? "orange" : "steelblue")
.add(pv.Label) **// does nothing!!**
.bottom(0)
.textAlign("center")
.textStyle("white")
.text(function(d) d[0] )
.event("mouseover", function() vis.j(this.index))
.event("mouseout", function() vis.j(-1))
.anchor("top").add(pv.Label)
.visible(function() vis.j() >= 0)
.textStyle("white")
.text(function(d) d[1]);
vis.render();