我正在尝试使用CSV文件上的数据呈现图表,但是,当我打开图表时,数据并不是我想要的数据。我从这里读了很多类似的帖子但是当我去一些答案中提供的例子时,链接被打破了。我怎么能解决这个问题?
我的图表位于此处:http://www.blucable.com/chart/index.php
我的index.php看起来像这样:
<?php header('Access-Control-Allow-Origin: *'); ?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>ITS Dashboard Test Chart</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
var options = {
chart: {
renderTo: 'container',
},
title: {
text: 'Another Chart'
},
xAxis: {
categories: []
},
yAxis: {
title: {
text: 'Units'
}
},
rangeSelector : {
selected : 1
},
series: []
};
$.get('table.csv', function(data) {
// Split the lines
var lines = data.split('\n');
// Iterate over the lines and add categories or series
$.each(lines, function(lineNo, line) {
var items = line.split(',');
// header line containes categories
if (lineNo == 0) {
$.each(items, function(itemNo, item) {
if (itemNo > 0) options.xAxis.categories.push(item);
});
}
// the rest of the lines contain data with their name in the first
// position
else {
var series = {
data: []
};
$.each(items, function(itemNo, item) {
if (itemNo == 0) {
series.name = item;
} else {
series.data.push(parseFloat(item));
}
});
options.series.push(series);
}
});
// Create the chart
var chart = new Highcharts.StockChart(options);
});
});
</script>
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>
</head>
<body>
<div id="container" style="height: 500px; min-width: 500px"></div>
</body>
</html>
我的CSV文件如下所示:
Date,Open Tickets,Closed Tickets,Calls
2013-12-01,01,02,04
2013-11-01,06,07,09
2013-10-01,11,08,06
2013-09-01,16,09,10