Skip to content

Commit

Permalink
fix gauge field formatters (#12913) (#12961)
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar authored Jul 27, 2017
1 parent 6d7a033 commit c3f7b66
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/ui/public/vislib/visualizations/gauges/meter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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')
Expand Down
6 changes: 4 additions & 2 deletions src/ui/public/vislib/visualizations/gauges/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit c3f7b66

Please sign in to comment.