Skip to content

Commit 1d61d79

Browse files
fix(graph): paths not loading
1 parent e97b6d6 commit 1d61d79

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

src/client/build/graph/graph.component.ts

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {AfterContentChecked, ChangeDetectionStrategy, Component, ElementRef, Inject, Input, OnInit} from '@angular/core';
1+
import {Component, ElementRef, Inject, Input, OnInit} from '@angular/core';
22
import {select} from 'd3-selection';
33
import {curveStepAfter, Line, line} from 'd3-shape';
44

@@ -14,19 +14,18 @@ export interface Path {
1414
enabled: boolean;
1515
preview: boolean;
1616
name: string;
17-
obj: Line<[number, number]>;
17+
d: Line<[number, number]>;
1818
}
1919

2020
@Component({
2121
selector: 'graph',
22-
changeDetection: ChangeDetectionStrategy.OnPush,
2322
template: `
2423
<legend [paths]="paths"></legend>
2524
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="100%" height="100%" [attr.viewBox]="'0 0 ' + config.width + ' ' + config.height">
2625
<g ability-sequence [attr.transform]="'translate(0,' + (config.graphHeight + config.margin.top + config.margin.bottom) + ')'"></g>
2726
<g [attr.transform]="'translate(' + config.margin.left + ',' + config.margin.top + ')'">
2827
<g class="lines">
29-
<path *ngFor="let path of paths" [ngClass]="'line ' + path.name + (path.enabled ? ' enabled' : '') + (path.preview ? ' preview' : '')"></path>
28+
<path *ngFor="let path of paths" [attr.d]="path.d" [ngClass]="'line ' + path.name + (path.enabled ? ' enabled' : '') + (path.preview ? ' preview' : '')"></path>
3029
</g>
3130
<g class="axes">
3231
<g class="x axis time" [attr.transform]="'translate(0,' + config.graphHeight + ')'"></g>
@@ -39,7 +38,7 @@ export interface Path {
3938
</svg>`
4039
})
4140

42-
export class GraphComponent implements OnInit, AfterContentChecked {
41+
export class GraphComponent implements OnInit {
4342
private samples: Samples;
4443
@Input() private stats: any;
4544

@@ -98,10 +97,6 @@ export class GraphComponent implements OnInit, AfterContentChecked {
9897
});
9998
}
10099

101-
ngAfterContentChecked() {
102-
this.updatePaths();
103-
}
104-
105100
createAxes() {
106101
this.xScaleTime.create();
107102
this.xAxisTime.create(this.xScaleTime);
@@ -120,17 +115,11 @@ export class GraphComponent implements OnInit, AfterContentChecked {
120115
this.paths = [];
121116
for (let index in this.samples) {
122117
this.paths.push(
123-
{enabled: true, preview: false, name: index, obj: this.lineSamples(this.samples[index])});
118+
{enabled: true, preview: false, name: index, d: this.lineSamples(this.samples[index])});
124119
}
125120
for (let index in this.stats) {
126121
this.paths.push(
127-
{enabled: true, preview: false, name: index, obj: this.lineStats(this.stats[index])});
128-
}
129-
}
130-
131-
updatePaths() {
132-
for (let path of this.paths) {
133-
this.svg.select('.line.' + path.name).attr('d', path.obj);
122+
{enabled: true, preview: false, name: index, d: this.lineStats(this.stats[index])});
134123
}
135124
}
136125

0 commit comments

Comments
 (0)