Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix gauge field formatters (#12913) #12961

Merged
merged 1 commit into from
Jul 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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