fix gauge field formatters (#12913)

This commit is contained in:
Peter Pisljar 2017-07-18 17:41:27 +02:00 committed by GitHub
parent b69a446db8
commit 7da4efe302
2 changed files with 8 additions and 4 deletions

View file

@ -153,7 +153,6 @@ export function MeterGaugeProvider() {
const minAngle = this.gaugeConfig.minAngle;
const angleFactor = this.gaugeConfig.gaugeType === 'Meter' ? 0.75 : 1;
const maxRadius = (Math.min(width, height / angleFactor) / 2) * marginFactor;
const yFieldFormatter = this.gaugeChart.handler.data.get('yAxisFormatter');
const extendRange = this.gaugeConfig.extendRange;
const maxY = _.max(data.values, 'y').y;
@ -262,7 +261,10 @@ export function MeterGaugeProvider() {
const percentage = Math.round(100 * (d.y - min) / (max - min));
return `${percentage}%`;
}
return yFieldFormatter(d.y);
if (d.aggConfig) {
return d.aggConfig.fieldFormatter('text')(d.y);
}
return d.y;
})
.attr('style', 'dominant-baseline: central;')
.style('text-anchor', 'middle')

View file

@ -103,7 +103,6 @@ export function SimpleGaugeProvider() {
drawGauge(svg, data, width) {
const tooltip = this.gaugeChart.tooltip;
const isTooltip = this.gaugeChart.handler.visConfig.get('addTooltip');
const yFieldFormatter = this.gaugeChart.handler.data.get('yAxisFormatter');
const fontSize = this.gaugeChart.handler.visConfig.get('gauge.style.fontSize');
const labelColor = this.gaugeConfig.style.labelColor;
@ -179,7 +178,10 @@ export function SimpleGaugeProvider() {
const percentage = Math.round(100 * (d.y - min) / (max - min));
return `${percentage}%`;
}
return yFieldFormatter(d.y);
if (d.aggConfig) {
return d.aggConfig.fieldFormatter('text')(d.y);
}
return d.y;
})
.attr('style', 'dominant-baseline: central; font-weight: bold; white-space: nowrap;text-overflow: ellipsis;overflow: hidden;')
.style('text-anchor', 'middle')