【发布时间】:2014-03-17 22:48:57
【问题描述】:
我尝试以漂亮的格式化日期更新 Raphael LineChart 的 Unix 时间戳,但我收到错误 Uncaught TypeError: Object 0 has no method 'attr'
我使用的代码如下:
var progression = r.linechart(30, 0, 350, 300, x, y, options);
console.log("Progression is %O", progression.axis[0].text.items);
/* Overwrites the Axis label for display a formatted date instead of the Unix timestamp */
$(progression.axis[0].text.items).each( function ( label, index ) {
originalText = label.attr('text');
newText = 'up';
label.attr({'text': newText});
});
似乎我无法修改标签,但该属性存在,如此打印屏幕上所示... 突出显示的文本是我的 Unix 时间戳...
我试图直接修改属性,但它不可能......当我打印标签时,它只是一个字符串,而不是一个对象(?)
【问题讨论】:
-
可以加个小提琴吗?我通常更喜欢我的自定义轴标签。它可以使用 chart.eachColumn 轻松生成。在 eachColumn 中,this.y、this.x 以及 this.value 可用于将文本放置在画布上的任何位置。
标签: graphael