javascript - How to set Date Value for x Axis using gRaphael Line Graph -
i've started use graphael graphing needs , pretty impressed far. however, have run difficulty when producing line graphs, when attempt set values x axis dates, graph fails render. code generate graph is:
<script type='text/javascript' charset='utf-8'> var r = raphael('holder'); var lines = r.g.linechart(20, 20, 600, 300, [[1, 2, 3, 4, 5, 6, 7]], [['4.16','6.35','1.77','3.1','9.79','10.03','-0.3']], {nostroke: false, axis: '0 0 1 1', symbol: 'o', smooth: false}).hovercolumn(function () { this.tags = r.set(); (var = 0, ii = this.y.length; < ii; i++) { this.tags.push(r.g.tag(this.x, this.y[i], this.values[i], 160, 10).insertbefore(this).attr([{fill: '#fff'}, {fill: this.symbols[i].attr('fill')}])); } }, function () { this.tags && this.tags.remove(); }); lines.symbols.attr({r: 3}); </script> <div id='holder'></div>
how able replace x axis values '1, 2, 3, 4, 5, 6, 7' say, 'jan 2001, feb 2001, mar 2001...etc...etc....'?
many indeed, appreciated!
at first have give chart values not complain about. in case save unix timestamp etc can alter values using (using prototype etc):
lines.axis[0].text.items.each( function ( index, label ) { //get timestamp saved originaltext = label.attr('text'); newtext = 'convert timestamp date using originaltext input here'; //label.rotate(75); label.attr({'text': newtext}); });
the .each can replaced regular
for(var x = 0; x < lines.axis[0].text.length; x++)
loop if like.
Comments
Post a Comment