Skip to content

Commit

Permalink
chore: change electro
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaZhem committed Jul 18, 2024
1 parent d9ba463 commit 43d6187
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,48 @@
<div>
<p class="controls">
<tui-input-date-range
[maxLength]="dataElectro.maxLength"
[(ngModel)]="dataElectro.data"
(ngModelChange)="dataElectro.onDataChange($event)"
[maxLength]="electroService.maxLength"
[(ngModel)]="electroService.show"
(ngModelChange)="electroService.onDataChange($event)"
>
Data
</tui-input-date-range>
</p>
<p class="legend tui-space_top-0">
<span
*ngFor="let chart of dataElectro.days; let index = index"
*ngFor="let chart of electroService.days; let index = index"
class="item"
>
<small class="name">Electricity bills</small>
</span>
</p>
<tui-axes
*ngIf="dataElectro.labels(dataElectro.show) | async as labels"
*ngIf="electroService.labels(electroService.show) | async as labels"
class="axes"
[axisXLabels]="labels"
[horizontalLines]="4"
[tuiLineChartHint]="hint"
[verticalLines]="labels.length"
>
<ng-container *ngIf="dataElectro.getWidth(dataElectro.show) > 90; else line">
<ng-container *ngIf="electroService.getWidth(electroService.show) > 90; else line">
<tui-line-days-chart
*ngFor="let chart of dataElectro.days"
*ngFor="let chart of electroService.days"
class="chart"
[height]="200"
[value]="chart | tuiFilter: dataElectro.filter : dataElectro.range"
[value]="chart | tuiFilter: electroService.filter : electroService.range"
/>
</ng-container>
<ng-template #line>
<tui-line-chart
*ngFor="let chart of dataElectro.days"
*ngFor="let chart of electroService.days"
class="chart"
[height]="200"
[value]="
chart
| tuiFilter: dataElectro.filter : dataElectro.range
| tuiMapper: dataElectro.toNumbers : dataElectro.range
| tuiFilter: electroService.filter : electroService.range
| tuiMapper: electroService.toNumbers : electroService.range
"
[width]="dataElectro.getWidth(dataElectro.range)"
[width]="electroService.getWidth(electroService.range)"
/>
</ng-template>
</tui-axes>
Expand All @@ -58,7 +58,7 @@
let-data
>
<div class="tui-space_bottom-2">
<strong>{{ dataElectro.getDate(data[0][0], dataElectro.range.from) }}</strong>
<strong>{{ electroService.getDate(data[0][0], electroService.range.from) }}</strong>
</div>
<div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@
}

.color() {
color: var(--tui-chart-categorical-01);

&:first-child {
color: var(--tui-chart-categorical-08);
}

&:last-child {
color: var(--tui-background-accent-1);
}
color: var(--tui-background-accent-1);
}

.axes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {TuiAppearance} from '@taiga-ui/core';
import {TuiCardLarge} from '@taiga-ui/layout';
import {TuiInputDateRangeModule} from '@taiga-ui/legacy';

import {ElectroService} from '../../data/services/electro.service';
import {ElectroService} from './electro.service';

@Component({
standalone: true,
Expand All @@ -38,5 +38,5 @@ import {ElectroService} from '../../data/services/electro.service';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ElectroComponent {
protected dataElectro = inject(ElectroService);
protected electroService = inject(ElectroService);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ import {map, of} from 'rxjs';
export class ElectroService {
private readonly months$ = inject(TUI_MONTHS);

public data = new TuiDayRange(
public show = new TuiDayRange(
TuiDay.currentLocal(),
TuiDay.currentLocal().append({month: 3}),
);

public show = this.data;

public days = this.random(this.data);
public days = this.random(this.show);

public readonly maxLength: TuiDayLike = {month: 4};

Expand Down

0 comments on commit 43d6187

Please sign in to comment.