Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.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
Javascript 在自定义模板Wordpress中绘制Highcharts.com图表_Javascript_Php_Jquery_Wordpress_Highcharts - Fatal编程技术网

Javascript 在自定义模板Wordpress中绘制Highcharts.com图表

Javascript 在自定义模板Wordpress中绘制Highcharts.com图表,javascript,php,jquery,wordpress,highcharts,Javascript,Php,Jquery,Wordpress,Highcharts,我试图独自解决那个问题,但似乎我还不够好;-) 所以我把它编码了,在这里所有的东西都工作了: 然后我把它放在我wordpress网站上的一个页面模板中(使用Jannah主题),一切正常,但不是图表 因此,我在我的function.php中添加了我的主题,但不是更好: add_action('wp_enqueue_scripts','Load_Chart_Script'); function Load_Chart_Script(){ if ( is_page_template('p

我试图独自解决那个问题,但似乎我还不够好;-)

所以我把它编码了,在这里所有的东西都工作了:

然后我把它放在我wordpress网站上的一个页面模板中(使用Jannah主题),一切正常,但不是图表

因此,我在我的function.php中添加了我的主题,但不是更好:

    add_action('wp_enqueue_scripts','Load_Chart_Script');
function Load_Chart_Script(){
    if ( is_page_template('page-conditions.php') ) {
        wp_enqueue_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js');
        wp_enqueue_script('highstock', 'https://code.highcharts.com/stock/highstock.js');
        wp_enqueue_script('exporting', 'https://code.highcharts.com/stock/modules/exporting.js');
        wp_enqueue_script('export-data', 'https://code.highcharts.com/stock/modules/export-data.js');
    } 
}
下面是我的代码的一部分,我是如何从Json数据生成它的

    $datetimeParis = new DateTime("$now", new DateTimeZone("Europe/Paris"));
        $decalage = intval($datetimeParis->getOffset())/3600;
        $surl = "https://api.solunar.org/solunar/".$_SESSION["latitude"].",".$_SESSION["longitude"].",".$datetime->format('Ymd').",".$decalage;
        $sraw = file_get_contents($surl);
        $sjson = json_decode($sraw,true);

        echo "
            <script language=\"JavaScript\" type=\"text/javascript\">
                (function() {
                      $('#graph$i').highcharts({
                        title: '',
                        xAxis: {
                          type: 'datetime'
                        },
                        series: [{
                          name: 'Indice solunaire',
                          data: [
                            [new Date('".$datetime->format('Y-m-d')." 01:00:00').getTime(), ".$sjson["hourlyRating"][0]."],
                            [new Date('".$datetime->format('Y-m-d')." 02:00:00').getTime(), ".$sjson["hourlyRating"][1]."],
                            [new Date('".$datetime->format('Y-m-d')." 03:00:00').getTime(), ".$sjson["hourlyRating"][2]."],
                            [new Date('".$datetime->format('Y-m-d')." 04:00:00').getTime(), ".$sjson["hourlyRating"][3]."],
                            [new Date('".$datetime->format('Y-m-d')." 05:00:00').getTime(), ".$sjson["hourlyRating"][4]."],
                            [new Date('".$datetime->format('Y-m-d')." 06:00:00').getTime(), ".$sjson["hourlyRating"][5]."],
                            [new Date('".$datetime->format('Y-m-d')." 07:00:00').getTime(), ".$sjson["hourlyRating"][6]."],
                            [new Date('".$datetime->format('Y-m-d')." 08:00:00').getTime(), ".$sjson["hourlyRating"][7]."],
                            [new Date('".$datetime->format('Y-m-d')." 09:00:00').getTime(), ".$sjson["hourlyRating"][8]."],
                            [new Date('".$datetime->format('Y-m-d')." 10:00:00').getTime(), ".$sjson["hourlyRating"][9]."],
                            [new Date('".$datetime->format('Y-m-d')." 11:00:00').getTime(), ".$sjson["hourlyRating"][10]."],
                            [new Date('".$datetime->format('Y-m-d')." 12:00:00').getTime(), ".$sjson["hourlyRating"][11]."],
                            [new Date('".$datetime->format('Y-m-d')." 13:00:00').getTime(), ".$sjson["hourlyRating"][12]."],
                            [new Date('".$datetime->format('Y-m-d')." 14:00:00').getTime(), ".$sjson["hourlyRating"][13]."],
                            [new Date('".$datetime->format('Y-m-d')." 15:00:00').getTime(), ".$sjson["hourlyRating"][14]."],
                            [new Date('".$datetime->format('Y-m-d')." 16:00:00').getTime(), ".$sjson["hourlyRating"][15]."],
                            [new Date('".$datetime->format('Y-m-d')." 17:00:00').getTime(), ".$sjson["hourlyRating"][16]."],
                            [new Date('".$datetime->format('Y-m-d')." 18:00:00').getTime(), ".$sjson["hourlyRating"][17]."],
                            [new Date('".$datetime->format('Y-m-d')." 19:00:00').getTime(), ".$sjson["hourlyRating"][18]."],
                            [new Date('".$datetime->format('Y-m-d')." 20:00:00').getTime(), ".$sjson["hourlyRating"][19]."],
                            [new Date('".$datetime->format('Y-m-d')." 21:00:00').getTime(), ".$sjson["hourlyRating"][20]."],
                            [new Date('".$datetime->format('Y-m-d')." 22:00:00').getTime(), ".$sjson["hourlyRating"][21]."],
                            [new Date('".$datetime->format('Y-m-d')." 23:00:00').getTime(), ".$sjson["hourlyRating"][22]."],
                            [new Date('".$datetime->format('Y-m-d')." 24:00:00').getTime(), ".$sjson["hourlyRating"][23]."],
                            ]
                        }]
                      });
                    });
            </script>
                ";
    
        echo "<div id=\"graph".$i."\" style=\"min-width: 100px; height: 200px; margin: 0 auto\"></div>";
$datetimeParis=newdatetime($now),newdatetimezone(“欧洲/巴黎”);
$detage=intval($datetimeParis->getOffset())/3600;
$surl=”https://api.solunar.org/solunar/“$会话[“纬度”]。”、“$会话[“经度”]。”、“$日期时间->格式('Ymd')”、“$贴花;
$sraw=文件获取内容($surl);
$sjson=json_decode($sraw,true);
回声“
(功能(){
$(“#图$i”)。高图({
标题:“”,
xAxis:{
键入:“日期时间”
},
系列:[{
名称:“Indice solunaire”,
数据:[
[新日期(““$datetime->format('Y-m-d').”01:00:00').getTime(),“$sjson[“hourlyRating”][0]”,
[新日期(““$datetime->format('Y-m-d').”02:00:00').getTime(),“$sjson[“hourlyRating”][1]”,
[新日期(““$datetime->format('Y-m-d').”03:00:00').getTime(),“$sjson[“hourlyRating”][2]”,
[新日期(““$datetime->format('Y-m-d').”04:00:00').getTime(),“$sjson[“hourlyRating”][3]”,
[新日期(““$datetime->format('Y-m-d').”05:00:00').getTime(),“$sjson[“hourlyRating”][4]”,
[新日期(““$datetime->format('Y-m-d').”06:00:00').getTime(),“$sjson[“hourlyRating”][5]”,
[新日期(““$datetime->format('Y-m-d').”07:00:00').getTime(),“$sjson[“hourlyRating”][6]”,
[新日期(““$datetime->format('Y-m-d').”08:00:00').getTime(),“$sjson[“hourlyRating”][7]”,
[新日期(““$datetime->format('Y-m-d').”09:00:00').getTime(),“$sjson[“hourlyRating”][8]”,
[新日期(““$datetime->format('Y-m-d').”10:00:00').getTime(),“$sjson[“hourlyRating”][9]”,
[新日期(““$datetime->format('Y-m-d').”11:00:00').getTime(),“$sjson[“hourlyRating”][10]”,
[新日期(““$datetime->format('Y-m-d').”12:00:00').getTime(),“$sjson[“hourlyRating”][11]”,
[新日期(““$datetime->format('Y-m-d').”13:00:00').getTime(),“$sjson[“hourlyRating”][12]”,
[新日期(““$datetime->format('Y-m-d').”14:00:00').getTime(),“$sjson[“hourlyRating”][13]”,
[新日期(““$datetime->format('Y-m-d').”15:00:00').getTime(),“$sjson[“hourlyRating”][14]”,
[新日期(““$datetime->format('Y-m-d').”16:00:00').getTime(),“$sjson[“hourlyRating”][15]”,
[新日期(““$datetime->format('Y-m-d').”17:00:00').getTime(),“$sjson[“hourlyRating”][16]”,
[新日期(““$datetime->format('Y-m-d').”18:00:00').getTime(),“$sjson[“hourlyRating”][17]”,
[新日期(““$datetime->format('Y-m-d').”19:00:00').getTime(),“$sjson[“hourlyRating”][18]”,
[new Date(““$datetime->format('Y-m-d').”20:00:00').getTime(),“$sjson[“hourlyRating”][19]”,
[新日期(““$datetime->format('Y-m-d').”21:00:00').getTime(),“$sjson[“hourlyRating”][20]”,
[新日期(““$datetime->format('Y-m-d').”22:00:00').getTime(),“$sjson[“hourlyRating”][21]”,
[新日期(““$datetime->format('Y-m-d').”23:00:00').getTime(),“$sjson[“hourlyRating”][22]”,
[新日期(““$datetime->format('Y-m-d').”24:00:00').getTime(),“$sjson[“hourlyRating”][23]”,
]
}]
});
});
";
回声“;
当我在一个jsfiddle.net示例中从HTML源复制原始数据时,它可以工作。。。我真的不明白我的错在哪里?控制台错误中没有更多信息

谢谢大家!
关于

我可以在你的网站上看到一些图表,你能准确地解释一下什么不起作用吗?