UNPKG

@grafana/ui

Version:
69 lines (64 loc) 2.17 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var jsxRuntime = require('react/jsx-runtime'); var data = require('@grafana/data'); var schema = require('@grafana/schema'); var BarGauge = require('../../../BarGauge/BarGauge.cjs'); var MaybeWrapWithLink = require('../components/MaybeWrapWithLink.cjs'); var constants = require('../constants.cjs'); var utils = require('../utils.cjs'); "use strict"; const defaultScale = { mode: data.ThresholdsMode.Absolute, steps: [ { color: "blue", value: -Infinity }, { color: "green", value: 20 } ] }; const BarGaugeCell = ({ value, field, theme, height, width, rowIdx }) => { var _a; const displayValue = field.display(value); const cellOptions = utils.getCellOptions(field); const heightOffset = constants.TABLE.CELL_PADDING * 2; let config = data.getFieldConfigWithMinMax(field, false); if (!config.thresholds) { config = { ...config, thresholds: defaultScale }; } let barGaugeMode = schema.BarGaugeDisplayMode.Gradient; let valueDisplayMode = void 0; if (cellOptions.type === schema.TableCellDisplayMode.Gauge) { barGaugeMode = (_a = cellOptions.mode) != null ? _a : schema.BarGaugeDisplayMode.Gradient; valueDisplayMode = cellOptions.valueDisplayMode !== void 0 ? cellOptions.valueDisplayMode : schema.BarGaugeValueMode.Text; } const alignmentFactors = utils.getAlignmentFactor(field, displayValue, rowIdx); const renderedHeight = Math.min(height - heightOffset, constants.TABLE.MAX_CELL_HEIGHT); return /* @__PURE__ */ jsxRuntime.jsx(MaybeWrapWithLink.MaybeWrapWithLink, { field, rowIdx, children: /* @__PURE__ */ jsxRuntime.jsx( BarGauge.BarGauge, { width, height: renderedHeight, field: config, display: field.display, text: { valueSize: 14 }, value: displayValue, orientation: data.VizOrientation.Horizontal, theme, alignmentFactors, itemSpacing: 1, lcdCellWidth: 8, displayMode: barGaugeMode, valueDisplayMode } ) }); }; exports.BarGaugeCell = BarGaugeCell; //# sourceMappingURL=BarGaugeCell.cjs.map