當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。