diff --git a/public/app/plugins/panel/heatmap/partials/axes_editor.html b/public/app/plugins/panel/heatmap/partials/axes_editor.html
index 9d711078718..67e05f00a12 100644
--- a/public/app/plugins/panel/heatmap/partials/axes_editor.html
+++ b/public/app/plugins/panel/heatmap/partials/axes_editor.html
@@ -21,6 +21,10 @@
+
+
+
+
{
@@ -340,21 +345,29 @@ export class HeatmapRenderer {
this.ctrl.decimals = decimals;
const tickValueFormatter = this.tickValueFormatter.bind(this);
- function tickFormatter(valIndex: d3.AxisDomain) {
- let valueFormatted = tsBuckets[valIndex.valueOf()];
- if (!isNaN(toNumber(valueFormatted)) && valueFormatted !== '') {
- // Try to format numeric tick labels
- valueFormatted = tickValueFormatter(decimals)(toNumber(valueFormatted));
- }
- return valueFormatted;
+ function tickFormatter(yAxisWidth: number | null) {
+ return function (valIndex: d3.AxisDomain) {
+ let valueFormatted = tsBuckets[valIndex.valueOf()];
+ if (!isNaN(toNumber(valueFormatted)) && valueFormatted !== '') {
+ // Try to format numeric tick labels
+ valueFormatted = tickValueFormatter(decimals)(toNumber(valueFormatted));
+ } else if (valueFormatted && typeof valueFormatted === 'string' && valueFormatted !== '') {
+ if (yAxisWidth) {
+ const scale = 0.15; // how to have a better calculation for this
+ const trimmed = valueFormatted.substring(0, Math.floor(yAxisWidth * scale));
+ const postfix = trimmed.length < valueFormatted.length ? '...' : '';
+ valueFormatted = `${trimmed}${postfix}`;
+ }
+ }
+ return valueFormatted;
+ };
}
-
- const tsBucketsFormatted = map(tsBuckets, (v, i) => tickFormatter(i));
+ const tsBucketsFormatted = map(tsBuckets, (v, i) => tickFormatter(null)(i));
this.data.tsBucketsFormatted = tsBucketsFormatted;
const yAxis = d3
.axisLeft(this.yScale)
- .tickFormat(tickFormatter)
+ .tickFormat(tickFormatter(this.getPanelYAxisWidth()))
.tickSizeInner(0 - this.width)
.tickSizeOuter(0)
.tickPadding(Y_AXIS_TICK_PADDING);
@@ -840,4 +853,12 @@ export class HeatmapRenderer {
this.scope.chartWidth = this.chartWidth;
this.scope.chartTop = this.chartTop;
}
+
+ private getPanelYAxisWidth(): number | null {
+ if (!this.panel.yAxis.width) {
+ return null;
+ }
+
+ return isNaN(this.panel.yAxis.width) ? null : parseInt(this.panel.yAxis.width, 10);
+ }
}