Exemple #1
0
  initColumns() {
    this.formatters = [];
    this.colorState = {};

    for (let colIndex = 0; colIndex < this.table.columns.length; colIndex++) {
      const column = this.table.columns[colIndex];
      column.title = column.text;

      for (let i = 0; i < this.panel.styles.length; i++) {
        const style = this.panel.styles[i];

        const regex = kbn.stringToJsRegex(style.pattern);
        if (column.text.match(regex)) {
          column.style = style;

          if (style.alias) {
            column.title = column.text.replace(regex, style.alias);
          }

          break;
        }
      }

      this.formatters[colIndex] = this.createColumnFormatter(column);
    }
  }
Exemple #2
0
function matchSeriesOverride(aliasOrRegex, seriesAlias) {
  if (!aliasOrRegex) { return false; }

  if (aliasOrRegex[0] === '/') {
    var regex = kbn.stringToJsRegex(aliasOrRegex);
    return seriesAlias.match(regex) != null;
  }

  return aliasOrRegex === seriesAlias;
}
Exemple #3
0
function applyAliasing(panel, model){
  if (!panel.styles) {
    return;
  }
  var hash = [];
  for (var i = 0; i < model.columns.length; i++) {
    for (var j = 0; j < panel.styles.length; j++) {
      var regex = kbn.stringToJsRegex(panel.styles[j].pattern);
      if (model.columns[i].text.match(regex)) {
        if (!hash[i]) {
          model.columns[i].alias = panel.styles[j].alias ? model.columns[i].text.replace(regex, panel.styles[j].alias) : '';
          hash[i] = model.columns[i].alias;
        }
      }
    }
  }
}
Exemple #4
0
  formatColumnValue(colIndex, value) {
    if (this.formaters[colIndex]) {
      return this.formaters[colIndex](value);
    }

    for (let i = 0; i < this.panel.styles.length; i++) {
      let style = this.panel.styles[i];
      let column = this.table.columns[colIndex];
      var regex = kbn.stringToJsRegex(style.pattern);
      if (column.text.match(regex)) {
        this.formaters[colIndex] = this.createColumnFormater(style);
        return this.formaters[colIndex](value);
      }
    }

    this.formaters[colIndex] = this.defaultCellFormater;
    return this.formaters[colIndex](value);
  }
Exemple #5
0
      return v => {
        if (v === undefined || v === null) {
          return '-';
        }

        if (column.style.textMappings && column.style.colorMode) {
          for (let i = 0; i < column.style.textMappings.length; i++) {
            let mapping = column.style.textMappings[i];
            var regex = kbn.stringToJsRegex(mapping.text);
            if (v.match(regex)) {
              this.colorState[column.style.colorMode] = this.getColorForValue(mapping.value, column.style);
              break;
            }
          }
        }

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