Heatmap: fix formatting (#21433)

* add formatting

* remove logging
This commit is contained in:
Ryan McKinley 2020-01-10 03:50:30 -08:00 committed by Torkel Ödegaard
parent 15fe58f193
commit 7521d2bba0
2 changed files with 16 additions and 6 deletions

View File

@ -2,7 +2,7 @@ import * as d3 from 'd3';
import $ from 'jquery';
import _ from 'lodash';
import { getValueBucketBound } from './heatmap_data_converter';
import { getValueFormat } from '@grafana/data';
import { getValueFormat, formattedValueToString } from '@grafana/data';
const TOOLTIP_PADDING_X = 30;
const TOOLTIP_PADDING_Y = 5;
@ -273,9 +273,9 @@ export class HeatmapTooltip {
}
countValueFormatter(decimals: number, scaledDecimals: any = null) {
const format = 'short';
const fmt = getValueFormat('short');
return (value: number) => {
return getValueFormat(format)(value, decimals, scaledDecimals);
return formattedValueToString(fmt(value, decimals, scaledDecimals));
};
}
}

View File

@ -6,7 +6,14 @@ import * as ticksUtils from 'app/core/utils/ticks';
import { HeatmapTooltip } from './heatmap_tooltip';
import { mergeZeroBuckets } from './heatmap_data_converter';
import { getColorScale, getOpacityScale } from './color_scale';
import { toUtc, PanelEvents, GrafanaThemeType, getColorFromHexRgbOrName, getValueFormat } from '@grafana/data';
import {
toUtc,
PanelEvents,
GrafanaThemeType,
getColorFromHexRgbOrName,
getValueFormat,
formattedValueToString,
} from '@grafana/data';
import { CoreEvents } from 'app/types';
const MIN_CARD_SIZE = 1,
@ -441,11 +448,14 @@ export class HeatmapRenderer {
const format = this.panel.yAxis.format;
return (value: any) => {
try {
return format !== 'none' ? getValueFormat(format)(value, decimals, scaledDecimals) : value;
if (format !== 'none') {
const v = getValueFormat(format)(value, decimals, scaledDecimals);
return formattedValueToString(v);
}
} catch (err) {
console.error(err.message || err);
return value;
}
return value;
};
}