in src/gantt.ts [1312:1360]
public static converter(
dataView: DataView,
host: IVisualHost,
colors: IColorPalette,
colorHelper: ColorHelper,
localizationManager: ILocalizationManager): GanttViewModel {
if (!dataView
|| !dataView.categorical
|| !Gantt.isChartHasTask(dataView)
|| dataView.categorical.categories.length === 0) {
return null;
}
const settings: GanttSettings = this.parseSettings(dataView, colorHelper);
const taskTypes: TaskTypes = Gantt.getAllTasksTypes(dataView);
const formatters: GanttChartFormatters = this.getFormatters(dataView, settings, host.locale || null);
const isDurationFilled: boolean = _.findIndex(dataView.metadata.columns, col => col.roles.hasOwnProperty(GanttRoles.Duration)) !== -1,
isEndDateFillled: boolean = _.findIndex(dataView.metadata.columns, col => col.roles.hasOwnProperty(GanttRoles.EndDate)) !== -1,
isParentFilled: boolean = _.findIndex(dataView.metadata.columns, col => col.roles.hasOwnProperty(GanttRoles.Parent)) !== -1,
isResourcesFilled: boolean = _.findIndex(dataView.metadata.columns, col => col.roles.hasOwnProperty(GanttRoles.Resource)) !== -1;
const legendData: LegendData = Gantt.createLegend(host, colors, settings, taskTypes, !isDurationFilled && !isEndDateFillled);
const milestonesData: MilestoneData = Gantt.createMilestones(dataView, host);
let taskColor: string = (legendData.dataPoints.length <= 1) || !isDurationFilled
? settings.taskConfig.fill
: null;
const tasks: Task[] = Gantt.createTasks(dataView, taskTypes, host, formatters, colors, settings, taskColor, localizationManager, isEndDateFillled);
// Remove empty legend if tasks isn't exist
const types = _.groupBy(tasks, x => x.taskType);
legendData.dataPoints = legendData.dataPoints.filter(x => types[x.label]);
return {
dataView,
settings,
taskTypes,
tasks,
legendData,
milestonesData,
isDurationFilled,
isEndDateFillled,
isParentFilled,
isResourcesFilled
};
}