Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database 将值从db传递到jqplot_Database_Jqplot - Fatal编程技术网

Database 将值从db传递到jqplot

Database 将值从db传递到jqplot,database,jqplot,Database,Jqplot,下面是我的jsp页面的一部分,它按照 var line1 = [['2013-07-02 18:34:22',27], ['2013-07-02 18:34:52',32]]; 使用日期轴渲染器,并按预期工作,现在这里的值是硬编码的 <script type="text/javascript"> $(document).ready(function(){ var line1 = [['2013-07-02 18:34:22',27], ['2013-07-02 18:3

下面是我的jsp页面的一部分,它按照

  var line1 = [['2013-07-02 18:34:22',27], ['2013-07-02 18:34:52',32]]; 
使用日期轴渲染器,并按预期工作,现在这里的值是硬编码的

<script type="text/javascript"> 
$(document).ready(function(){
  var line1 = [['2013-07-02 18:34:22',27], ['2013-07-02 18:34:52',32]]; 
  var plot3 = $.jqplot('chart', [line1], {
      title:'VITALS CHART-TEMPERATURE', 
      axesDefaults: {
            labelRenderer: $.jqplot.CanvasAxisLabelRenderer
          },
      axes:{
        xaxis:{
          renderer:$.jqplot.DateAxisRenderer,
          label:'TIME',
          tickOptions:{formatString:'%d/%m/%y\n%I:%M:%S %p'},
          tickInterval:'30 second'
        },

       yaxis:{
             label: 'TEMPERATURE'
           }

      },
      series:[{lineWidth:4,markerOptions:{style:'square'}}]
  });
});
</script>
<body>
<center> 
<div id="chart" style="height:500px; width:500px;"></div>
</center>
</body>
</html>
并将其作为id为data的隐藏文本字段的值传递,然后将line1的值更改为

   var line1 = document.getElementByID("data");
但现在我看到绘图消失了…从db中获取这些值并绘图的最简单方法是什么

在rails中,我在控制器中使用并定义了它,如下所示:

@testarray = []
Model.find_all.each do |ph|
  @testarray << [ph.created_at.to_formatted_s(:short), ph.value.to_f]
end
gon.array = @testarray 
[["10 Dec 14:10", 61.0],["10 Dec 13:38", 0.0],["11 Dec 10:08", 0.0],["11 Dec 10:06", 0.0],["10 Dec 14:12", 91369.0],["11 Dec 11:45", 31004.0]]
现在在我的jsp上,我刚刚替换了

var line1 = [['2013-07-02 18:34:22',27], ['2013-07-02 18:34:52',32]]; 

var line1 = [['2013-07-02 18:34:22',27], ['2013-07-02 18:34:52',32]]; 
var line1=gon.array