in src/gantt.ts [402:491]
private createViewport(element: HTMLElement): void {
let self = this;
const isHighContrast: boolean = this.colorHelper.isHighContrast;
const axisBackgroundColor: string = this.colorHelper.getThemeColor();
// create div container to the whole viewport area
this.ganttDiv = this.body.append("div")
.classed(Selectors.Body.className, true);
// create container to the svg area
this.ganttSvg = this.ganttDiv
.append("svg")
.classed(Selectors.ClassName.className, true);
// create clear catcher
this.clearCatcher = appendClearCatcher(this.ganttSvg);
// create chart container
this.chartGroup = this.ganttSvg
.append("g")
.classed(Selectors.Chart.className, true);
// create tasks container
this.taskGroup = this.chartGroup
.append("g")
.classed(Selectors.Tasks.className, true);
// create tasks container
this.taskGroup = this.chartGroup
.append("g")
.classed(Selectors.Tasks.className, true);
// create axis container
this.axisGroup = this.ganttSvg
.append("g")
.classed(Selectors.AxisGroup.className, true);
this.axisGroup
.append("rect")
.attr("width", "100%")
.attr("y", "-20")
.attr("height", "40px")
.attr("fill", axisBackgroundColor);
// create task lines container
this.lineGroup = this.ganttSvg
.append("g")
.classed(Selectors.TaskLines.className, true);
this.lineGroupWrapper = this.lineGroup
.append("rect")
.classed(Selectors.TaskLinesRect.className, true)
.attr("height", "100%")
.attr("width", "0")
.attr("fill", axisBackgroundColor)
.attr("y", this.margin.top);
this.lineGroup
.append("rect")
.classed(Selectors.TaskTopLine.className, true)
.attr("width", "100%")
.attr("height", 1)
.attr("y", this.margin.top)
.attr("fill", this.colorHelper.getHighContrastColor("foreground", Gantt.DefaultValues.TaskLineColor));
this.collapseAllGroup = this.lineGroup
.append("g")
.classed(Selectors.CollapseAll.className, true);
// create legend container
const interactiveBehavior: IInteractiveBehavior = this.colorHelper.isHighContrast ? new OpacityLegendBehavior() : null;
this.legend = createLegend(
element,
this.isInteractiveChart,
this.interactivityService,
true,
LegendPosition.Top,
interactiveBehavior);
this.ganttDiv.on("scroll", function (evt) {
if (self.viewModel) {
const taskLabelsWidth: number = self.viewModel.settings.taskLabels.show
? self.viewModel.settings.taskLabels.width
: 0;
self.axisGroup
.attr("transform", SVGManipulations.translate(taskLabelsWidth + self.margin.left + Gantt.SubtasksLeftMargin, Gantt.TaskLabelsMarginTop + this.scrollTop));
self.lineGroup
.attr("transform", SVGManipulations.translate(this.scrollLeft, 0))
.attr("height", 20);
}
}, false);
}