本文整理汇总了TypeScript中app/core/table_model.mergeTablesIntoModel函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mergeTablesIntoModel函数的具体用法?TypeScript mergeTablesIntoModel怎么用?TypeScript mergeTablesIntoModel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mergeTablesIntoModel函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: calculateResultsFromQueryTransactions
export function calculateResultsFromQueryTransactions(
queryTransactions: QueryTransaction[],
datasource: any,
graphInterval: number
) {
const graphResult = _.flatten(
queryTransactions.filter(qt => qt.resultType === 'Graph' && qt.done && qt.result).map(qt => qt.result)
);
const tableResult = mergeTablesIntoModel(
new TableModel(),
...queryTransactions.filter(qt => qt.resultType === 'Table' && qt.done && qt.result).map(qt => qt.result)
);
const logsResult =
datasource && datasource.mergeStreams
? datasource.mergeStreams(
_.flatten(
queryTransactions.filter(qt => qt.resultType === 'Logs' && qt.done && qt.result).map(qt => qt.result)
),
graphInterval
)
: undefined;
return {
graphResult,
tableResult,
logsResult,
};
}
示例2: it
it('should return 1 row for a single table', () => {
const table = mergeTablesIntoModel(new TableModel(), singleTable);
expect(table.rows.length).toBe(1);
expect(table.rows[0][0]).toBe(time);
expect(table.rows[0][1]).toBe('Label Value 1');
expect(table.rows[0][2]).toBe(42);
});
示例3: calculateResultsFromQueryTransactions
export function calculateResultsFromQueryTransactions(
queryTransactions: QueryTransaction[],
datasource: any,
graphInterval: number
) {
const graphResult = _.flatten(
queryTransactions.filter(qt => qt.resultType === 'Graph' && qt.done && qt.result).map(qt => qt.result)
);
const tableResult = mergeTablesIntoModel(
new TableModel(),
...queryTransactions
.filter(qt => qt.resultType === 'Table' && qt.done && qt.result && qt.result.columns && qt.result.rows)
.map(qt => qt.result)
);
const logsResult = seriesDataToLogsModel(
_.flatten(
queryTransactions.filter(qt => qt.resultType === 'Logs' && qt.done && qt.result).map(qt => qt.result)
).map(r => guessFieldTypes(toSeriesData(r))),
graphInterval
);
return {
graphResult,
tableResult,
logsResult,
};
}
示例4: calculateResultsFromQueryTransactions
export function calculateResultsFromQueryTransactions(result: any, resultType: ResultType, graphInterval: number) {
const flattenedResult: any[] = _.flatten(result);
const graphResult = resultType === 'Graph' && result ? result : null;
const tableResult =
resultType === 'Table' && result
? mergeTablesIntoModel(
new TableModel(),
...flattenedResult.filter((r: any) => r.columns && r.rows).map((r: any) => r as TableModel)
)
: mergeTablesIntoModel(new TableModel());
const logsResult =
resultType === 'Logs' && result
? seriesDataToLogsModel(flattenedResult.map(r => guessFieldTypes(toSeriesData(r))), graphInterval)
: null;
return {
graphResult,
tableResult,
logsResult,
};
}
示例5: mergeTablesIntoModel
transform: (data: any[], panel, model) => {
if (!data || data.length === 0) {
return;
}
const noTableIndex = _.findIndex(data, d => 'columns' in d && 'rows' in d);
if (noTableIndex < 0) {
throw {
message: `Result of query #${String.fromCharCode(
65 + noTableIndex
)} is not in table format, try using another transform.`,
};
}
mergeTablesIntoModel(model, ...data);
},