@grafana/data APIs
- SelectableValue
- DataQuery
- DataSourceJsonData
- PanelProps
- PanelPlugin
- DataFrame
- DataSourcePluginOptionsEditorProps
- DataSourceInstanceSettings
- FieldType
- DataSourcePlugin
- DataSourceApi
- MetricFindValue
- PanelEditorProps
- GrafanaTheme
- getDisplayProcessor
- DataQueryError
- DataQueryRequest
- DataQueryResponse
- MutableDataFrame
- ArrayVector
- LoadingState
- KeyValue
- AppPluginMeta
- PluginMeta
- AppPlugin
- NavModelItem
- ThresholdsMode
- DisplayValue
- formattedValueToString
- FieldConfig
- FieldColorMode
- GraphSeriesValue
- FieldDisplayOptions
- GraphSeriesXY
- TimeZone
- MS_DATE_TIME_FORMAT
- DEFAULT_DATE_TIME_FORMAT
- ReducerID
- AppEvents
- DataSourceSelectItem
- NullValueMode
- getFlotPairs
- getValueFormat
- AbsoluteTimeRange
- AnnotationEvent
- PanelData
- getTimeField
- reduceField
- getSeriesTimeStep
- hasMsResolution
- FieldColor
- MutableField
- AppRootProps
- GrafanaThemeType
- PanelPluginMeta
- ScopedVars
- PluginBuildInfo
- PluginState
- VizOrientation
- Field
- TimeSeriesValue
- FormattedValue
- DisplayValueAlignmentFactors
- getColorFromHexRgbOrName
- getColorDefinitionByName
- getNamedColorPalette
- getColorName
- getColorForTheme
- deprecationWarning
- DataLink
- VariableSuggestion
- VariableOrigin
- LinkModelSupplier
- DataSourceSettings
- applyFieldOverrides
- FieldConfigSource
- InterpolateFunction
- FieldMatcherID
- toDataFrame
- standardFieldConfigEditorRegistry
- FieldOverrideContext
- FieldConfigEditorProps
- FieldOverrideEditorProps
- ValueMapping
- toIntegerOrUndefined
- toFloatOrUndefined
- FieldPropertyEditorItem
- ThresholdsConfig
- getActiveThreshold
- Threshold
- dateTime
- TimeRange
- DefaultTimeZone
- createDimension
- DateTimeInput
- FlotDataPoint
- getValueFromDimension
- getColumnFromDimension
- FieldCache
- LogRowModel
- LogLevel
- calculateFieldStats
- calculateLogsLabelStats
- calculateStats
- getParser
- LinkModel
- Labels
- findHighlightChunksInText
- LogsDedupStrategy
- fieldMatchers
- Registry
- stringToMs
- DEFAULT_FIELD_DISPLAY_VALUES_LIMIT
- toNumberString
- VAR_SERIES_NAME
- VAR_FIELD_NAME
- VAR_CALC
- VAR_CELL_PREFIX
- fieldReducers
- sortThresholds
- MappingType
- PanelModel
- ConfigOverrideRule
- validateFieldConfig
- readCSV
- DateTime
- dateTimeAsMoment
- TimeFragment
- isDateTime
- rangeUtil
- TIME_FORMAT
- TimeOption
- dateMath
- dateTimeForTimeZone
- getTimeZoneGroups
- RawTimeRange
- FilterFieldsByNameTransformerOptions
- DataTransformerID
- transformersRegistry
- FilterFramesByRefIdTransformerOptions
- ReduceTransformerOptions
- DataTransformerConfig
- transformDataFrame
- getValueFormats
- GrafanaThemeCommons
- setLocale
- setMarkdownOptions
- escapeStringForRegex
- unEscapeStringFromRegex
- UserOrgDTO
- NavModel
- NavModelBreadcrumb
- renderMarkdown
- LogsMetaKind
- findCommonLabels
- findUniqueLabels
- getLogLevel
- getLogLevelFromKey
- LogsModel
- LogsMetaItem
- toUtc
- FieldWithIndex
- NavIndex
- PanelEvents
- OrgRole
- eventFactory
- TableData
- Column
- ValueFormatter
- stringToJsRegex
- DecimalCount
- AppEvent
- ExploreMode
- CoreApp
- HistoryItem
- IntervalValues
- toCSV
- DynamicConfigValue
- FieldConfigEditorRegistry
- VariableSuggestionsScope
- DefaultTimeRange
- toDataFrameDTO
- PanelMenuItem
- PluginType
- toLegacyResponseData
- DataQueryResponseData
- guessFieldTypes
- DataSourcePluginMeta
- DataSourceConstructor
- PluginInclude
- PluginMetaInfo
- toDuration
- LogsDedupDescription
- QueryFixAction
- TimeSeries
- LegacyResponseData
- AngularPanelMenuItem
- FieldDisplay
- DataFrameView
- GrafanaPlugin
- PluginDependencies
- PluginIncludeType
- onUpdateDatasourceJsonDataOptionSelect
- onUpdateDatasourceOption
- onUpdateDatasourceResetOption
- onUpdateDatasourceJsonDataOption
- onUpdateDatasourceSecureJsonDataOption
- updateDatasourcePluginOption
- updateDatasourcePluginResetOption
- updateDatasourcePluginJsonDataOption
- updateDatasourcePluginSecureJsonDataOption
- ExploreStartPageProps
- DataFrameDTO
- AnnotationQueryRequest
- LanguageProvider
- formatLabels
- parseLabels
- CircularDataFrame
- QueryHint
- isDataFrame
- QueryFix
- CSVReader
- DurationUnit
- getFieldDisplayValues
- getDisplayValueAlignmentFactors
- getFlotPairsConstant
- CreatePlotOverlay
- isTableData
- stringStartsAsRegEx
- base64StringToArrowTable
- arrowTableToDataFrame
- FieldConfigProperty
Other Related APIs
- @grafana/data#MutableDataFrame
- @grafana/data#FieldType
- @grafana/data#DataFrame
- @grafana/data#GrafanaTheme
- @grafana/data#FieldConfig
- @grafana/data#applyFieldOverrides
- @grafana/data#FieldConfigSource
- @grafana/data#FieldMatcherID
- @grafana/data#FieldDisplayOptions
- @grafana/data#toDataFrame
- @grafana/data#standardFieldConfigEditorRegistry
@grafana/data#InterpolateFunction TypeScript Examples
The following examples show how to use
@grafana/data#InterpolateFunction.
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: gfunc.ts From grafana-chinese with Apache License 2.0 | 6 votes |
render(metricExp: string, replaceVariables: InterpolateFunction): string {
const str = this.def.name + '(';
const parameters = _.map(this.params, (value, index) => {
let paramType;
if (index < this.def.params.length) {
paramType = this.def.params[index].type;
} else if (_.get(_.last(this.def.params), 'multiple')) {
paramType = _.get(_.last(this.def.params), 'type');
}
// param types that should never be quoted
if (_.includes(['value_or_series', 'boolean', 'int', 'float', 'node'], paramType)) {
return value;
}
const valueInterpolated = _.isString(value) ? replaceVariables(value) : value;
// param types that might be quoted
// To quote variables correctly we need to interpolate it to check if it contains a numeric or string value
if (_.includes(['int_or_interval', 'node_or_tag'], paramType) && _.isFinite(+valueInterpolated)) {
return _.toString(value);
}
return "'" + value + "'";
});
// don't send any blank parameters to graphite
while (parameters[parameters.length - 1] === '') {
parameters.pop();
}
if (metricExp) {
parameters.unshift(metricExp);
}
return str + parameters.join(', ') + ')';
}
Example #2
Source File: fieldOverrides.test.ts From grafana-chinese with Apache License 2.0 | 4 votes |
describe('FieldOverrides', () => {
beforeAll(() => {
standardFieldConfigEditorRegistry.setInit(getStandardFieldConfigs);
});
const f0 = new MutableDataFrame();
f0.add({ title: 'AAA', value: 100, value2: 1234 }, true);
f0.add({ title: 'BBB', value: -20 }, true);
f0.add({ title: 'CCC', value: 200, value2: 1000 }, true);
expect(f0.length).toEqual(3);
// Hardcode the max value
f0.fields[1].config.max = 0;
f0.fields[1].config.decimals = 6;
const src: FieldConfigSource = {
defaults: {
unit: 'xyz',
decimals: 2,
},
overrides: [
{
matcher: { id: FieldMatcherID.numeric },
properties: [
{ prop: 'decimals', value: 1 }, // Numeric
{ prop: 'title', value: 'Kittens' }, // Text
],
},
],
};
it('will merge FieldConfig with default values', () => {
const field: FieldConfig = {
min: 0,
max: 100,
};
const f1 = {
unit: 'ms',
dateFormat: '', // should be ignored
max: parseFloat('NOPE'), // should be ignored
min: null, // should alo be ignored!
};
const f: DataFrame = toDataFrame({
fields: [{ type: FieldType.number, name: 'x', config: field, values: [] }],
});
const processed = applyFieldOverrides({
data: [f],
standard: standardFieldConfigEditorRegistry,
fieldOptions: {
defaults: f1 as FieldConfig,
overrides: [],
},
replaceVariables: v => v,
theme: getTheme(),
})[0];
const out = processed.fields[0].config;
expect(out.min).toEqual(0);
expect(out.max).toEqual(100);
expect(out.unit).toEqual('ms');
});
it('will apply field overrides', () => {
const data = applyFieldOverrides({
data: [f0], // the frame
fieldOptions: src as FieldDisplayOptions, // defaults + overrides
replaceVariables: (undefined as any) as InterpolateFunction,
theme: (undefined as any) as GrafanaTheme,
})[0];
const valueColumn = data.fields[1];
const config = valueColumn.config;
// Keep max from the original setting
expect(config.max).toEqual(0);
// Don't Automatically pick the min value
expect(config.min).toEqual(undefined);
// The default value applied
expect(config.unit).toEqual('xyz');
// The default value applied
expect(config.title).toEqual('Kittens');
// The override applied
expect(config.decimals).toEqual(1);
});
it('will apply set min/max when asked', () => {
const data = applyFieldOverrides({
data: [f0], // the frame
fieldOptions: src as FieldDisplayOptions, // defaults + overrides
replaceVariables: (undefined as any) as InterpolateFunction,
theme: (undefined as any) as GrafanaTheme,
autoMinMax: true,
})[0];
const valueColumn = data.fields[1];
const config = valueColumn.config;
// Keep max from the original setting
expect(config.max).toEqual(0);
// Don't Automatically pick the min value
expect(config.min).toEqual(-20);
});
});