pddl-gantt
Version:
Plan visualization for AI-Planning plans. The package includes HTML components for Gantt, swimlane and line plot visualization of plan originating from AI Planning solvers.
88 lines (87 loc) • 3.7 kB
TypeScript
import { VariableValue } from "pddl-workspace";
import { DomainInfo, Plan, PlanStep } from "pddl-workspace";
import { DomainVizConfiguration } from "./DomainVizConfiguration";
export interface PlanViewOptions {
epsilon: number;
displayWidth: number;
disableSwimlanes?: boolean;
disableLinePlots?: boolean;
selfContained?: boolean;
onActionSelected?: (actionName: string) => void;
onHelpfulActionSelected?: (actionName: string) => void;
onLinePlotsVisible?: (planView: PlanView) => void;
onFinalStateVisible?: (planView: PlanView) => void;
}
export declare const DIGITS = 4;
export declare function getHostElement(hostElementId: string): HTMLElement;
export declare class View {
protected readonly options: PlanViewOptions;
protected readonly host: HTMLElement;
constructor(hostElement: HTMLDivElement, options: PlanViewOptions);
/**
* Sets new display width. Does not trigger (re-)drawing.
* @param displayWidth new width in pixels, the width is used to fit all gantt chart bars (not necessarily the labels next to them)
*/
setDisplayWidth(displayWidth: number): void;
protected getOrCreateBlankChildElement(className: string): HTMLDivElement;
private createChildElement;
}
export declare const ATTR_PLAN = "plan";
export declare const PLAN_VIEW_CLASS = "planView";
/** Single-plan view. */
export declare class PlanView extends View {
readonly planIndex: number;
private planStepHeight;
private lineCharts;
private handleScrollEvent;
private linePlotsGenerated;
private plan;
private customVisualization;
private visible;
constructor(hostElement: HTMLDivElement, planIndex: number, options: PlanViewOptions);
clear(): void;
setVisible(visible: boolean): void;
showPlan(plan: Plan, configuration?: DomainVizConfiguration): void;
private tryVisualizePlan;
addError(planVizDiv: HTMLDivElement, ex: string): void;
private visualizePlan;
showPlanLinePlots(title: string, yAxisUnit: string, objects: string[], data: (number | null)[][]): void;
showFinalState(finalState: VariableValue[]): void;
private showGantt;
private renderGanttStep;
private renderHelpfulActions;
private renderHelpfulAction;
private static getActionSuffix;
private computeLeftOffset;
/** Converts the _time_ argument to view coordinates */
private toViewCoordinates;
private toActionLink;
private toActionTooltip;
private toActionTooltipPlain;
private computePlanHeadDuration;
private computeWidth;
private computeRelaxedWidth;
private isPlanHeadStep;
private static shouldDisplay;
static shouldDisplayObject(step: PlanStep, obj: string, domain?: DomainInfo, configuration?: DomainVizConfiguration): boolean;
private getActionColor;
private colors;
private showSwimLanes;
private renderTypeSwimLanes;
private renderObjectSwimLane;
private renderSwimLaneStep;
/**
* Line plots get populated lazily, when they get scrolled to the view.
* @param lineCharts line chart element
* @param plan plan being displayed
*/
private activateLinePlotPlaceholder;
/** Removes the scroll events to avoid generating charts for plans that have been cleared from the view */
private deactivateLinePlotPlaceholder;
private addLoader;
hideLinePlotLoadingProgress(): void;
private addLinePlot;
}
export declare function px(valueInPx: number): string;
export declare function createPlanView(hostElementId: string, options: PlanViewOptions): PlanView;
export declare function appendPlanView(parent: HTMLDivElement, planIndex: number, options: PlanViewOptions): PlanView;