Question

I am trying to get time from postgresql database to Highstock series, so in my series I put that code :

series: [{
    name: "DNS hits",
    data: [
    <%
    @HighStock_result.each{ |row|
    %>
    [Date.UTC(<%= row["query_time"] %>)],
    <%}%>
    ],
}]

in my database I have column query_time type timestamp without time zone, the format of time is like this :

2014-04-30 11:01:55
2014-04-30 11:01:56
2014-04-30 11:01:56
2014-04-30 11:01:57

So when run this I have a javascript error :

Horodatage : 05/05/2014 11:28:53
Erreur : SyntaxError: missing ) after argument list
Fichier Source : http://192.168.111.136:3000/assets/js/lib/all-concat.js?body=1
Ligne : 1909, Colonne : 25
Code Source :
[Date.UTC(2014-04-30 11:01:55)],

any suggestions would be greatly appreciated. Thank you in advance.

Was it helpful?

Solution 2

series: [
    {
        name : 'dns hits',
        data: ([
            <% @HighStock_result.each{ |row| %>
            [Date.UTC(<%=row['qt']%>),<%=row['hits']%>],
            <%}%>
        ])
    }
]

OTHER TIPS

You need tranform the data. Try to separate the seconds, days, etc with substr. Example:

$datatime = mktime($hour, $minute, $sencond, $month, $day, $year)*1000

More info for mktime here

Yesterday i used it for create a highstock, i hope help you :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top