Currently, I am receiving JSON data from a URL. The data is structured in the following way:
[
{"id":1,"symbol":"SP-500","date":"1927-12-30T07:00:00.000+00:00","open":17.66,"high":17.66,"low":17.66,"close":17.66,"volume":0},
{"id":2,"symbol":"SP-500","date":"1928-01-03T07:00:00.000+00:00","open":17.76,"high":17.76,"low":17.76,"close":17.76,"volume":0}
]
The code snippet responsible for fetching this data resides in quote.service.ts and is structured as follows:
getQuotesList(): Observable<any> {
return this.http.get(`${this.baseUrl}`);
}
The full class, including dependencies and methods, can be found below:
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable, Subject } from 'rxjs';
import { of } from 'rxjs';
import 'rxjs/add/operator/map'
import 'rxjs/operator/filter';
import { Quote } from "./quote";
@Injectable({
providedIn: 'root'
})
export class QuoteService {
private baseUrl = 'http://localhost:8080/springboot-crud-rest/api/v1/quotes';
constructor(private http: HttpClient) { }
// Additional methods for CRUD operations
getQuotesList(): Observable<any> {
// Transformation of data for charting purposes
}
}
After fetching and loading the data into an array in quote-list.component.ts, the data is presented in a tabular format using the code snippet below:
<tr *ngFor="let quote of quotes | async">
<td>{{quote.symbol}}</td>
<td>{{quote.date}}</td>
<td>{{quote.open}}</td>
<td>{{quote.high}}</td>
<td>{{quote.low}}</td>
<td>{{quote.close}}</td>
<td>{{quote.volume}}</td>
<td><button (click)="deleteQuote(quote.id)" class="btn btn-danger">Delete</button>
<button (click)="quoteDetails(quote.id)" class="btn btn-info" style="margin-left: 10px">Details</button>
</td>
</tr>
The next step is to extract and organize the values into separate arrays for each data type (such as dates and open prices) to facilitate plotting in a JavaScript charting program. Various attempts have been made to achieve this, but certain errors have been encountered. Assistance and guidance on resolving these issues are greatly appreciated!
UPDATE: The code has been successfully hosted on a Linux server. To access the live data, please visit the following URL in your browser: 167.172.141.34:8080/springboot-crud-rest/api/v1/quotes