Skip to content
This repository was archived by the owner on Apr 7, 2025. It is now read-only.

fix calibration chart edge case #6552

Merged
merged 3 commits into from
Feb 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/client/hmi-client/src/services/charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { ChartAnnotation, FunmanInterval } from '@/types/Types';
import { CalendarDateType, SensitivityChartType } from '@/types/common';
import { countDigits, fixPrecisionError } from '@/utils/number';
import { format } from 'd3';
import { BinParams } from 'vega-lite/build/src/bin';
import { flattenInterventionData } from './intervention-policy';
import type { FunmanBox, FunmanConstraintsResponse } from './models/funman-service';

Expand Down Expand Up @@ -404,12 +405,17 @@ export function createHistogramChart(dataset: Record<string, any>[], options: Hi
domain: opts.variables.map((v) => v.label ?? v.field),
range: opts.variables.map((v) => v.color)
};
const bin = { maxbins: maxBins, extent };
let bin: BinParams | null = { maxbins: maxBins, extent };

// If there is only one value (min and max extent are the same), we do not want to bin it
if (extent[0] === extent[1]) {
bin = null;
}
const aggregate = 'count';
return opts.variables.map((varOption) => ({
mark: { type: 'bar', width: varOption.width, tooltip: true },
encoding: {
x: { bin, field: varOption.field, axis: xaxis, scale: { padding: xPadding } },
x: { bin, field: varOption.field, axis: xaxis, scale: { padding: xPadding }, type: 'quantitative' },
y: { aggregate, axis: yaxis },
color: {
legend: { ...legendProperties },
Expand Down
Loading