Skip to content

Instantly share code, notes, and snippets.

@kylelix7
Created November 24, 2019 03:48
Show Gist options
  • Save kylelix7/5c9c43324b0c5dc6c7c9613e266dc2ec to your computer and use it in GitHub Desktop.
Save kylelix7/5c9c43324b0c5dc6c7c9613e266dc2ec to your computer and use it in GitHub Desktop.
updated_chart.ts
import { Component, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
import { StockDataService } from '../stock-data.service';
import { HistoricalData } from '../models';
import { Observable} from 'rxjs';
@Component({
selector: 'app-chart',
templateUrl: './chart.component.html',
styleUrls: ['./chart.component.css'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ChartComponent {
historicalData: Observable<HistoricalData[]> = this.stockDataService.historicalData;
single: any[];
multi: any[];
view: any[] = [800, 360];
// options
showXAxis = true;
showYAxis = true;
gradient = false;
showLegend = true;
showXAxisLabel = true;
xAxisLabel = 'Time';
showYAxisLabel = true;
yAxisLabel = 'Population';
colorScheme = {
domain: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA']
};
constructor(private stockDataService: StockDataService, private changeDetectorRef: ChangeDetectorRef) {
this.historicalData.subscribe((resp)=> {
this.single = resp;
this.changeDetectorRef.detectChanges();
});
}
public onSelect(event): void {
}
public onRefresh(): void {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment