使用jsreport和时间戳绘制flot图表中的x轴

3

我现在正在尝试利用jsreport生成一个简单的PDF报告,其中包含一段时间内bpsIn的图形。目前的数据是静态的,但我遇到了几个问题:

(1) 当我尝试利用moment.js格式化数据时,moment.unix({{this.[1]}}*1000)似乎运行良好,但是,当你在末尾添加.format("YYYY-MM-DD")将时代时间格式化为可读的人类内容时,图表中的内容消失了。

我在jsreport的playground上设置了一个游乐场版本,展示了具有时代时间戳的柱状图工作情况。请注意,它们完全无法阅读..

将其转换为折线图很简单。我还尝试替换flot中xasis的mode: "categories"以使用时间,如下所示:

xaxis: { 
   mode: "time",
   minTickSize: [15, "minute"],
   min: (new Date(data.points[0][1])).getTime(),
   max: (new Date(data.points[0][29])).getTime(),
   timeformat: "%y/%m/%d"
},
"lines": {"show": "true"},
"points": {"show": "true"},
clickable:true, hoverable: true

使用适当的附加包括://cdnjs.cloudflare.com/ajax/libs/flot/0.8.3/jquery.flot.min.js//cdnjs.cloudflare.com/ajax/libs/flot/0.8.3/jquery.flot.categories.min.js//cdnjs.cloudflare.com/ajax/libs/flot/0.8.3/jquery.flot.time.min.js//cdnjs.cloudflare.com/ajax/libs/flot/0.8.3/jquery.flot.symbol.min.js
最终目标是生成一个报告,其中x轴显示人类可读的日期,但实际上这些日期是15分钟为一段的增量,因为此数据目前来自InfluxDB作为一些测试数据。

另外,从flot文档中我意识到它需要x轴的时刻(UTC)时间,这很好。我只想使用timeformat来读取它们。 - shat
1个回答

0

实际上,当我在问题上添加有关flot希望使用UTC时间的评论时,我最终回答了自己的问题(扇耳光)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接