How to parse data (Observable) returned by valueChanges() on Firebase and plot to Chart.js
I'm trying to retrieve some data from Firebase RealTime Database, I'm being able to plot the data that I'm retrieving, but I don't know how to parse this data received as an Observable, to a list that I could plot on Chart.js or any other chart framework.
Here is my datastored.ts module
<pre>
import { Component } from '@angular/core';
import { IonicPage, NavParams, DateTime } from 'ionic-angular';
import { NavController, Item } from 'ionic-angular';
import { Observable } from 'rxjs-compat';
import { AngularFireDatabase } from '@angular/fire/database';
@IonicPage({
name: 'DatastoredPage'
})
@Component({
selector: 'page-datastored',
templateUrl: 'datastored.html',
})
export class DatastoredPage {
myDateStart:string = "2018-10-04"
myDateEnd:string = "2018-10-30"
incubator30: Observable<any>;
constructor(public navCtrl: NavController, public navParams: NavParams, private db:AngularFireDatabase) {
this.incubator30 = db.list('NeoSilence/Incubator1', ref => ref.orderByChild("d").startAt(this.myDateStart).endAt(this.myDateEnd)).valueChanges();
}
ionViewDidLoad() {
console.log('ionViewDidLoad DatastoredPage');
console.log(this.incubator30);
}
getstartByDate() {
console.log(this.myDateStart);
console.log("Before the Startdate filter");
this.incubator30 = this.db.list('NeoSilence/Incubator1', ref => ref.orderByChild("d").startAt(this.myDateStart).endAt(this.myDateEnd)).valueChanges();
console.log("After the Startdate filter");
this.incubator30.forEach(element => {
element.forEach(co => {
console.log(co.d)
})
});
}
getendByDate() {
console.log(this.myDateEnd);
console.log("Before the Enddate filter");
this.incubator30 = this.db.list('NeoSilence/Incubator1', ref => ref.orderByChild("d").startAt(this.myDateStart).endAt(this.myDateEnd)).valueChanges();
console.log("After the Enddate filter");
this.incubator30.forEach(element => {
element.forEach(co => {
console.log(co.d)
})
});
}
}
</pre>
And here is my HTML code where I'm being able to display that data retrieved.
class="bgstyle" *ngFor="let StoredData of incubator30 | async">
{{StoredData.d | json}} - {{StoredData.t | json}} {{StoredData.f | json}}dBA
How on the datastored.ts module I'll be able to read the information I want (date(d) and measurement(f) into a variable that I can plot on chart.js or highchart, or any other chart platform.
angular firebase ionic-framework firebase-realtime-database
add a comment |
I'm trying to retrieve some data from Firebase RealTime Database, I'm being able to plot the data that I'm retrieving, but I don't know how to parse this data received as an Observable, to a list that I could plot on Chart.js or any other chart framework.
Here is my datastored.ts module
<pre>
import { Component } from '@angular/core';
import { IonicPage, NavParams, DateTime } from 'ionic-angular';
import { NavController, Item } from 'ionic-angular';
import { Observable } from 'rxjs-compat';
import { AngularFireDatabase } from '@angular/fire/database';
@IonicPage({
name: 'DatastoredPage'
})
@Component({
selector: 'page-datastored',
templateUrl: 'datastored.html',
})
export class DatastoredPage {
myDateStart:string = "2018-10-04"
myDateEnd:string = "2018-10-30"
incubator30: Observable<any>;
constructor(public navCtrl: NavController, public navParams: NavParams, private db:AngularFireDatabase) {
this.incubator30 = db.list('NeoSilence/Incubator1', ref => ref.orderByChild("d").startAt(this.myDateStart).endAt(this.myDateEnd)).valueChanges();
}
ionViewDidLoad() {
console.log('ionViewDidLoad DatastoredPage');
console.log(this.incubator30);
}
getstartByDate() {
console.log(this.myDateStart);
console.log("Before the Startdate filter");
this.incubator30 = this.db.list('NeoSilence/Incubator1', ref => ref.orderByChild("d").startAt(this.myDateStart).endAt(this.myDateEnd)).valueChanges();
console.log("After the Startdate filter");
this.incubator30.forEach(element => {
element.forEach(co => {
console.log(co.d)
})
});
}
getendByDate() {
console.log(this.myDateEnd);
console.log("Before the Enddate filter");
this.incubator30 = this.db.list('NeoSilence/Incubator1', ref => ref.orderByChild("d").startAt(this.myDateStart).endAt(this.myDateEnd)).valueChanges();
console.log("After the Enddate filter");
this.incubator30.forEach(element => {
element.forEach(co => {
console.log(co.d)
})
});
}
}
</pre>
And here is my HTML code where I'm being able to display that data retrieved.
class="bgstyle" *ngFor="let StoredData of incubator30 | async">
{{StoredData.d | json}} - {{StoredData.t | json}} {{StoredData.f | json}}dBA
How on the datastored.ts module I'll be able to read the information I want (date(d) and measurement(f) into a variable that I can plot on chart.js or highchart, or any other chart platform.
angular firebase ionic-framework firebase-realtime-database
1
You can convert Observable to array which you can use as data feed.
– wannadream
Nov 23 '18 at 2:02
add a comment |
I'm trying to retrieve some data from Firebase RealTime Database, I'm being able to plot the data that I'm retrieving, but I don't know how to parse this data received as an Observable, to a list that I could plot on Chart.js or any other chart framework.
Here is my datastored.ts module
<pre>
import { Component } from '@angular/core';
import { IonicPage, NavParams, DateTime } from 'ionic-angular';
import { NavController, Item } from 'ionic-angular';
import { Observable } from 'rxjs-compat';
import { AngularFireDatabase } from '@angular/fire/database';
@IonicPage({
name: 'DatastoredPage'
})
@Component({
selector: 'page-datastored',
templateUrl: 'datastored.html',
})
export class DatastoredPage {
myDateStart:string = "2018-10-04"
myDateEnd:string = "2018-10-30"
incubator30: Observable<any>;
constructor(public navCtrl: NavController, public navParams: NavParams, private db:AngularFireDatabase) {
this.incubator30 = db.list('NeoSilence/Incubator1', ref => ref.orderByChild("d").startAt(this.myDateStart).endAt(this.myDateEnd)).valueChanges();
}
ionViewDidLoad() {
console.log('ionViewDidLoad DatastoredPage');
console.log(this.incubator30);
}
getstartByDate() {
console.log(this.myDateStart);
console.log("Before the Startdate filter");
this.incubator30 = this.db.list('NeoSilence/Incubator1', ref => ref.orderByChild("d").startAt(this.myDateStart).endAt(this.myDateEnd)).valueChanges();
console.log("After the Startdate filter");
this.incubator30.forEach(element => {
element.forEach(co => {
console.log(co.d)
})
});
}
getendByDate() {
console.log(this.myDateEnd);
console.log("Before the Enddate filter");
this.incubator30 = this.db.list('NeoSilence/Incubator1', ref => ref.orderByChild("d").startAt(this.myDateStart).endAt(this.myDateEnd)).valueChanges();
console.log("After the Enddate filter");
this.incubator30.forEach(element => {
element.forEach(co => {
console.log(co.d)
})
});
}
}
</pre>
And here is my HTML code where I'm being able to display that data retrieved.
class="bgstyle" *ngFor="let StoredData of incubator30 | async">
{{StoredData.d | json}} - {{StoredData.t | json}} {{StoredData.f | json}}dBA
How on the datastored.ts module I'll be able to read the information I want (date(d) and measurement(f) into a variable that I can plot on chart.js or highchart, or any other chart platform.
angular firebase ionic-framework firebase-realtime-database
I'm trying to retrieve some data from Firebase RealTime Database, I'm being able to plot the data that I'm retrieving, but I don't know how to parse this data received as an Observable, to a list that I could plot on Chart.js or any other chart framework.
Here is my datastored.ts module
<pre>
import { Component } from '@angular/core';
import { IonicPage, NavParams, DateTime } from 'ionic-angular';
import { NavController, Item } from 'ionic-angular';
import { Observable } from 'rxjs-compat';
import { AngularFireDatabase } from '@angular/fire/database';
@IonicPage({
name: 'DatastoredPage'
})
@Component({
selector: 'page-datastored',
templateUrl: 'datastored.html',
})
export class DatastoredPage {
myDateStart:string = "2018-10-04"
myDateEnd:string = "2018-10-30"
incubator30: Observable<any>;
constructor(public navCtrl: NavController, public navParams: NavParams, private db:AngularFireDatabase) {
this.incubator30 = db.list('NeoSilence/Incubator1', ref => ref.orderByChild("d").startAt(this.myDateStart).endAt(this.myDateEnd)).valueChanges();
}
ionViewDidLoad() {
console.log('ionViewDidLoad DatastoredPage');
console.log(this.incubator30);
}
getstartByDate() {
console.log(this.myDateStart);
console.log("Before the Startdate filter");
this.incubator30 = this.db.list('NeoSilence/Incubator1', ref => ref.orderByChild("d").startAt(this.myDateStart).endAt(this.myDateEnd)).valueChanges();
console.log("After the Startdate filter");
this.incubator30.forEach(element => {
element.forEach(co => {
console.log(co.d)
})
});
}
getendByDate() {
console.log(this.myDateEnd);
console.log("Before the Enddate filter");
this.incubator30 = this.db.list('NeoSilence/Incubator1', ref => ref.orderByChild("d").startAt(this.myDateStart).endAt(this.myDateEnd)).valueChanges();
console.log("After the Enddate filter");
this.incubator30.forEach(element => {
element.forEach(co => {
console.log(co.d)
})
});
}
}
</pre>
And here is my HTML code where I'm being able to display that data retrieved.
class="bgstyle" *ngFor="let StoredData of incubator30 | async">
{{StoredData.d | json}} - {{StoredData.t | json}} {{StoredData.f | json}}dBA
How on the datastored.ts module I'll be able to read the information I want (date(d) and measurement(f) into a variable that I can plot on chart.js or highchart, or any other chart platform.
angular firebase ionic-framework firebase-realtime-database
angular firebase ionic-framework firebase-realtime-database
edited Nov 23 '18 at 1:35
Frank van Puffelen
227k27372396
227k27372396
asked Nov 23 '18 at 1:03
Diego Cabral
325
325
1
You can convert Observable to array which you can use as data feed.
– wannadream
Nov 23 '18 at 2:02
add a comment |
1
You can convert Observable to array which you can use as data feed.
– wannadream
Nov 23 '18 at 2:02
1
1
You can convert Observable to array which you can use as data feed.
– wannadream
Nov 23 '18 at 2:02
You can convert Observable to array which you can use as data feed.
– wannadream
Nov 23 '18 at 2:02
add a comment |
1 Answer
1
active
oldest
votes
I was able to solve it, subscribing to the variable I'll would like to plot. Which as 'd' and 'f'.
this.incubator30.subscribe((res) => {
this.date = res.map((value) => { return value.d });
this.list = res.map((value) => { return value.f
})
Thanks.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439555%2fhow-to-parse-data-observable-returned-by-valuechanges-on-firebase-and-plot-t%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I was able to solve it, subscribing to the variable I'll would like to plot. Which as 'd' and 'f'.
this.incubator30.subscribe((res) => {
this.date = res.map((value) => { return value.d });
this.list = res.map((value) => { return value.f
})
Thanks.
add a comment |
I was able to solve it, subscribing to the variable I'll would like to plot. Which as 'd' and 'f'.
this.incubator30.subscribe((res) => {
this.date = res.map((value) => { return value.d });
this.list = res.map((value) => { return value.f
})
Thanks.
add a comment |
I was able to solve it, subscribing to the variable I'll would like to plot. Which as 'd' and 'f'.
this.incubator30.subscribe((res) => {
this.date = res.map((value) => { return value.d });
this.list = res.map((value) => { return value.f
})
Thanks.
I was able to solve it, subscribing to the variable I'll would like to plot. Which as 'd' and 'f'.
this.incubator30.subscribe((res) => {
this.date = res.map((value) => { return value.d });
this.list = res.map((value) => { return value.f
})
Thanks.
answered Nov 23 '18 at 23:35
Diego Cabral
325
325
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439555%2fhow-to-parse-data-observable-returned-by-valuechanges-on-firebase-and-plot-t%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You can convert Observable to array which you can use as data feed.
– wannadream
Nov 23 '18 at 2:02