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


TypeScript ui.getValueFormat函数代码示例

本文整理汇总了TypeScript中@grafana/ui.getValueFormat函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getValueFormat函数的具体用法?TypeScript getValueFormat怎么用?TypeScript getValueFormat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getValueFormat函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getValueFormat

 return value => {
   try {
     return format !== 'none' ? getValueFormat(format)(value, decimals, scaledDecimals) : value;
   } catch (err) {
     console.error(err.message || err);
     return value;
   }
 };
开发者ID:CorpGlory,项目名称:grafana,代码行数:8,代码来源:rendering.ts

示例2: getValueFormat

    axis.tickFormatter = (val, axis) => {
      const formatter = getValueFormat(format);

      if (!formatter) {
        throw new Error(`Unit '${format}' is not supported`);
      }
      return formatter(val, axis.tickDecimals, axis.scaledDecimals);
    };
开发者ID:CorpGlory,项目名称:grafana,代码行数:8,代码来源:graph.ts

示例3: constructor

 constructor(opts) {
   this.datapoints = opts.datapoints;
   this.label = opts.alias;
   this.id = opts.alias;
   this.alias = opts.alias;
   this.aliasEscaped = _.escape(opts.alias);
   this.color = opts.color;
   this.bars = { fillColor: opts.color };
   this.valueFormater = getValueFormat('none');
   this.stats = {};
   this.legend = true;
   this.unit = opts.unit;
   this.hasMsResolution = this.isMsResolutionNeeded();
 }
开发者ID:CorpGlory,项目名称:grafana,代码行数:14,代码来源:time_series2.ts

示例4: updateLegendValues

export function updateLegendValues(data: TimeSeries[], panel, height) {
  for (let i = 0; i < data.length; i++) {
    const series = data[i];
    const yaxes = panel.yaxes;
    const seriesYAxis = series.yaxis || 1;
    const axis = yaxes[seriesYAxis - 1];
    const formatter = getValueFormat(axis.format);

    // decimal override
    if (_.isNumber(panel.decimals)) {
      series.updateLegendValues(formatter, panel.decimals, null);
    } else if (_.isNumber(axis.decimals)) {
      series.updateLegendValues(formatter, axis.decimals + 1, null);
    } else {
      // auto decimals
      // legend and tooltip gets one more decimal precision
      // than graph legend ticks
      const { datamin, datamax } = getDataMinMax(data);
      const { tickDecimals, scaledDecimals } = getFlotTickDecimals(datamin, datamax, axis, height);
      const tickDecimalsPlusOne = (tickDecimals || -1) + 1;
      series.updateLegendValues(formatter, tickDecimalsPlusOne, scaledDecimals + 2);
    }
  }
}
开发者ID:CorpGlory,项目名称:grafana,代码行数:24,代码来源:time_series2.ts

示例5: getValueFormats

///// FORMAT MENU /////

kbn.getUnitFormats = () => {
  return getValueFormats();
};

//
// Backward compatible layer for value formats to support old plugins
//
if (typeof Proxy !== 'undefined') {
  kbn.valueFormats = new Proxy(kbn.valueFormats, {
    get(target, name, receiver) {
      if (typeof name !== 'string') {
        throw { message: `Value format ${String(name)} is not a string` };
      }

      const formatter = getValueFormat(name);
      if (formatter) {
        return formatter;
      }

      // default to look here
      return Reflect.get(target, name, receiver);
    },
  });
} else {
  kbn.valueFormats = getValueFormatterIndex();
}

export default kbn;
开发者ID:johntdyer,项目名称:grafana,代码行数:30,代码来源:kbn.ts

示例6: createColumnFormatter

  createColumnFormatter(column) {
    if (!column.style) {
      return this.defaultCellFormatter;
    }

    if (column.style.type === 'hidden') {
      return v => {
        return undefined;
      };
    }

    if (column.style.type === 'date') {
      return v => {
        if (v === undefined || v === null) {
          return '-';
        }

        if (_.isArray(v)) {
          v = v[0];
        }

        // if is an epoch (numeric string and len > 12)
        if (_.isString(v) && !isNaN(v as any) && v.length > 12) {
          v = parseInt(v, 10);
        }

        let date = dateTime(v);

        if (this.isUtc) {
          date = date.utc();
        }

        return date.format(column.style.dateFormat);
      };
    }

    if (column.style.type === 'string') {
      return v => {
        if (_.isArray(v)) {
          v = v.join(', ');
        }

        const mappingType = column.style.mappingType || 0;

        if (mappingType === 1 && column.style.valueMaps) {
          for (let i = 0; i < column.style.valueMaps.length; i++) {
            const map = column.style.valueMaps[i];

            if (v === null) {
              if (map.value === 'null') {
                return map.text;
              }
              continue;
            }

            // Allow both numeric and string values to be mapped
            if ((!_.isString(v) && Number(map.value) === Number(v)) || map.value === v) {
              this.setColorState(v, column.style);
              return this.defaultCellFormatter(map.text, column.style);
            }
          }
        }

        if (mappingType === 2 && column.style.rangeMaps) {
          for (let i = 0; i < column.style.rangeMaps.length; i++) {
            const map = column.style.rangeMaps[i];

            if (v === null) {
              if (map.from === 'null' && map.to === 'null') {
                return map.text;
              }
              continue;
            }

            if (Number(map.from) <= Number(v) && Number(map.to) >= Number(v)) {
              this.setColorState(v, column.style);
              return this.defaultCellFormatter(map.text, column.style);
            }
          }
        }

        if (v === null || v === void 0) {
          return '-';
        }

        this.setColorState(v, column.style);
        return this.defaultCellFormatter(v, column.style);
      };
    }

    if (column.style.type === 'number') {
      const valueFormatter = getValueFormat(column.unit || column.style.unit);

      return v => {
        if (v === null || v === void 0) {
          return '-';
        }

        if (isNaN(v) || _.isArray(v)) {
          return this.defaultCellFormatter(v, column.style);
//.........这里部分代码省略.........
开发者ID:grafana,项目名称:grafana,代码行数:101,代码来源:renderer.ts

示例7: getValueFormat

 return value => {
   return getValueFormat(format)(value, decimals, scaledDecimals);
 };
开发者ID:grafana,项目名称:grafana,代码行数:3,代码来源:heatmap_tooltip.ts


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