-
Notifications
You must be signed in to change notification settings - Fork 672
Expand file tree
/
Copy pathapp.component.ts
More file actions
84 lines (69 loc) · 2.03 KB
/
app.component.ts
File metadata and controls
84 lines (69 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import {
ChangeDetectionStrategy,
Component,
AfterViewInit,
enableProdMode,
provideZoneChangeDetection,
inject,
} from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { HttpClient, provideHttpClient, withFetch } from '@angular/common/http';
import { lastValueFrom } from 'rxjs';
import { DxChartModule, DxSelectBoxModule } from 'devextreme-angular';
import { DataSource, CustomStore } from 'devextreme-angular/common/data';
if (!/localhost/.test(document.location.host)) {
enableProdMode();
}
let modulePrefix = '';
// @ts-ignore
if (window && window.config?.packageConfigPaths) {
modulePrefix = '/app';
}
@Component({
changeDetection: ChangeDetectionStrategy.Eager,
selector: 'demo-app',
templateUrl: `.${modulePrefix}/app.component.html`,
styleUrls: [`.${modulePrefix}/app.component.css`],
imports: [
DxChartModule,
DxSelectBoxModule,
],
})
export class AppComponent implements AfterViewInit {
temperature: number[] = [2, 4, 6, 8, 9, 10, 11];
palette: string[] = ['#c3a2cc', '#b7b5e0', '#e48cba'];
paletteIndex = 0;
monthWeather = {} as DataSource;
http = inject(HttpClient);
ngAfterViewInit() {
this.monthWeather = new DataSource({
store: new CustomStore({
load: () => lastValueFrom(this.http.get('../../../../data/monthWeather.json'))
.catch(() => { throw new Error('Data Loading Error'); }),
loadMode: 'raw',
}),
filter: ['t', '>', '2'],
paginate: false,
});
}
customizePoint = () => {
const color = this.palette[this.paletteIndex];
this.paletteIndex = this.paletteIndex === 2 ? 0 : this.paletteIndex + 1;
return {
color,
};
};
customizeText(arg) {
return `${arg.valueText}°C`;
}
onValueChanged(data) {
this.monthWeather.filter(['t', '>', data.value]);
this.monthWeather.load();
}
}
bootstrapApplication(AppComponent, {
providers: [
provideZoneChangeDetection({ eventCoalescing: true, runCoalescing: true }),
provideHttpClient(withFetch()),
],
});