import { css } from '@emotion/css'; import { ChangeEvent } from 'react'; import * as React from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { Icon, InlineField, InlineLabel, TextArea, Toggletip, useStyles2, Stack, TextLink } from '@grafana/ui'; import { t, Trans } from 'app/core/internationalization'; 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 = ({ labelWidth, onChange, query, onRunQuery }: Props) => { const onExpressionChange = (event: ChangeEvent) => { onChange({ ...query, expression: event.target.value }); }; const styles = useStyles2(getStyles); const executeQuery = () => { if (query.expression) { onRunQuery(); } }; return (
Run math operations on one or more queries. You reference the query by {'{{refExample}}'} ie.{' '} {'{{ref1}}'}, {'{{ref2}}'}, {'{{ref3}}'} etc.
Example: {'{{example}}'}
Available math functions
} title={ Math operator } footer={
See our additional documentation on{' '} Math expressions .
} closeButton={true} placement="bottom-start" >
Expression
} labelWidth={labelWidth} grow={true} shrink={true} >