uploading external csv file to highcharts not working

风流意气都作罢 提交于 2019-12-14 03:58:29

问题


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


回答1:


You need a server setup, like apache or nodejs.

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



来源:https://stackoverflow.com/questions/38889440/uploading-external-csv-file-to-highcharts-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!