@grafana/data#DataTransformerID TypeScript Examples

The following examples show how to use @grafana/data#DataTransformerID. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransformationsEditor.tsx    From grafana-chinese with Apache License 2.0 6 votes vote down vote up
onTransformationAdd = () => {
    const { transformations, onChange } = this.props;
    onChange([
      ...transformations,
      {
        id: DataTransformerID.noop,
        options: {},
      },
    ]);
    this.setState({ updateCounter: this.state.updateCounter + 1 });
  };
Example #2
Source File: FilterByNameTransformerEditor.tsx    From grafana-chinese with Apache License 2.0 5 votes vote down vote up
filterFieldsByNameTransformRegistryItem: TransformerUIRegistyItem<FilterFieldsByNameTransformerOptions> = {
  id: DataTransformerID.filterFieldsByName,
  component: FilterByNameTransformerEditor,
  transformer: transformersRegistry.get(DataTransformerID.filterFieldsByName),
  name: 'Filter by name',
  description: 'UI for filter by name transformation',
}
Example #3
Source File: FilterByRefIdTransformerEditor.tsx    From grafana-chinese with Apache License 2.0 5 votes vote down vote up
filterFramesByRefIdTransformRegistryItem: TransformerUIRegistyItem<FilterFramesByRefIdTransformerOptions> = {
  id: DataTransformerID.filterByRefId,
  component: FilterByRefIdTransformerEditor,
  transformer: transformersRegistry.get(DataTransformerID.filterByRefId),
  name: 'Filter by refId',
  description: 'Filter results by refId',
}
Example #4
Source File: ReduceTransformerEditor.tsx    From grafana-chinese with Apache License 2.0 5 votes vote down vote up
reduceTransformRegistryItem: TransformerUIRegistyItem<ReduceTransformerOptions> = {
  id: DataTransformerID.reduce,
  component: ReduceTransformerEditor,
  transformer: transformersRegistry.get(DataTransformerID.reduce),
  name: 'Reduce',
  description: 'UI for reduce transformation',
}
Example #5
Source File: TransformationsEditor.tsx    From grafana-chinese with Apache License 2.0 5 votes vote down vote up
renderTransformationEditors = () => {
    const { transformations, dataFrames } = this.props;
    const hasTransformations = transformations.length > 0;
    const preTransformData = dataFrames;

    if (!hasTransformations) {
      return undefined;
    }

    const availableTransformers = transformersUIRegistry.list().map(t => {
      return {
        value: t.transformer.id,
        label: t.transformer.name,
      };
    });

    return (
      <>
        {transformations.map((t, i) => {
          let editor, input;
          if (t.id === DataTransformerID.noop) {
            return (
              <Select
                className={css`
                  margin-bottom: 10px;
                `}
                key={`${t.id}-${i}`}
                options={availableTransformers}
                placeholder="Select transformation"
                onChange={v => {
                  this.onTransformationChange(i, {
                    id: v.value as string,
                    options: {},
                  });
                }}
              />
            );
          }
          const transformationUI = transformersUIRegistry.getIfExists(t.id);
          input = transformDataFrame(transformations.slice(0, i), preTransformData);

          if (transformationUI) {
            editor = React.createElement(transformationUI.component, {
              options: { ...transformationUI.transformer.defaultOptions, ...t.options },
              input,
              onChange: (options: any) => {
                this.onTransformationChange(i, {
                  id: t.id,
                  options,
                });
              },
            });
          }

          return (
            <TransformationRow
              key={`${t.id}-${i}`}
              input={input || []}
              onRemove={() => this.onTransformationRemove(i)}
              editor={editor}
              name={transformationUI ? transformationUI.name : ''}
              description={transformationUI ? transformationUI.description : ''}
            />
          );
        })}
      </>
    );
  };