|
|
|
@ -160,13 +160,13 @@ export function buildHistogram(frames: DataFrame[], options?: HistogramTransform |
|
|
|
|
for (const frame of frames) { |
|
|
|
|
for (const field of frame.fields) { |
|
|
|
|
if (field.type === FieldType.number) { |
|
|
|
|
allValues = allValues.concat( |
|
|
|
|
field.values.toArray().map((val: number) => Number(val.toFixed(field.config.decimals ?? 0))) |
|
|
|
|
); |
|
|
|
|
allValues = allValues.concat(field.values.toArray()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
allValues = allValues.filter((v) => v != null); |
|
|
|
|
|
|
|
|
|
allValues.sort((a, b) => a - b); |
|
|
|
|
|
|
|
|
|
let smallestDelta = Infinity; |
|
|
|
@ -204,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; |
|
|
|
@ -220,7 +223,7 @@ export function buildHistogram(frames: DataFrame[], options?: HistogramTransform |
|
|
|
|
unit: undefined, |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
if (!config && Object.keys(field.config).length) { |
|
|
|
|
if (!config && field.config.unit) { |
|
|
|
|
config = field.config; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -251,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, |
|
|
|
|