上传外部csv文件到highcharts不工作 [英] uploading external csv file to highcharts not working
本文介绍了上传外部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数据时,它的抛出错误。
The code worked for csv data embedded in a hidden div. However when I try exporting external csv data, its throwing error.
推荐答案
您需要一个服务器设置,如 apache 或 nodejs 。
You need a server setup, like apache or nodejs.
您需要一个服务器,因为您无法使 XMLHttpRequests 位于file:// URL
You need a server because you cannot make XMLHttpRequests at a file:// URL
这篇关于上传外部csv文件到highcharts不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文