php - Displaying dates in Flot from timestamps -


i trying graph display dates on x axis instead of timestamps. i've searched , read other posts , still can't budge. here's code:

for($i = 0; $i < 3; $i++) {     $j = $i + 1;     $query = "select unix_timestamp(date_added)*1000, count(id)                     likes                     date_added between                         date_sub(curdate(), interval $j month)                         , date_sub(curdate(), interval $i month)";     $result = mysql_query($query);     echo mysql_error();     $date = mysql_result($result, 0, 0);     $count = mysql_result($result, 0, 1);     $pair = array( (string)$date, (int)$count );     array_push($data_series1, $pair); } 

    $.ajax({     url: 'graph_likes.php?get_data=month',     datatype: 'json',     success: function(returned) {         $.plot($('#container'),          [{             data: returned,             points:             {                 show: true             },             lines:             {                 show: true             },             color: '#00d6e2',             xaxis:             {                 mode: 'time'             }         }]);     } }); 

if want flot display timestamps nicely formatted, can try using timestamp format option (called timeformat):

        ...         xaxis:         {             mode: 'time',             timeformat: "%y/%m/%d"         }         ... 

you find option explained in document: http://people.iola.dk/olau/flot/api.txt , section called time series data.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -