var myArrY = new Array (); // original values
// TODO: fill its values as before . . .
var myArrY_steps = new Array(0, 10, 20, 30); // the steps I want to mark
var myData = new Array ();
myData[0] = myArrY;
myData[1] = myArrY_steps;
var chart = r.barchart(10, 10, 600, 300, myData, 0, {type: "sharp"});
. . .
var x = 10;
var y;
for (i = 0; i < myArrY_steps.length; i++) {
// Note: In this loop I use chart.bars[1], the steps array!
y = chart.bars[1][i].y; // calculated by gRaphael !
r.text(x, y, chart.bars[1][i].value).attr(txtAttr);
}
and for the Y-axis, I added another bar, with the steps I want to mark. I guess you can set its color to "transparent".
var myArrY = new Array (); // original values
// TODO: fill its values as before . . .
var myArrY_steps = new Array(0, 10, 20, 30); // the steps I want to mark
var myData = new Array ();
myData[0] = myArrY;
myData[1] = myArrY_steps;
var chart = r.barchart(10, 10, 600, 300, myData, 0, {type: "sharp"});
. . .
var x = 10;
var y;
for (i = 0; i < myArrY_steps.length; i++) {
// Note: In this loop I use chart.bars[1], the steps array!
y = chart.bars[1][i].y; // calculated by gRaphael !
r.text(x, y, chart.bars[1][i].value).attr(txtAttr);
}
发布评论
评论(4)
您也可以使用 axis 类来实现此目的:
You could work with the axis class as well for this :
[我知道这个问题很旧,但这是我的解决方案 -]
我没有设法使用 rgaxis,但我使用了 aX -
[I am aware that this question is old, but here is my solution -]
I did not manage to use the r.g.axis, but I used the aX -
我在此示例中看到了一些轴,尽管没有标签。我认为您可以使用 Raphael 函数 text() 将文本添加到所需位置。
I see some axis although without labels in this example. I think you can add text to a desired position using Raphael function text().
对于 Y 轴,我添加了另一个栏,其中包含我要标记的步骤。
我想你可以将其颜色设置为“透明”。
and for the Y-axis, I added another bar, with the steps I want to mark.
I guess you can set its color to "transparent".