javascript - Highchart 仅在本地主机上正确显示
问题描述
当我Uncaught SyntaxError: Unexpected token '<'
尝试将其上传到 webhost 时出现错误,而当我使用 localhost 时它正确显示而没有任何错误。我使用的 php 版本也与 webhost 相同。
这是highchart代码
$(function(){
var chart = new Highcharts.Chart({
chart: {
renderTo: 'graph',
scrollablePlotArea: {minWidth: 700},
},
xAxis: {
categories: [<?php echo join($arrayTanggal, ',') ?>],
tickWidth: 0,
gridLineWidth: 1,
labels: {
align: 'left',
x: -40,
y: -3
}
},
yAxis: [{ // left y axis
title: {
text: null
},
labels: {
align: 'left',
x: 3,
y: 16,
format: '{value:.,0f}'
},
showFirstLabel: false
}, { // right y axis
linkedTo: 0,
gridLineWidth: 0,
opposite: true,
title: {
text: null
},
labels: {
align: 'right',
x: -3,
y: 16,
format: '{value:.,0f}'
},
showFirstLabel: false
}],
legend: {
align: 'left',
verticalAlign: 'top',
borderWidth: 0
},
tooltip: {
shared: true,
crosshairs: true
},
series: [{
name: 'Overall',
color: '#dc3545',
data: [<?php echo join($arrayAverage, ',') ?>],
lineWidth: 3,
marker: {
radius: 8
}
},]
});
});
感谢您提供的任何帮助
解决方案
在 PHP 中,join
是implode
. 所以正确的语法是implode ( string $glue , array $pieces ) : string
.
答案是:
<?php echo implode(',', $arrayTanggal) ?>
推荐阅读
- python - 为什么我的代码在不同的 IDE 中没有提供相同的结果
- excel - [VBA][MULTISELECT] 将多选文件复制到活动工作簿无法正常工作
- mysql - 如何解决这个 MariaDB 错误?=> 错误 1296 (HY000):从 CONNECT 收到错误 122“无法检索错误消息”
- sql-server - 在 SQL 中透视数据并将其更新到目标表中
- node.js - Google 电子表格 API v4 编辑器访问权限
- javascript - 如何在 VueJS 的 v-for 循环中定义起点
- javascript - Axios ReactJS 中无法更改状态,无法按顺序检索数据
- python - 我应该使用 pyodbc 还是 win32com 使用 python 填写 Microsoft Access 数据库 (.accdb) 中的预先存在的表格?
- python - Holoviews Sankey Diagram 指定节点和边排序
- python - 如何将 datetime.utcnow() 过滤到 flask-sqlalchemy 中的特定 date.today()