Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
fix(event-chart): Fixes various issues with the legend and heatfields.
Browse files Browse the repository at this point in the history
  • Loading branch information
ffriedl89 committed May 27, 2021
1 parent a3ed931 commit c617d0a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
16 changes: 16 additions & 0 deletions apps/dev/src/event-chart/easy-travel-test-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,22 @@ export class EasyTravelDataSource implements EventChartDemoDataSource {
},
color: 'error',
},
{
start: 2000,
end: 2000,
data: {
page: '/cart/asdf3',
pageGroup: '/cart',
},
},
{
start: 2000,
end: 2000,
data: {
page: '/cart/asdf1',
pageGroup: '/cart',
},
},
{
start: 2000,
end: 3000,
Expand Down
2 changes: 1 addition & 1 deletion libs/barista-components/event-chart/src/event-chart.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="dt-event-chart-container">
<div
class="dt-event-chart-lane-labels"
[style.margin-top]="hasHeatfields ? FIELDS_OFFSET : 0"
[style.margin-top.px]="hasHeatfields ? FIELDS_OFFSET : 0"
#laneLabels
>
<div *ngFor="let lane of _lanesReversed" class="dt-event-chart-lane-label">
Expand Down
10 changes: 7 additions & 3 deletions libs/barista-components/event-chart/src/event-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -972,16 +972,20 @@ export class DtEventChart<T> implements AfterContentInit, OnInit, OnDestroy {
color = field.color;
}

const length = x2 - x1;

renderFields.push({
x1,
x2,
x1: length >= 3 ? x1 : x1 - (3 - length),
x2: length >= 3 ? x2 : x2 + (3 - length),
y: FIELD_BUBBLE_SIZE,
color,
fields: [field],
});
}

this._renderFields = dtEventChartMergeFields<T>(renderFields, 0);
this._renderFields = dtEventChartMergeFields<T>(renderFields).sort(
(a, b) => b.x2 - b.x1 - (a.x2 - a.x1),
);
}

/** Generates and updates the path that connects all the render events. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
import { isDefined } from '@dynatrace/barista-components/core';
import { RenderEvent } from '../render-event.interface';

export function dtCreateEventPath<T>(renderEvents: RenderEvent<T>[]): string {
export function dtCreateEventPath<T>(
renderEvents: RenderEvent<T>[],
): string | null {
if (renderEvents.length === 0) {
return null;
}

const svgPath: string[] = [];

// Move to the start point
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export function dtEventChartMergeEvents<T>(

export function dtEventChartMergeFields<T>(
renderEvents: MergedRenderField<T>[],
overlapThreshold: number,
): RenderField<T>[] {
// Loop over the rendered fields to merge points if necessary.
for (let index = 0; index < renderEvents.length; index += 1) {
Expand All @@ -142,11 +141,9 @@ export function dtEventChartMergeFields<T>(
eligableIndex += 1
) {
const eligableEvent: MergedRenderField<T> = renderEvents[eligableIndex];
const isOverlapping = dtEventChartIsOverlappingEvent(
currentEvent,
eligableEvent,
overlapThreshold,
);
const isOverlapping =
currentEvent.x1 === eligableEvent.x1 &&
currentEvent.x2 === eligableEvent.x2;
const hasSameColor = currentEvent.color === eligableEvent.color;

// If the lane is the same, but the fields do not overlap, there will be no more overlaps
Expand Down

0 comments on commit c617d0a

Please sign in to comment.