(cherry picked from commit 173636aa61)
Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
co-authored by
Leon Sorokin
parent
a0aba4319f
commit
17b083f861
@@ -165,6 +165,8 @@ export function buildHistogram(frames: DataFrame[], options?: HistogramTransform
|
||||
}
|
||||
}
|
||||
|
||||
allValues = allValues.filter((v) => v != null);
|
||||
|
||||
allValues.sort((a, b) => a - b);
|
||||
|
||||
let smallestDelta = Infinity;
|
||||
@@ -202,6 +204,9 @@ export function buildHistogram(frames: DataFrame[], options?: HistogramTransform
|
||||
|
||||
const getBucket = (v: number) => incrRoundDn(v - bucketOffset, bucketSize!) + bucketOffset;
|
||||
|
||||
// guess number of decimals
|
||||
let bucketDecimals = (('' + bucketSize).match(/\.\d+$/) ?? ['.'])[0].length - 1;
|
||||
|
||||
let histograms: AlignedData[] = [];
|
||||
let counts: Field[] = [];
|
||||
let config: FieldConfig | undefined = undefined;
|
||||
@@ -249,7 +254,13 @@ export function buildHistogram(frames: DataFrame[], options?: HistogramTransform
|
||||
values: new ArrayVector(joinedHists[0]),
|
||||
type: FieldType.number,
|
||||
state: undefined,
|
||||
config: config ?? {},
|
||||
config:
|
||||
bucketDecimals === 0
|
||||
? config ?? {}
|
||||
: {
|
||||
...config,
|
||||
decimals: bucketDecimals,
|
||||
},
|
||||
};
|
||||
const bucketMax = {
|
||||
...bucketMin,
|
||||
|
||||
Reference in New Issue
Block a user