Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2011-08-01 00:00:00,155
- 2011-08-02 00:00:00,156
- 2011-08-03 00:00:00,157
- 2011-08-03 00:00:00,160
- $(document).ready(function() {
- var options = {
- chart: {
- renderTo: 'chart',
- defaultSeriesType: 'line',
- marginRight: 130,
- marginBottom: 25
- },
- title: {
- text: 'reading',
- x: -20 //center
- },
- xAxis: {
- title: {
- text: 'Date Measurement'
- },
- categories: []
- },
- yAxis: {
- title: {
- text: 'reading'
- }
- },
- series: []
- };
- $.get('C:/Program Files (x86)/Zend/Apache2/htdocs/myproject/public/data.csv', function(data) {
- // Split the lines using newline 'n' as delimiter
- var lines = data.split('n');
- $.each(lines, function(lineNo, line) {
- // split the line elements using comma ',' as delimiter
- var items = line.split(',');
- $.each (items, function(itemNo, item) {
- if(itemNo == 0)
- options.xAxis.categories.push(item);
- else if(itemNo > 0) {
- var series = {
- data: []
- };
- series.data.push(parseFloat(item));
- };
- options.series.push(series);
- });
- var chart = new HighCharts.Chart(options);
- });
- });
- });
- $(document).ready(function() {
- var c = [];
- var d = [];
- $.get('data.csv', function(data) {
- var lines = data.split('n');
- $.each(lines, function(lineNo, line) {
- var items = line.split(',');
- c.push(items[0]);
- d.push(parseInt(items[1]));
- });
- });
- var options = {
- chart: {
- renderTo: 'chart',
- defaultSeriesType: 'line'
- },
- title: {
- text: 'reading'
- },
- xAxis: {
- title: {
- text: 'Date Measurement'
- },
- categories: c
- },
- yAxis: {
- title: {
- text: 'reading'
- }
- },
- series: [{
- data: d
- }]
- };
- var chart = new Highcharts.Chart(options);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement