0

我实际上正在尝试完全执行此示例“ http://jsfiddle.net/BrLp7/ ”中所做的操作,但不幸的是在从 csv 文件中检索数据时无法执行此任务。下面是我的代码,它不输出任何内容,当我们单击给定示例中的一个点时,如果单击最后一个点,则结果图必须以 5,10,13 的形式存储在某个文本文件中。

<html>
<head>
<title>A BASIC HTML FORM</title>
</head>
<body>

<FORM NAME ="form1" METHOD ="POST" ACTION = "BasicForm.php">

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"   

"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>Highcharts Example</title>

<!-- 1. Add these JavaScript inclusions in the head of your page -->

<script type="text/javascript"   

src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

<script type="text/javascript" src="../js/highcharts.js"></script>

<!--[if IE]>

<script type="text/javascript" src="../js/excanvas.compiled.js"></script>

<![endif]-->

<!-- 2. Add the JavaScript to initialize the chart on document ready -->

<script type="text/javascript">

$(document).ready(function() {

var options = {

chart: {

renderTo: 'container',

defaultSeriesType: 'line'

},
title: {
text: 'Input'
},
xAxis: {
categories: []
},
yAxis: {
title: {
text: 'Units'
}
},
plotOptions: {
series: {
cursor: 'pointer',
point: {
events: {
click: function() {                                                                                                                                                         

$.get('testFile.csv', function(data) {
// Split the lines
var lines = data.split('\n');

$.each(lines, function(lineNo, line) {

var x=this.series.processedXData.indexOf(this.x);
var items = line.split(',');                                                                                              

seriesData =[];                                                                                                     

$.each(items, function(itemNo, item) {
if (itemNo < x) {
seriesData.push(parseFloat(item));
}  else if (itemNo == x){
seriesData.push(0);
}
});
}
this.series.setData(seriesData);

}
}
}
},
series: []

};

$.get('testFile.csv', function(data) {
// Split the lines
var lines = data.split('\n');

$.each(lines, function(lineNo, line) {

var items = line.split(',');

var series = {
data: []
};

$.each(items, function(itemNo, item) {

series.data.push(parseFloat(item));    });

options.series.push(series);

});

var chart = new Highcharts.Chart(options);
});
});
</script>

</head>

<body>

<script src="http://code.highcharts.com/highcharts.js"></script>

<script src="http://code.highcharts.com/modules/data.js"></script>

<script src="http://code.highcharts.com/modules/exporting.js"></script>

<!-- 3. Add the container -->

<div id="container" style="width: 1400px; height: 400px; margin: 0 auto"></div>

</body>
</html>
</FORM>

</body>

</html>
4

0 回答 0