Skip to content

Commit

Permalink
run prettier on some files
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilFlash committed Feb 19, 2024
1 parent 2690712 commit 191ace5
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,63 +57,82 @@ describe('<ngx-charts-box-chart>', () => {
const fixture = TestBed.createComponent(TestComponent);
fixture.detectChanges();
type LineCoordinates = [IVector2D, IVector2D, IVector2D, IVector2D];
const line1Coordinates: LineCoordinates = [{
"v1": { "x": 109.5, "y": 245 },
"v2": { "x": 109.5, "y": 107.96610169491527 }
}, {
"v1": { "x": 121.66666666666667, "y": 245 },
"v2": { "x": 97.33333333333333, "y": 245 }
}, {
"v1": { "x": 150, "y": 191.01694915254237 },
"v2": { "x": 69, "y": 191.01694915254237 }
}, {
"v1": { "x": 121.66666666666667, "y": 107.96610169491527 },
"v2": { "x": 97.33333333333333, "y": 107.96610169491527 }
}];
const line2Coordinates: LineCoordinates = [{
"v1": { "x": 254.5, "y": 211.77966101694915 },
"v2": { "x": 254.5, "y": 41.52542372881356 }
}, {
"v1": { "x": 266.6666666666667, "y": 211.77966101694915 },
"v2": { "x": 242.33333333333334, "y": 211.77966101694915 }
}, {
"v1": { "x": 295, "y": 149.4915254237288 },
"v2": { "x": 214, "y": 149.4915254237288 }
}, {
"v1": { "x": 266.6666666666667, "y": 41.52542372881356 },
"v2": { "x": 242.33333333333334, "y": 41.52542372881356 }
}];
const line1Coordinates: LineCoordinates = [
{
v1: { x: 109.5, y: 245 },
v2: { x: 109.5, y: 107.96610169491527 }
},
{
v1: { x: 121.66666666666667, y: 245 },
v2: { x: 97.33333333333333, y: 245 }
},
{
v1: { x: 150, y: 191.01694915254237 },
v2: { x: 69, y: 191.01694915254237 }
},
{
v1: { x: 121.66666666666667, y: 107.96610169491527 },
v2: { x: 97.33333333333333, y: 107.96610169491527 }
}
];
const line2Coordinates: LineCoordinates = [
{
v1: { x: 254.5, y: 211.77966101694915 },
v2: { x: 254.5, y: 41.52542372881356 }
},
{
v1: { x: 266.6666666666667, y: 211.77966101694915 },
v2: { x: 242.33333333333334, y: 211.77966101694915 }
},
{
v1: { x: 295, y: 149.4915254237288 },
v2: { x: 214, y: 149.4915254237288 }
},
{
v1: { x: 266.6666666666667, y: 41.52542372881356 },
v2: { x: 242.33333333333334, y: 41.52542372881356 }
}
];

const cloneLine1Coordinates = cloneLineCoordinates(line1Coordinates);
const cloneLine2Coordinates = cloneLineCoordinates(line2Coordinates);

expect(cloneLine1Coordinates).toEqual([{
"v1": { "x": 109.5, "y": 245 },
"v2": { "x": 109.5, "y": 107.96610169491527 }
}, {
"v1": { "x": 121.66666666666667, "y": 245 },
"v2": { "x": 97.33333333333333, "y": 245 }
}, {
"v1": { "x": 150, "y": 191.01694915254237 },
"v2": { "x": 69, "y": 191.01694915254237 }
}, {
"v1": { "x": 121.66666666666667, "y": 107.96610169491527 },
"v2": { "x": 97.33333333333333, "y": 107.96610169491527 }
}]);
expect(cloneLine2Coordinates).toEqual([{
"v1": { "x": 254.5, "y": 211.77966101694915 },
"v2": { "x": 254.5, "y": 41.52542372881356 }
}, {
"v1": { "x": 266.6666666666667, "y": 211.77966101694915 },
"v2": { "x": 242.33333333333334, "y": 211.77966101694915 }
}, {
"v1": { "x": 295, "y": 149.4915254237288 },
"v2": { "x": 214, "y": 149.4915254237288 }
}, {
"v1": { "x": 266.6666666666667, "y": 41.52542372881356 },
"v2": { "x": 242.33333333333334, "y": 41.52542372881356 }
}]);
expect(cloneLine1Coordinates).toEqual([
{
v1: { x: 109.5, y: 245 },
v2: { x: 109.5, y: 107.96610169491527 }
},
{
v1: { x: 121.66666666666667, y: 245 },
v2: { x: 97.33333333333333, y: 245 }
},
{
v1: { x: 150, y: 191.01694915254237 },
v2: { x: 69, y: 191.01694915254237 }
},
{
v1: { x: 121.66666666666667, y: 107.96610169491527 },
v2: { x: 97.33333333333333, y: 107.96610169491527 }
}
]);
expect(cloneLine2Coordinates).toEqual([
{
v1: { x: 254.5, y: 211.77966101694915 },
v2: { x: 254.5, y: 41.52542372881356 }
},
{
v1: { x: 266.6666666666667, y: 211.77966101694915 },
v2: { x: 242.33333333333334, y: 211.77966101694915 }
},
{
v1: { x: 295, y: 149.4915254237288 },
v2: { x: 214, y: 149.4915254237288 }
},
{
v1: { x: 266.6666666666667, y: 41.52542372881356 },
v2: { x: 242.33333333333334, y: 41.52542372881356 }
}
]);
});

});
});
11 changes: 8 additions & 3 deletions projects/swimlane/ngx-charts/src/lib/box-chart/box.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function cloneLineCoordinates(original: LineCoordinates): LineCoordinates
cloneVector2d(original[1]),
cloneVector2d(original[2]),
cloneVector2d(original[3])
]
];
}

@Component({
Expand Down Expand Up @@ -311,8 +311,13 @@ export class BoxComponent implements OnChanges {

const lineCoordinates: LineCoordinates = cloneLineCoordinates(this.lineCoordinates);

lineCoordinates[1].v1.y = lineCoordinates[1].v2.y = lineCoordinates[3].v1.y = lineCoordinates[3].v2.y = lineCoordinates[0].v1.y = lineCoordinates[0].v2.y =
lineCoordinates[2].v1.y;
lineCoordinates[1].v1.y =
lineCoordinates[1].v2.y =
lineCoordinates[3].v1.y =
lineCoordinates[3].v2.y =
lineCoordinates[0].v1.y =
lineCoordinates[0].v2.y =
lineCoordinates[2].v1.y;

return lineCoordinates;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,8 @@ describe('<ngx-charts-advanced-legend>', () => {

const labelElement = fixture.debugElement.nativeElement.querySelector('.total-label');
const roundedTotalElement = fixture.debugElement.nativeElement.querySelector('.advanced-pie-legend').children[0];
const {
legendItemsElements,
legendItemValueElements,
legendItemLabelElements,
legendItemPercentElements
} = loadLegendItemElements(fixture);
const { legendItemsElements, legendItemValueElements, legendItemLabelElements, legendItemPercentElements } =
loadLegendItemElements(fixture);

expect(labelElement).toBeDefined();
expect(roundedTotalElement).toBeDefined();
Expand Down Expand Up @@ -117,12 +113,8 @@ describe('<ngx-charts-advanced-legend>', () => {
component.percentageFormatting = percentage => Math.round(percentage);
fixture.detectChanges();

const {
legendItemsElements,
legendItemValueElements,
legendItemLabelElements,
legendItemPercentElements
} = loadLegendItemElements(fixture);
const { legendItemsElements, legendItemValueElements, legendItemLabelElements, legendItemPercentElements } =
loadLegendItemElements(fixture);

expect(legendItemsElements.childElementCount).toBe(6);
expect(Array.from(legendItemValueElements).map((x: Element) => x.textContent.trim())).toEqual([
Expand Down Expand Up @@ -155,9 +147,8 @@ describe('<ngx-charts-advanced-legend>', () => {
const legendItemsElements = fixture.debugElement.nativeElement.querySelector('.legend-items');
const legendItemValueElements = fixture.debugElement.nativeElement.querySelectorAll('.legend-items .item-value');
const legendItemLabelElements = fixture.debugElement.nativeElement.querySelectorAll('.legend-items .item-label');
const legendItemPercentElements = fixture.debugElement.nativeElement.querySelectorAll(
'.legend-items .item-percent'
);
const legendItemPercentElements =
fixture.debugElement.nativeElement.querySelectorAll('.legend-items .item-percent');
return {
legendItemsElements,
legendItemValueElements,
Expand Down
2 changes: 1 addition & 1 deletion projects/swimlane/ngx-charts/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": [],
"types": []
},
"exclude": ["src/test.ts", "**/*.spec.ts"]
}

0 comments on commit 191ace5

Please sign in to comment.