uploading external csv file to highcharts not work

2019-07-30 04:55发布

<!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>

The code worked for csv data embedded in a hidden div. However when I try exporting external csv data, its throwing error.

enter image description here

1条回答
Melony?
2楼-- · 2019-07-30 05:46

You need a server setup, like apache or nodejs.

You need a server because you cannot make XMLHttpRequests at a file:// URL

查看更多
登录 后发表回答