1

I am trying to figure out how to plot data from a local '.JSON' file using angular2-highcharts example.

I followed the example in 'https://www.npmjs.com/package/angular2-highcharts' to first understand how to plot .JSON data and it worked. I took the data available for the example and created a local .JSON file (copied the content from 'https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=JSONP_CALLBACK' in notepad and saved it with UTF-8 encoding as a .JSON file), and replaced the file path for the JSON request to this. When I do this though, I get an error - response with status 200.

  constructor(jsonp : Jsonp) {
    //jsonp.get('https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=JSONP_CALLBACK').subscribe(res => {
        jsonp.get('./data.json').subscribe(res => {
        this.options = {
            title : { text : 'AAPL Stock Price' },
           series : [{
               name : 'AAPL',
               data : res.json(),
              tooltip: {
                   valueDecimals: 2
              }
         }]
        };
    });
}
options: Object;
};

Since I am not super familiar with json data/ Javascript or angular2 I am not sure if I am missing something very basic here. Any help is appreciated.

Vysh
  • 718
  • 1
  • 7
  • 20

2 Answers2

1

as far as I know, Response Status 200 specifies that request was successful. i.e. your request was successfully handled. perhaps you want to try checking response data.

check your callback for response data.

Bhushan Gadekar
  • 13,485
  • 21
  • 82
  • 131
  • 1
    This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/13122493) – H. Pauwelyn Jul 26 '16 at 11:41
  • @H.Pauwelyn Thanks,actually I thought of it as answer ,sorry for the low quality post – Bhushan Gadekar Jul 26 '16 at 12:45
1

Using http instead of json helped. I made use of the suggestion in this answer https://stackoverflow.com/a/36305814/4567096.

Community
  • 1
  • 1
Vysh
  • 718
  • 1
  • 7
  • 20