|
| 1 | +import { |
| 2 | + AfterViewInit, |
| 3 | + ChangeDetectionStrategy, |
| 4 | + Component, |
| 5 | + ViewChild |
| 6 | +} from "@angular/core"; |
| 7 | +import { IgxCategoryChartComponent } from "igniteui-angular-charts"; |
| 8 | + |
| 9 | +@Component({ |
| 10 | + changeDetection: ChangeDetectionStrategy.OnPush, |
| 11 | + selector: "app-root", |
| 12 | + styleUrls: ["./app.component.scss"], |
| 13 | + templateUrl: "./app.component.html" |
| 14 | +}) |
| 15 | +export class AppComponent { |
| 16 | + |
| 17 | + @ViewChild("chart", { static: true }) |
| 18 | + public chart: IgxCategoryChartComponent; |
| 19 | + public isItemHighlightingEnabled: boolean = true; |
| 20 | + public isSeriesHighlightingEnabled: boolean = true; |
| 21 | + public isCategoryHighlightingEnabled: boolean = false; |
| 22 | + public olympicData: any; |
| 23 | + public chartType: string = "Column"; |
| 24 | + |
| 25 | + constructor() { |
| 26 | + const usaMedals: any = [ |
| 27 | + { Year: "1996", UnitedStates: 148 }, |
| 28 | + { Year: "2000", UnitedStates: 142 }, |
| 29 | + { Year: "2004", UnitedStates: 134 }, |
| 30 | + { Year: "2008", UnitedStates: 131 }, |
| 31 | + { Year: "2012", UnitedStates: 135 }, |
| 32 | + { Year: "2016", UnitedStates: 146 } |
| 33 | + ]; |
| 34 | + const chinaMedals: any = [ |
| 35 | + { Year: "1996", China: 110 }, |
| 36 | + { Year: "2000", China: 115 }, |
| 37 | + { Year: "2004", China: 121 }, |
| 38 | + { Year: "2008", China: 129 }, |
| 39 | + { Year: "2012", China: 115 }, |
| 40 | + { Year: "2016", China: 112 } |
| 41 | + ]; |
| 42 | + const russiaMedals: any = [ |
| 43 | + { Year: "1996", Russia: 95 }, |
| 44 | + { Year: "2000", Russia: 91 }, |
| 45 | + { Year: "2004", Russia: 86 }, |
| 46 | + { Year: "2008", Russia: 65 }, |
| 47 | + { Year: "2012", Russia: 77 }, |
| 48 | + { Year: "2016", Russia: 88 } |
| 49 | + ]; |
| 50 | + this.olympicData = [ usaMedals, chinaMedals, russiaMedals ]; |
| 51 | + } |
| 52 | + |
| 53 | + public ngAfterViewInit(): void { |
| 54 | + } |
| 55 | + |
| 56 | + public initHighlighting(): void { |
| 57 | + this.chart.isItemHighlightingEnabled = true; |
| 58 | + this.chart.isCategoryHighlightingEnabled = true; |
| 59 | + this.chart.isSeriesHighlightingEnabled = true; |
| 60 | + } |
| 61 | +} |
0 commit comments