0

我正在尝试使用高图表。我是高图表的新手,也是 jquery 的新手。我正在尝试将类别和系列加载到折线图中。这是我使用的代码。

<script type="text/javascript">
$(function () {
  function getData(){
      alert('fff');
      $.ajax({
    url:"high_line_data.php",
    type:"POST",    
    success:function(resp){
      chart.series[0].setData(resp);
    }
      });
    }


        chart = new Highcharts.Chart({
            chart: {
        renderTo: 'container',
                type: 'line',
                marginRight: 130,
                marginBottom: 25,
          events: {
               load: getData
          }
            },
            title: {
                text: 'Monthly Average Temperature',
                x: -20 //center
            },
            subtitle: {
                text: 'Source: WorldClimate.com',
                x: -20
            },
            xAxis: {
                categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
                    'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
            },
            yAxis: {
                title: {
                    text: 'Temperature (°C)'
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            tooltip: {
                valueSuffix: '°C'
            },
            legend: {
                layout: 'vertical',
                align: 'right',
                verticalAlign: 'top',
                x: -10,
                y: 100,
                borderWidth: 0
            },
            series: []
        });
    }); 

        </script>

和php脚本

我将系列结果呼应为

name:'Test',
Data : '1,3,4,5'

我该如何解决这个问题。请帮忙。

4

2 回答 2

0

您应该用数字替换您的字符串值。显然你可以使用 JSON 格式来添加点。

有关 PHP 预处理数据的相关文章:http: //docs.highcharts.com/#preprocessing

于 2013-04-25T09:35:22.527 回答
0

将 php 的输出从文本解析为数组。highcharts 还接受整数的直接数组作为输入来绘制数据。

希望这会有用

于 2013-04-25T09:37:00.003 回答