如何在 dojox 柱形图中显示柱上方的值(仅适用于高度 > 0 的柱)
How to show values above bars in a dojox columns chart (ONLY FOR BARS with height > 0)
在这个 link 中,我找到了一种显示柱值的方法。
How to show values above bars in a dojox columns chart
遗憾的是,一排零困扰着图表。我只想在大于 0 时才在条形图上方显示值。
从图形上看,这是 dojo 所做的:
|
| 3
| _
| 1 | |
y-axis | _ | |
| 0 0 | | 0 0 | |
----------------------------
0 1 2 3 4 5 6
x-axis
这就是我想要做的:
|
| 3
| _
| 1 | |
y-axis | _ | |
| | | | |
----------------------------
0 1 2 3 4 5 6
x-axis
或者,我可以使用任何其他免费的 js 库吗?我不是特别喜欢dojo
谢谢
您必须为此修补 dojo 代码:
(function() {
var origCreateLabel =dojox.charting.plot2d.Columns.prototype.createLabel;
dojox.charting.plot2d.Columns.prototype.createLabel = function(group, value, bbox, theme) {
if(isNaN(value)){
origCreateLabel.apply(this,arguments);
}else if(value > 0){
origCreateLabel.apply(this,arguments);
}
};
})();
在这个 link 中,我找到了一种显示柱值的方法。 How to show values above bars in a dojox columns chart
遗憾的是,一排零困扰着图表。我只想在大于 0 时才在条形图上方显示值。
从图形上看,这是 dojo 所做的:
|
| 3
| _
| 1 | |
y-axis | _ | |
| 0 0 | | 0 0 | |
----------------------------
0 1 2 3 4 5 6
x-axis
这就是我想要做的:
|
| 3
| _
| 1 | |
y-axis | _ | |
| | | | |
----------------------------
0 1 2 3 4 5 6
x-axis
或者,我可以使用任何其他免费的 js 库吗?我不是特别喜欢dojo
谢谢
您必须为此修补 dojo 代码:
(function() {
var origCreateLabel =dojox.charting.plot2d.Columns.prototype.createLabel;
dojox.charting.plot2d.Columns.prototype.createLabel = function(group, value, bbox, theme) {
if(isNaN(value)){
origCreateLabel.apply(this,arguments);
}else if(value > 0){
origCreateLabel.apply(this,arguments);
}
};
})();