Skip to content

Instantly share code, notes, and snippets.

@haroon786
Created June 25, 2020 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haroon786/35ef27d808de0143b494155e8cca93d8 to your computer and use it in GitHub Desktop.
Save haroon786/35ef27d808de0143b494155e8cca93d8 to your computer and use it in GitHub Desktop.
import { Component, OnInit } from "@angular/core";
import { HighchartService, chartModal } from "./highchart.service";
import * as Highcharts from "highcharts";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"],
})
export class AppComponent implements OnInit {
title = "Firestore-Angular-Highcharts";
items$: chartModal[];
Highcharts: typeof Highcharts = Highcharts;
chardata: any[] = [];
chartOptions: any;
constructor(private highchartservice: HighchartService) {}
ngOnInit() {
this.highchartservice.rates$.subscribe((assets) => {
this.items$ = assets;
if (this.items$) {
this.items$.forEach((element) => {
this.chardata.push(element.rate);
});
this.getChart();
}
});
}
getChart() {
this.chartOptions = {
series: [
{
data: this.chardata,
},
],
chart: {
type: "bar",
},
title: {
text: "barchart",
},
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment