Inline metrics(内联指标(Inline metrics))¶
Inline metrics provides application builders with a streamlined method for displaying key data directly in the chart.
- Header metrics are aligned with the timeline (x-axis) of the widget, offering high-level aggregations for the entire schedule.
- Row metrics are aligned with each row, providing insights into the scheduling and assignment of individual resource objects.

Functions signature¶
Inline metrics require functions that return a list of a custom type that matches the following shape:
interface InlineMetricsBucket {
range: IRange<Timestamp>;
value: Double
}
Inline metrics can support alternative return types as well.
// NOTE: The name of the interface is not important - only the names of the keys
interface InlineMetricsBucketInteger {
range: IRange<Timestamp>;
value: Integer
}
interface InlineMetricsBucketString {
range: IRange<LocalDate>;
value: string
}
The range key can support IRange types of Timestamp, LocalDate, or Integer (with numerical values representing epoch milliseconds).
The value key can support string, Integer, or Double values.
Sample header metric function¶
import { IRange, Double, Timestamp } from "@foundry/functions-api";
interface InlineMetricBucketV1Double {
range: IRange<Timestamp>;
value: Double;
}
// Counts the number of tasks within the given range bucketed by a step in days
@Function()
public getInlineMetricsV1WithObjectCounts(startTime: Timestamp, endTime: Timestamp, step: Double): Array<InlineMetricBucketV1Double> {
const tasks = Objects.search().schedulingMaintenanceTask().filter(x =>
x.startTime.range().gte(startTime).lte(endTime)
).all();
const buckets: InlineMetricBucketV1Double[] = [];
let current = startTime;
let count = 0
while (current < endTime) {
const currentEnd: Timestamp = current.plusDays(step);
const tasksInRange = tasks.filter(x => x.startTime! >= current && x.startTime! <= currentEnd);
buckets.push({
range: {
min: current,
max: currentEnd
},
value: tasksInRange.length
})
current = currentEnd;
count++;
}
return buckets
}
Since header metrics are displayed as a header alongside the x-axis, these functions are not necessarily tied to any specific objects as inputs.
Sample row metric function¶
// Returns the name of the row alongside the number bucket to which it belongs
@Function()
public getInlineMetricsV1StringWithObject(techs: ObjectSet<SchedulingTechnician_1>, startTime: Timestamp, endTime: Timestamp, step: Double): Array<InlineMetricBucketV1String> {
const techName = techs.all()[0].fullName;
const buckets: Array<InlineMetricBucketV1String> = [];
let current = startTime;
let count = 0;
while (current < endTime) {
const currentEnd: Timestamp = current.plusDays(step);
buckets.push({
range: {
min: current,
max: currentEnd
},
value: `${techName}-${count}`,
})
current = currentEnd;
count++;
}
return buckets
}
Row metrics accept the corresponding row object as runtime input. When specifying your function in the configuration, you can specify the object parameter as runtime input and the widget will automatically pass the corresponding row through to the function for you.

Widget configuration¶
The Scheduling Gantt Chart widget config has a Metrics section which includes options for header-level and row-level metrics.

Within the metric configuration setup, you can provide a display title, select an icon, and/or set up conditional coloring.

中文翻译¶
内联指标(Inline metrics)¶
内联指标为应用构建者提供了一种精简方法,可直接在图表中展示关键数据。
- 表头指标(Header metrics) 与组件的时间轴(x轴)对齐,提供整个计划的高层级聚合数据。
- 行指标(Row metrics) 与每一行对齐,提供单个资源对象的排程与分配洞察。

函数签名(Functions signature)¶
内联指标要求函数返回一个符合以下结构的自定义类型列表:
interface InlineMetricsBucket {
range: IRange<Timestamp>;
value: Double
}
内联指标也支持其他返回类型。
// 注意:接口名称不重要——只有键名重要
interface InlineMetricsBucketInteger {
range: IRange<Timestamp>;
value: Integer
}
interface InlineMetricsBucketString {
range: IRange<LocalDate>;
value: string
}
range 键支持 IRange 类型,其值可为 Timestamp、LocalDate 或 Integer(数值表示自纪元以来的毫秒数)。
value 键支持 string、Integer 或 Double 类型。
表头指标函数示例¶
import { IRange, Double, Timestamp } from "@foundry/functions-api";
interface InlineMetricBucketV1Double {
range: IRange<Timestamp>;
value: Double;
}
// 统计给定时间范围内,按天数分桶的任务数量
@Function()
public getInlineMetricsV1WithObjectCounts(startTime: Timestamp, endTime: Timestamp, step: Double): Array<InlineMetricBucketV1Double> {
const tasks = Objects.search().schedulingMaintenanceTask().filter(x =>
x.startTime.range().gte(startTime).lte(endTime)
).all();
const buckets: InlineMetricBucketV1Double[] = [];
let current = startTime;
let count = 0
while (current < endTime) {
const currentEnd: Timestamp = current.plusDays(step);
const tasksInRange = tasks.filter(x => x.startTime! >= current && x.startTime! <= currentEnd);
buckets.push({
range: {
min: current,
max: currentEnd
},
value: tasksInRange.length
})
current = currentEnd;
count++;
}
return buckets
}
由于表头指标作为表头与x轴对齐显示,这些函数不一定需要以特定对象作为输入。
行指标函数示例¶
// 返回行名称及其所属的数字桶
@Function()
public getInlineMetricsV1StringWithObject(techs: ObjectSet<SchedulingTechnician_1>, startTime: Timestamp, endTime: Timestamp, step: Double): Array<InlineMetricBucketV1String> {
const techName = techs.all()[0].fullName;
const buckets: Array<InlineMetricBucketV1String> = [];
let current = startTime;
let count = 0;
while (current < endTime) {
const currentEnd: Timestamp = current.plusDays(step);
buckets.push({
range: {
min: current,
max: currentEnd
},
value: `${techName}-${count}`,
})
current = currentEnd;
count++;
}
return buckets
}
行指标接受对应的行对象作为运行时输入。在配置中指定函数时,您可以将对象参数设为运行时输入,组件会自动将对应行传递给该函数。

组件配置(Widget configuration)¶
排程甘特图组件的配置中有一个指标(Metrics)部分,包含表头级和行级指标的选项。

在指标配置设置中,您可以提供显示标题、选择图标,以及/或设置条件着色。
