|
1 |
| -import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core'; |
2 |
| - |
3 |
| -import { customTooltips } from '@coreui/chartjs/dist/js/coreui-chartjs.js'; |
4 |
| - |
5 |
| -interface IChartProps { |
6 |
| - Data?: any; |
7 |
| - labels?: any; |
8 |
| - options?: any; |
9 |
| - colors?: any; |
10 |
| - type?: any; |
11 |
| - legend?: any; |
12 |
| - |
13 |
| - [propName: string]: any; |
14 |
| -} |
| 1 | +import { AfterContentInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, Input } from '@angular/core'; |
15 | 2 |
|
16 | 3 | @Component({
|
17 | 4 | selector: 'app-widgets-brand',
|
18 | 5 | templateUrl: './widgets-brand.component.html',
|
19 | 6 | styleUrls: ['./widgets-brand.component.scss'],
|
20 |
| - changeDetection: ChangeDetectionStrategy.OnPush |
| 7 | + changeDetection: ChangeDetectionStrategy.Default |
21 | 8 | })
|
22 |
| -export class WidgetsBrandComponent implements OnInit { |
| 9 | +export class WidgetsBrandComponent implements AfterContentInit { |
23 | 10 |
|
24 |
| - @Input() withCharts?: boolean; |
| 11 | + constructor( |
| 12 | + private changeDetectorRef: ChangeDetectorRef |
| 13 | + ) {} |
25 | 14 |
|
| 15 | + @Input() withCharts?: boolean; |
26 | 16 | // @ts-ignore
|
27 | 17 | chartOptions = {
|
28 |
| - tooltips: { |
29 |
| - enabled: false, |
30 |
| - custom: customTooltips, |
31 |
| - intersect: true, |
32 |
| - // mode: 'index' , |
33 |
| - position: 'nearest', |
34 |
| - }, |
35 | 18 | elements: {
|
36 | 19 | line: {
|
37 |
| - tension: 0.4, |
38 |
| - borderWidth: 2, |
| 20 | + tension: 0.4 |
39 | 21 | },
|
40 | 22 | point: {
|
41 | 23 | radius: 0,
|
42 | 24 | hitRadius: 10,
|
43 | 25 | hoverRadius: 4,
|
44 |
| - hoverBorderWidth: 3, |
45 |
| - }, |
46 |
| - }, |
47 |
| - animation: { |
48 |
| - duration: 0, |
| 26 | + hoverBorderWidth: 3 |
| 27 | + } |
49 | 28 | },
|
50 |
| - responsive: true, |
51 |
| - responsiveAnimationDuration: 0, |
52 | 29 | maintainAspectRatio: false,
|
53 | 30 | plugins: {
|
54 | 31 | legend: {
|
55 |
| - display: false, |
56 |
| - }, |
| 32 | + display: false |
| 33 | + } |
57 | 34 | },
|
58 | 35 | scales: {
|
59 |
| - xAxes: [ |
60 |
| - { |
61 |
| - display: false, |
62 |
| - }, |
63 |
| - ], |
64 |
| - yAxes: [ |
65 |
| - { |
66 |
| - display: false, |
67 |
| - }, |
68 |
| - ], |
69 |
| - }, |
70 |
| - } |
71 |
| - |
| 36 | + x: { |
| 37 | + display: false |
| 38 | + }, |
| 39 | + y: { |
| 40 | + display: false |
| 41 | + } |
| 42 | + } |
| 43 | + }; |
72 | 44 | labels = ['January', 'February', 'March', 'April', 'May', 'June', 'July'];
|
73 | 45 | datasets = {
|
74 | 46 | borderWidth: 2,
|
75 |
| - fill: true, |
76 |
| - } |
| 47 | + fill: true |
| 48 | + }; |
| 49 | + colors = { |
| 50 | + backgroundColor: 'rgba(255,255,255,.1)', |
| 51 | + borderColor: 'rgba(255,255,255,.55)', |
| 52 | + pointHoverBackgroundColor: '#fff' |
| 53 | + }; |
77 | 54 | brandData = [
|
78 | 55 | {
|
79 | 56 | icon: 'cibFacebook',
|
80 |
| - values: [{title: 'friends', value: '89K'}, {title: 'feeds', value: '459'}], |
81 |
| - capBg: {'--cui-card-cap-bg': '#3b5998'}, |
| 57 | + values: [{ title: 'friends', value: '89K' }, { title: 'feeds', value: '459' }], |
| 58 | + capBg: { '--cui-card-cap-bg': '#3b5998' }, |
82 | 59 | labels: [...this.labels],
|
83 |
| - data: [65, 59, 84, 84, 51, 55, 40], |
84 |
| - datasets: [{...this.datasets, data: [65, 59, 84, 84, 51, 55, 40], label: 'Facebook'}] |
| 60 | + data: { |
| 61 | + labels: [...this.labels], |
| 62 | + datasets: [{ ...this.datasets, data: [65, 59, 84, 84, 51, 55, 40], label: 'Facebook', ...this.colors }] |
| 63 | + } |
85 | 64 | },
|
86 | 65 | {
|
87 | 66 | icon: 'cibTwitter',
|
88 |
| - values: [{title: 'followers', value: '973k'}, {title: 'tweets', value: '1.792'}], |
89 |
| - capBg: {'--cui-card-cap-bg': '#00aced'}, |
90 |
| - labels: [...this.labels], |
91 |
| - datasets: [{...this.datasets, data: [1, 13, 9, 17, 34, 41, 38], label: 'Twitter'}] |
| 67 | + values: [{ title: 'followers', value: '973k' }, { title: 'tweets', value: '1.792' }], |
| 68 | + capBg: { '--cui-card-cap-bg': '#00aced' }, |
| 69 | + data: { |
| 70 | + labels: [...this.labels], |
| 71 | + datasets: [{ ...this.datasets, data: [1, 13, 9, 17, 34, 41, 38], label: 'Twitter', ...this.colors }] |
| 72 | + } |
92 | 73 | },
|
93 | 74 | {
|
94 | 75 | icon: 'cib-linkedin',
|
95 |
| - values: [{title: 'contacts', value: '500'}, {title: 'feeds', value: '1.292'}], |
96 |
| - capBg: {'--cui-card-cap-bg': '#4875b4'}, |
97 |
| - labels: [...this.labels], |
98 |
| - datasets: [{...this.datasets, data: [78, 81, 80, 45, 34, 12, 40], label: 'LinkedIn'}] |
| 76 | + values: [{ title: 'contacts', value: '500' }, { title: 'feeds', value: '1.292' }], |
| 77 | + capBg: { '--cui-card-cap-bg': '#4875b4' }, |
| 78 | + data: { |
| 79 | + labels: [...this.labels], |
| 80 | + datasets: [{ ...this.datasets, data: [78, 81, 80, 45, 34, 12, 40], label: 'LinkedIn', ...this.colors }] |
| 81 | + } |
99 | 82 | },
|
100 | 83 | {
|
101 | 84 | icon: 'cilCalendar',
|
102 |
| - values: [{title: 'events', value: '12+'}, {title: 'meetings', value: '4'}], |
| 85 | + values: [{ title: 'events', value: '12+' }, { title: 'meetings', value: '4' }], |
103 | 86 | color: 'warning',
|
104 |
| - labels: [...this.labels], |
105 |
| - datasets: [{...this.datasets, data: [35, 23, 56, 22, 97, 23, 64], label: 'Events'}] |
106 |
| - }, |
107 |
| - ] |
108 |
| - |
109 |
| - constructor() { |
110 |
| - } |
111 |
| - |
112 |
| - get colors() { |
113 |
| - return [{ |
114 |
| - backgroundColor: 'rgba(255,255,255,.1)', |
115 |
| - borderColor: 'rgba(255,255,255,.55)', |
116 |
| - pointHoverBackgroundColor: '#fff', |
117 |
| - }] |
118 |
| - } |
| 87 | + data: { |
| 88 | + labels: [...this.labels], |
| 89 | + datasets: [{ ...this.datasets, data: [35, 23, 56, 22, 97, 23, 64], label: 'Events', ...this.colors }] |
| 90 | + } |
| 91 | + } |
| 92 | + ]; |
119 | 93 |
|
120 | 94 | capStyle(value: string) {
|
121 |
| - return !!value ? {'--cui-card-cap-bg': value} : {}; |
| 95 | + return !!value ? { '--cui-card-cap-bg': value } : {}; |
122 | 96 | }
|
123 | 97 |
|
124 |
| - ngOnInit(): void { |
| 98 | + ngAfterContentInit(): void { |
| 99 | + this.changeDetectorRef.detectChanges(); |
125 | 100 | }
|
126 | 101 | }
|
0 commit comments