将外部csv文件上传到highcharts无法正常工作

时间:2016-08-11 07:02:59

标签: jquery csv highcharts

<!DOCTYPE html>
<html>
<head>
<title>Highcharts Data loading using CSV</title>

    <script type="text/javascript" src="jquery-3.1.0.min.js"></script>    
    <script src="js/highcharts.js"></script>
    <script src="js/modules/data.js"></script>
    <script src="js/modules/exporting.js"></script>
    <script type="text/javascript">
        $(function () {
        $.get('data.csv', function(data) {
         $('#container').highcharts({
            chart: {
                type: "line"
            },
            title: {
                text: "Fruit Consumtion"
            },
            xAxis: {
                title:{
                    text:"time(in sec)"
                }
            },
            yAxis: {
                title: {
                    text: "pitch value"
                }
            },
            data: {
                csv: data
                //csv: document.getElementById('csv').innerHTML
            },
            plotOptions: {
                series: {
                    marker: {
                        enabled: false
                    }
                }
            }
            });
        });
        });
    </script>
</head>
<body>
<div id="container" style="height: 400px"></div>
</body>
</html>

该代码适用于隐藏div中嵌入的csv数据。但是,当我尝试导出外部csv数据时,它的抛出错误。

enter image description here

0 个答案:

没有答案