mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Histogram: Respect min/max panel settings for x-axis (#62273)
This commit is contained in:
parent
8cd4866df7
commit
8f8baf1a07
@ -53,6 +53,10 @@ export function getBucketSize(frame: DataFrame) {
|
||||
const prepConfig = (frame: DataFrame, theme: GrafanaTheme2) => {
|
||||
// todo: scan all values in BucketMin and BucketMax fields to assert if uniform bucketSize
|
||||
|
||||
// since this is x axis range, this should ideally come from xMin or xMax fields, not a count field
|
||||
// though both methods are probably hacks, and we should just accept explicit opts into this prepConfig
|
||||
let { min: xScaleMin, max: xScaleMax } = frame.fields[2].config;
|
||||
|
||||
let builder = new UPlotConfigBuilder();
|
||||
|
||||
// assumes BucketMin is fields[0] and BucktMax is fields[1]
|
||||
@ -64,8 +68,8 @@ const prepConfig = (frame: DataFrame, theme: GrafanaTheme2) => {
|
||||
let minSpace = u.axes[axisIdx]._space;
|
||||
let bucketWidth = u.valToPos(u.data[0][0] + bucketSize, 'x') - u.valToPos(u.data[0][0], 'x');
|
||||
|
||||
let firstSplit = u.data[0][0];
|
||||
let lastSplit = u.data[0][u.data[0].length - 1] + bucketSize;
|
||||
let firstSplit = incrRoundDn(xScaleMin ?? u.data[0][0], bucketSize);
|
||||
let lastSplit = incrRoundUp(xScaleMax ?? u.data[0][u.data[0].length - 1] + bucketSize, bucketSize);
|
||||
|
||||
let splits = [];
|
||||
let skip = Math.ceil(minSpace / bucketWidth);
|
||||
@ -84,6 +88,14 @@ const prepConfig = (frame: DataFrame, theme: GrafanaTheme2) => {
|
||||
orientation: ScaleOrientation.Horizontal,
|
||||
direction: ScaleDirection.Right,
|
||||
range: (u, wantedMin, wantedMax) => {
|
||||
// these settings will prevent zooming, probably okay?
|
||||
if (xScaleMin != null) {
|
||||
wantedMin = xScaleMin;
|
||||
}
|
||||
if (xScaleMax != null) {
|
||||
wantedMax = xScaleMax;
|
||||
}
|
||||
|
||||
let fullRangeMin = u.data[0][0];
|
||||
let fullRangeMax = u.data[0][u.data[0].length - 1];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user