Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.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
如何使用php绘制google散点图_Php_Decimal_Plot_Google Visualization - Fatal编程技术网

如何使用php绘制google散点图

如何使用php绘制google散点图,php,decimal,plot,google-visualization,Php,Decimal,Plot,Google Visualization,我一直在尝试用谷歌api在散点图上绘制这些。但它似乎不起作用 我有100个这样的条目,代表比特币的价值 我想以一种在纵轴上标出价格,在横轴上标出序号的方式来绘制它。体积将定义圆的直径 <html> <head> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"&

我一直在尝试用谷歌api在散点图上绘制这些。但它似乎不起作用

我有100个这样的条目,代表比特币的价值

我想以一种在纵轴上标出价格,在横轴上标出序号的方式来绘制它。体积将定义圆的直径

<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = new google.visualization.DataTable();
        data.addColumn('number', 'Transactions');
        data.addColumn('number', 'Price');
        data.addRows(6);
        data.setValue(1, 0.632, 10.26);
        data.setValue(2, 0.631, 10);
        data.setValue(3,0.631, 20);
        data.setValue(4, 0.631, 4.65);



        var chart = new google.visualization.ScatterChart(document.getElementById('chart_div'));
        chart.draw(data, {width: 400, height: 240,
                          title: 'Bitcoins Transaction Prices',
                          hAxis: {title: 'Transactions', minValue: 1, maxValue: 100},
                          vAxis: {title: 'Price', minValue: 0, maxValue: 5},
                          legend: 'none'
                         });
      }
    </script>
  </head>

  <body>
    <div id="chart_div"></div>
  </body>
</html>

load(“可视化”、“1”、{packages:[“corechart”]});
setOnLoadCallback(drawChart);
函数绘图图(){
var data=new google.visualization.DataTable();
data.addColumn('number','Transactions');
data.addColumn(“数字”、“价格”);
数据。添加行(6);
数据设定值(1,0.632,10.26);
数据设定值(2,0.631,10);
数据设定值(3,0.631,20);
数据设定值(4,0.631,4.65);
var chart=new google.visualization.ScatterChart(document.getElementById('chart_div'));
绘制图表(数据,{宽度:400,高度:240,
标题:“比特币交易价格”,
hAxis:{title:'Transactions',minValue:1,maxValue:100},
变量:{title:'Price',minValue:0,maxValue:5},
图例:“无”
});
}
这将为我返回一个空白页。可能出什么问题了?我要以身作则。 下面给出了获取这些值的php代码

<?php
//get the unix time stamp of day 30 days back from today
$last_thirty = strtotime('-30 days'); 
//get the unix time stamp of day 1 month back from today
$last_month = strtotime("-1 month"); 
//get the data using bitcoinchart http api
$json = file_get_contents('http://bitcoincharts.com/t/lasttrades.json?limit=10&since=' . $last_month);
//decode json to php array
$data = json_decode($json);
$no = 1;
//loop through it
foreach ($data as $item) {
    $sn =  "S.No:".$no . "";
    $price = "Price:{$item->price}";
    $volume = "Volume:{$item->volume}";
    $no++;
    echo $sn . "<br/>";
    echo $price . "<br/>";
    echo $volume . "<br/>";

} ?>

可以在此处找到完整的文档。

<?php
//get the unix time stamp of day 30 days back from today
$last_thirty = strtotime('-30 days'); 
//get the unix time stamp of day 1 month back from today
$last_month = strtotime("-1 month"); 
//get the data using bitcoinchart http api
$json = file_get_contents('http://bitcoincharts.com/t/lasttrades.json?limit=10&since=' . $last_month);
//decode json to php array
$data = json_decode($json);
$no = 1;
//loop through it
foreach ($data as $item) {
    $sn =  "S.No:".$no . "";
    $price = "Price:{$item->price}";
    $volume = "Volume:{$item->volume}";
    $no++;
    echo $sn . "<br/>";
    echo $price . "<br/>";
    echo $volume . "<br/>";

} ?>