Christopher A. Lewis
Christopher A. Lewis

Reputation: 65

HighChart.js data source recommendations

I am looking to use Highstock.js for an application I am developing and looking to implement a stock performance with Highcharts stock library chart; http://www.highcharts.com/stock/demo/

I was wondering if there was any good suggestions on where to get the data source from?

Thank-you!

Upvotes: 0

Views: 1228

Answers (3)

StuR
StuR

Reputation: 12218

I fetch data from an API, and then store the data in localstorage.

e.g:

This fetches data from an API for use with Highcharts, and stores/updates it in localstorage (jStorage).

    updateLocalStorage: function(id) {
        //Check if local storage needs updating
        if (isNaN($.jStorage.get(id))) {
            //Data exists in Localstorage, merge data
            //Query API for highstock data

            return $.post('api/', {
                data_id: id
            }, function(data) {
                if (data) {
                    var merged = $.extend($.jStorage.get(id), data);
                    $.jStorage.set(id, merged);
                }
            });

            //return true;
        }
}

Once this data has been fetched I then render highcharts from the data that is stored in localstorage.

$.when(updateLocalStorage(id)).then(function(response){               
if(response){
//Local storage is up to date. Render chart
}
});

I can also fetch data from the API using a timer and update localstorage, when I want to re-render the chart I can just use the highcharts setData method, e.g:

var json = $.jStorage.get(id);

for(i =0; i < json.data; i++) {
    chart_object.series[i].setData(json.data[i]);
}

Upvotes: 1

SteveP
SteveP

Reputation: 19093

If you are asking about where to get financial stock price data from, there are several sources I know of including google finance and yahoo finance. Here are some links to help you:

How can I get stock quotes using Google Finance API?

http://www.yqlblog.net/blog/2009/06/02/getting-stock-information-with-yql-and-open-data-tables/

Upvotes: 0

Sebastian Bochan
Sebastian Bochan

Reputation: 37588

You can hardcode data in series / data object as in the example http://www.highcharts.com/demo/ Obviously you can also use dynamically way to define points.

http://docs.highcharts.com/#preprocessing

Upvotes: 0

Related Questions