Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions changelogs/fragments/10718.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Incorrect bucket options displayed ([#10718](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/10718))
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,23 @@ export const BarVisStyleControls: React.FC<BarVisStyleControlsProps> = ({
onStyleChange({ [key]: value });
};

const bucketType =
axisColumnMappings[AxisRole.X]?.schema === VisFieldType.Numerical
? axisColumnMappings[AxisRole.Y] === undefined
? 'single'
: 'num'
: axisColumnMappings[AxisRole.X]?.schema === VisFieldType.Date
? 'time'
: 'cate';
const axes = [axisColumnMappings[AxisRole.X], axisColumnMappings[AxisRole.Y]];
const hasCategory = axes.some((axis) => axis?.schema === VisFieldType.Categorical);
const hasNum = axes.some((axis) => axis?.schema === VisFieldType.Numerical);
const hasDate = axes.some((axis) => axis?.schema === VisFieldType.Date);

// 4 bucket types for bar chart:
// 1. time-numerical(Regular histogram): requires one axis to be date type, bucket options: time interval + aggregationType
// 2. categorical-numerical: requires one axis to be categorical type, bucket options: aggregationType only
// 3. numerical-numerical: both x and y axes are numerical, bucket options: bucket size + bucket count + aggregationType
// 4. single-numerical: only x-axis mapped (numerical), y-axis displays count of records, bucket options: bucket size + bucket count
const bucketType = hasDate
? 'time'
: hasCategory
? 'cate'
: hasNum && axisColumnMappings[AxisRole.Y] !== undefined
? 'num'
: 'single';

// The mapping object will be an empty object if no fields are selected on the axes selector. No
// visualization is generated in this case so we shouldn't display style option panels.
Expand Down
Loading