import { css } from '@emotion/css'; import React, { ChangeEvent, FC } from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { Stack } from '@grafana/experimental'; import { Icon, InlineField, InlineLabel, TextArea, useStyles2 } from '@grafana/ui'; import { HoverCard } from 'app/features/alerting/unified/components/HoverCard'; import { ExpressionQuery } from '../types'; interface Props { labelWidth: number | 'auto'; query: ExpressionQuery; onChange: (query: ExpressionQuery) => void; onRunQuery: () => void; } const mathPlaceholder = 'Math operations on one or more queries. You reference the query by ${refId} ie. $A, $B, $C etc\n' + 'The sum of two scalar values: $A + $B > 10'; export const Math: FC = ({ labelWidth, onChange, query, onRunQuery }) => { const onExpressionChange = (event: ChangeEvent) => { onChange({ ...query, expression: event.target.value }); }; const styles = useStyles2(getStyles); const executeQuery = () => { if (query.expression) { onRunQuery(); } }; return (
Math operator
Run math operations on one or more queries. You reference the query by {'${refId}'} ie. $A, $B, $C etc.
Example: $A + $B
Available Math functions
See our additional documentation on{' '} Math expressions .
} > Expression
} labelWidth={labelWidth} grow={true} shrink={true} >