mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
heatmap: middle bucket bound option, #15683
This commit is contained in:
parent
7167fa9d07
commit
9dbcc0fb6e
@ -32,6 +32,7 @@ export class AxesEditorCtrl {
|
|||||||
Auto: 'auto',
|
Auto: 'auto',
|
||||||
Upper: 'upper',
|
Upper: 'upper',
|
||||||
Lower: 'lower',
|
Lower: 'lower',
|
||||||
|
Middle: 'middle',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,9 @@ export class HeatmapTooltip {
|
|||||||
};
|
};
|
||||||
|
|
||||||
boundBottom = tickFormatter(yBucketIndex);
|
boundBottom = tickFormatter(yBucketIndex);
|
||||||
boundTop = yBucketIndex < data.tsBuckets.length - 1 ? tickFormatter(yBucketIndex + 1) : '';
|
if (this.panel.yBucketBound !== 'middle') {
|
||||||
|
boundTop = yBucketIndex < data.tsBuckets.length - 1 ? tickFormatter(yBucketIndex + 1) : '';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Display 0 if bucket is a special 'zero' bucket
|
// Display 0 if bucket is a special 'zero' bucket
|
||||||
const bottom = yData.y ? yData.bounds.bottom : 0;
|
const bottom = yData.y ? yData.bounds.bottom : 0;
|
||||||
@ -122,8 +124,9 @@ export class HeatmapTooltip {
|
|||||||
boundTop = bucketBoundFormatter(yData.bounds.top);
|
boundTop = bucketBoundFormatter(yData.bounds.top);
|
||||||
}
|
}
|
||||||
valuesNumber = countValueFormatter(yData.count);
|
valuesNumber = countValueFormatter(yData.count);
|
||||||
|
const boundStr = boundTop && boundBottom ? `${boundBottom} - ${boundTop}` : boundBottom || boundTop;
|
||||||
tooltipHtml += `<div>
|
tooltipHtml += `<div>
|
||||||
bucket: <b>${boundBottom} - ${boundTop}</b> <br>
|
bucket: <b>${boundStr}</b> <br>
|
||||||
count: <b>${valuesNumber}</b> <br>
|
count: <b>${valuesNumber}</b> <br>
|
||||||
</div>`;
|
</div>`;
|
||||||
} else {
|
} else {
|
||||||
|
@ -379,6 +379,12 @@ export class HeatmapRenderer {
|
|||||||
const posX = this.getYAxisWidth(this.heatmap) + Y_AXIS_TICK_PADDING;
|
const posX = this.getYAxisWidth(this.heatmap) + Y_AXIS_TICK_PADDING;
|
||||||
this.heatmap.select('.axis-y').attr('transform', 'translate(' + posX + ',' + posY + ')');
|
this.heatmap.select('.axis-y').attr('transform', 'translate(' + posX + ',' + posY + ')');
|
||||||
|
|
||||||
|
if (this.panel.yBucketBound === 'middle' && tickValues && tickValues.length) {
|
||||||
|
// Shift Y axis labels to the middle of bucket
|
||||||
|
const tickShift = 0 - this.chartHeight / (tickValues.length - 1) / 2;
|
||||||
|
this.heatmap.selectAll('.axis-y text').attr('transform', 'translate(' + 0 + ',' + tickShift + ')');
|
||||||
|
}
|
||||||
|
|
||||||
// Remove vertical line in the right of axis labels (called domain in d3)
|
// Remove vertical line in the right of axis labels (called domain in d3)
|
||||||
this.heatmap
|
this.heatmap
|
||||||
.select('.axis-y')
|
.select('.axis-y')
|
||||||
|
Loading…
Reference in New Issue
Block a user