mhopkins321
mhopkins321

Reputation: 3073

Chart duration of event with Flot

I'm trying to chart the duration of something using flot and having some issues. In my sql table I have two datetime columns and I am performing the below select to get the difference between them as a timestamp that works with flot (I think)

$p1Query = $db->rawQuery("SELECT AVG((synth.page2-synth.page1)) AS difference FROM (SELECT (UNIX_TIMESTAMP(pageoneloadtime))*1000 AS page1, (UNIX_TIMESTAMP(pagetwoloadtime))*1000 AS     page2 FROM usersession) synth");
$p1Average = floor($p1Query[0]['difference']);

The javascript section of my chart looks like this.

var pageTimeData = [["Page 1",<?= $p1Average ?>],["Page 2",<?= $p2Average ?>],["Page 3",<?= $p3Average ?>],["Page 4",<?= $p4Average ?>]];
$.plot("#pageTimeChart", [ pageTimeData ], {
series: {
    bars: {
        show: true,
        barWidth: 0.6,
        align: "center"
    }
},
xaxis: {
    mode: "categories",
    tickLength: 0
},
yaxis: {
    mode: "time",
    timeformat: "%M:%S",
    minTickSize:[2,"seconds"]
}
});

But I can't figure out why my chart isn't displaying any bars. I have verified that I have loaded the necessary javascript files

Upvotes: 0

Views: 82

Answers (1)

mhopkins321
mhopkins321

Reputation: 3073

I realized it was just a simple type. minTickSize:[2,"seconds"] needs to be minTickSize:[2,"second"]

Upvotes: 2

Related Questions