From 138c8c348eaf209c59c72d478528006d6082e6d1 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Fri, 27 Apr 2018 13:41:20 +0200 Subject: [PATCH] revert renaming of unit key ppm #11211 removed the unit key ppm in favor of conppm. A change which is not forward compatible. This commit revert the unit key back to ppm. Also adds some better error description if trying to use a unit which don't exists. Fixes #11743 --- public/app/core/utils/kbn.ts | 4 ++-- public/app/plugins/panel/graph/graph.ts | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/public/app/core/utils/kbn.ts b/public/app/core/utils/kbn.ts index 0909bd36f69..f4ee7af3383 100644 --- a/public/app/core/utils/kbn.ts +++ b/public/app/core/utils/kbn.ts @@ -596,7 +596,7 @@ kbn.valueFormats.radr = kbn.formatBuilders.decimalSIPrefix('R'); kbn.valueFormats.radsvh = kbn.formatBuilders.decimalSIPrefix('Sv/h'); // Concentration -kbn.valueFormats.conppm = kbn.formatBuilders.fixedUnit('ppm'); +kbn.valueFormats.ppm = kbn.formatBuilders.fixedUnit('ppm'); kbn.valueFormats.conppb = kbn.formatBuilders.fixedUnit('ppb'); kbn.valueFormats.conngm3 = kbn.formatBuilders.fixedUnit('ng/m3'); kbn.valueFormats.conngNm3 = kbn.formatBuilders.fixedUnit('ng/Nm3'); @@ -1101,7 +1101,7 @@ kbn.getUnitFormats = function() { { text: 'concentration', submenu: [ - { text: 'parts-per-million (ppm)', value: 'conppm' }, + { text: 'parts-per-million (ppm)', value: 'ppm' }, { text: 'parts-per-billion (ppb)', value: 'conppb' }, { text: 'nanogram per cubic metre (ng/m3)', value: 'conngm3' }, { text: 'nanogram per normal cubic metre (ng/Nm3)', value: 'conngNm3' }, diff --git a/public/app/plugins/panel/graph/graph.ts b/public/app/plugins/panel/graph/graph.ts index 8a2aea8c4c2..07ce0fed49f 100755 --- a/public/app/plugins/panel/graph/graph.ts +++ b/public/app/plugins/panel/graph/graph.ts @@ -634,6 +634,9 @@ function graphDirective(timeSrv, popoverSrv, contextSrv) { function configureAxisMode(axis, format) { axis.tickFormatter = function(val, axis) { + if (!kbn.valueFormats[format]) { + throw new Error(`Unit '${format}' is not supported`); + } return kbn.valueFormats[format](val, axis.tickDecimals, axis.scaledDecimals); }; }