Highchart仅在本地主机上正确显示

时间:2020-10-13 07:03:35

标签: javascript highcharts

当我尝试将其上载到webhost时显示Uncaught SyntaxError: Unexpected token '<'错误,而在使用本地主机时显示正确,没有任何错误。我使用的php版本也与虚拟主机相同。

这是我在控制台错误中发现的 enter image description here

这是高图代码

   $(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
      }
    },]
  });
});

感谢您可以提供的任何帮助

1 个答案:

答案 0 :(得分:1)

在PHP中,joinimplode的别名。所以正确的语法是implode ( string $glue , array $pieces ) : string

答案是:

<?php echo implode(',', $arrayTanggal) ?>