How to use the @grafana/ui.getValueFormat function in @grafana/ui

To help you get started, we’ve selected a few @grafana/ui examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github grafana / grafana / public / app / plugins / panel / heatmap / rendering.ts View on Github external
return value => {
      try {
        return format !== 'none' ? getValueFormat(format)(value, decimals, scaledDecimals) : value;
      } catch (err) {
        console.error(err.message || err);
        return value;
      }
    };
  }
github replicatedhq / kots / web / src / components / apps / Dashboard.jsx View on Github external
getValue = (chart, value) => {
    let yAxisTickFormat = null;
    if (chart.tickFormat) {
      const valueFormatter = getValueFormat(chart.tickFormat);
      yAxisTickFormat = (v) => `${valueFormatter(v)}`;
      return yAxisTickFormat(value);
    } else if (chart.tickTemplate) {
      try {
        const template = Handlebars.compile(chart.tickTemplate);
        yAxisTickFormat = (v) => `${template({ values: v })}`;
        return yAxisTickFormat(value);
      } catch (err) {
        console.error("Failed to compile y axis tick template", err);
      }
    } else {
      return value.toFixed(5);
    }
  }
github grafana / grafana / public / app / plugins / panel / table / renderer.ts View on Github external
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);
        }

        this.setColorState(v, column.style);
        return valueFormatter(v, column.style.decimals, null);
      };
    }

    return value => {
github OpenNMS / opennms-helm / src / panels / alarm-table / renderer.js View on Github external
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);
        }

        this.setColorState(v, column.style);
        return valueFormatter(v, column.style.decimals, null);
      };
    }

    if (column.style.type === 'severity') {
github pierosavi / pierosavi-imageit-panel / src / imageit_ctrl.js View on Github external
sensor.isBold = valueMapping.isSensorFontBold;

                            break;
                        } else {
                            normalizeSensor(sensor);
                        }
                    }
                } else {
                    normalizeSensor(sensor);
                }

                if (metricValue === undefined) {
                    sensor.valueFormatted = 'Select a sensor metric';
                } else {
                    const formatFunc = getValueFormat(sensor.unitFormat);
                    sensor.valueFormatted = formatFunc(metricValue, sensor.decimals);
                }
            }

            dragEventSetup();
        }