当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript table_model.mergeTablesIntoModel函数代码示例

本文整理汇总了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,
  };
}
开发者ID:acedrew,项目名称:grafana,代码行数:28,代码来源:explore.ts

示例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);
 });
开发者ID:CorpGlory,项目名称:grafana,代码行数:7,代码来源:table_model.test.ts

示例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,
  };
}
开发者ID:johntdyer,项目名称:grafana,代码行数:27,代码来源:explore.ts

示例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,
  };
}
开发者ID:grafana,项目名称:grafana,代码行数:21,代码来源:explore.ts

示例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);
  },
开发者ID:grafana,项目名称:grafana,代码行数:15,代码来源:transformers.ts


注:本文中的app/core/table_model.mergeTablesIntoModel函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。