UNPKG

@grafana/ui

Version:
29 lines (24 loc) 1.6 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var schema = require('@grafana/schema'); var types = require('./types.cjs'); "use strict"; function buildScaleKey(config, fieldType) { var _a, _b, _c, _d, _e, _f, _g; const defaultPart = "na"; const scaleRange = `${config.min !== void 0 ? config.min : defaultPart}-${config.max !== void 0 ? config.max : defaultPart}`; const scaleSoftRange = `${((_a = config.custom) == null ? void 0 : _a.axisSoftMin) !== void 0 ? config.custom.axisSoftMin : defaultPart}-${((_b = config.custom) == null ? void 0 : _b.axisSoftMax) !== void 0 ? config.custom.axisSoftMax : defaultPart}`; const scalePlacement = `${((_c = config.custom) == null ? void 0 : _c.axisPlacement) !== void 0 ? (_d = config.custom) == null ? void 0 : _d.axisPlacement : schema.AxisPlacement.Auto}`; const scaleUnit = (_e = config.unit) != null ? _e : types.FIXED_UNIT; const scaleDistribution = ((_f = config.custom) == null ? void 0 : _f.scaleDistribution) ? getScaleDistributionPart(config.custom.scaleDistribution) : schema.ScaleDistribution.Linear; const scaleLabel = Boolean((_g = config.custom) == null ? void 0 : _g.axisLabel) ? config.custom.axisLabel : defaultPart; return `${scaleUnit}/${scaleRange}/${scaleSoftRange}/${scalePlacement}/${scaleDistribution}/${scaleLabel}/${fieldType}`; } function getScaleDistributionPart(config) { if (config.type === schema.ScaleDistribution.Log) { return `${config.type}${config.log}`; } return config.type; } exports.buildScaleKey = buildScaleKey; //# sourceMappingURL=internal.cjs.map