简体   繁体   中英

How To Load CSV File Data On HighChart?

I am trying to using highchart library into Xcode for showing chart In mobile application. Objective C to calling highchart library. For data load I have Included local .CSV file Into Xcode. Now If I am using below code to read the data from CSV file, I cant print the data and chart data also not loading.

My Code Below

$(function () {

  $.get('data.csv', function(data) {

            // Create the chart
            $('#container').highcharts('StockChart', {

                   rangeSelector : {
                     selected : 1
                   },

                   title : {
                         text : ''
                   },

                   rangeSelector : {
                         enabled : false
                   },

                   scrollbar : {
                         enabled : false
                   },

                   navigator : {
                         enabled : false
                   },

                   plotOptions: {
                       line: {animation: true},
                       series: {
                           marker: {
                           enabled: true,
                           fillColor: '#FFFFFF',
                           lineWidth: 2,
                           symbol: 'url()'
                               },
                           enableMouseTracking: true
                           }
                   },

                   series : [{
                             name : 'AAS Stock Price',
                             csv:data,
                             /*data : [
                                     [1233705600000,13.36],
                                     [1233792000000,13.78],
                                     [1233878400000,14.25],
                                     [1234137600000,14.64],
                                     [1234224000000,13.98],
                                     [1234310400000,13.83],
                                     [1234396800000,14.18],
                                     [1234483200000,14.17],
                                     [1234828800000,13.50],
                                     [1234915200000,13.48],
                                     [1235001600000,12.95],
                                     [1235088000000,13.00],
                                     [1235347200000,12.42],
                                     [1235433600000,12.89],
                                     [1235520000000,13.02],
                                     [1235606400000,12.74],
                                     [1235692800000,12.76]],*/
                             tooltip: {
                             valueDecimals: 2
                     }
                 }]
            });
        });
  });
 data: {
        csv: data // data is your param you set in get csv call

    },

,

refer Documentation here

For loading data directly from CSV file you should add Highcharts data module and then set the data like:

$.get('data.csv', function(csv) {
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        data: {
            csv: csv
        },
        title: {
            text: 'Fruit Consumption'
        },
        yAxis: {
            title: {
                text: 'Units'
            }
        }
    });
});

More info about data module can be found in Highchars Docs - here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM