用Flot绘制事件的图表持续时间

我正在尝试使用flot绘制某些​​内容的持续时间并遇到一些问题。 在我的sql表中,我有两个datetime列,我正在执行下面的select来获取它们之间的区别作为一个与flot一起工作的时间戳(我认为)</ p>

  $ p1Query =  $ db-&gt; rawQuery(“SELECT AVG((synth.page2-synth.page1))AS区别FROM(SELECT(UNIX_TIMESTAMP(pageoneloadtime))* 1000 AS page1,(UNIX_TIMESTAMP(pagetwoloadtime))* 1000 AS page2 FROM usersession)  synth“); 
$ p1Average = floor($ p1Query [0] ['difference']);
</ code> </ pre>

我的图表的javascript部分如下所示。 </ p>

  var pageTimeData = [[“Page 1”,&lt;?= $ p1Average?&gt;],[“Page 2”,&lt;?= $ p2Average?&gt;  ],[“第3页”,&lt;?= $ p3Average?&gt;],[“第4页”,&lt;?= $ p4Average?&gt;]]; 
$ .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”]
}

});
</ code> </ pre>

但我无法弄清楚为什么我的图表没有显示任何条形图。 我已经验证我已经加载了必要的javascript文件</ p>
</ div>

展开原文

原文

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

1个回答



我意识到这只是一个简单的类型。 minTickSize:[2,“seconds”] </ code>需要 minTickSize:[2,“second”] </ code> </ p>
</ div>

展开原文

原文

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐