-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add lost event layer to timeline-chart
Signed-off-by: Ankush Tyagi <ankush.tyagi@ericsson.com>
- Loading branch information
1 parent
e0da58a
commit ceff78b
Showing
8 changed files
with
204 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { TimeGraphAnnotationComponent } from "../components/time-graph-annotation"; | ||
import { TimelineChart } from "../time-graph-model"; | ||
import { TimeGraphRowController } from "../time-graph-row-controller"; | ||
import { TimeGraphChartProviders } from "./time-graph-chart"; | ||
import { TimeGraphChartLayer } from "./time-graph-chart-layer"; | ||
|
||
export class TimeGraphChartRangeEvents extends TimeGraphChartLayer { | ||
|
||
|
||
protected rangeEvents: Map<TimelineChart.TimeGraphAnnotation, TimeGraphAnnotationComponent>; | ||
private _updateHandler: { (): void; (viewRange: TimelineChart.TimeGraphRange): void; (viewRange: TimelineChart.TimeGraphRange): void; }; | ||
protected providers: TimeGraphChartProviders; | ||
|
||
constructor(id: string, providers: TimeGraphChartProviders, rowController: TimeGraphRowController){ | ||
super(id,rowController); | ||
this.providers = providers; | ||
} | ||
|
||
protected afterAddToContainer() { | ||
this._updateHandler = (): void => this.update(); | ||
this.unitController.onViewRangeChanged(this._updateHandler); | ||
} | ||
|
||
protected addRangeEvent(rangeEvent: TimelineChart.TimeGraphAnnotation) { | ||
const width = this.getPixels(rangeEvent.range.end - rangeEvent.range.start); | ||
const height = this.stateController.canvasDisplayHeight; | ||
let rangeEventComponent: TimeGraphAnnotationComponent | undefined; | ||
const elementStyle = this.providers.rowAnnotationStyleProvider ? this.providers.rowAnnotationStyleProvider(rangeEvent) : undefined; | ||
rangeEventComponent = new TimeGraphAnnotationComponent(rangeEvent.id, { position: { x: this.getPixels(rangeEvent.range.start - this.unitController.viewRange.start), y: 0 }, width, height }, elementStyle); | ||
this.rangeEvents.set(rangeEvent, rangeEventComponent); | ||
this.addChild(rangeEventComponent); | ||
} | ||
|
||
addRangeEvents(rangeEvents: TimelineChart.TimeGraphAnnotation[]): void { | ||
if (!this.stateController) { | ||
throw ('Add this TimeGraphChartArrows to a container before adding arrows.'); | ||
} | ||
if (this.rangeEvents) { | ||
this.removeChildren(); | ||
} | ||
this.rangeEvents = new Map(); | ||
rangeEvents.forEach(rangeEvent => { | ||
this.addRangeEvent(rangeEvent); | ||
}) | ||
} | ||
|
||
update(): void { | ||
if (this.rangeEvents) { | ||
for (const rangeEvent of this.rangeEvents.keys()) { | ||
this.updateRangeEvent(rangeEvent); | ||
} | ||
} | ||
} | ||
|
||
protected updateRangeEvent(rangeEvent: TimelineChart.TimeGraphAnnotation) { | ||
const rangeEventComponent = this.rangeEvents.get(rangeEvent); | ||
const width = this.getPixels(rangeEvent.range.end - rangeEvent.range.start); | ||
const height = this.stateController.canvasDisplayHeight; | ||
if (rangeEventComponent) { | ||
rangeEventComponent.update({ position: { x: this.getPixels(rangeEvent.range.start - this.unitController.viewRange.start), y: 0 }, width, height }); | ||
} | ||
} | ||
|
||
destroy(): void { | ||
if (this.unitController) { | ||
this.unitController.removeViewRangeChangedHandler(this._updateHandler); | ||
} | ||
super.destroy(); | ||
} | ||
} |
Oops, something went wrong.