简体   繁体   English

如何在HighChart上加载CSV文件数据?

[英]How To Load CSV File Data On HighChart?

I am trying to using highchart library into Xcode for showing chart In mobile application. 我正在尝试使用highchart库到Xcode以在移动应用程序中显示图表。 Objective C to calling highchart library. Objective C调用highchart库。 For data load I have Included local .CSV file Into Xcode. 对于数据加载,我已将本地.CSV文件包含到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. 现在,如果我正在使用以下代码从CSV文件读取数据,则无法打印数据,并且图表数据也无法加载。

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: 要直接从CSV文件加载数据,您应该添加Highcharts 数据模块 ,然后按以下方式设置数据:

$.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 . 有关数据模块的更多信息,请参见Highchars Docs- 这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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